Need help with custom calculation script

Contributor ,
Dec 02, 2020

Copy link to clipboard

Copied

Please help, I don't know how to apply these together in the same text field.  Thank you!

event.value = this.getField("WO1").valueAsString;

var a ="";
if (this.getField("Absence1").value == "Vacation (Construction)"){
a="12";
} else if (this.getField("Absence1").value == "Sick (Construction"){
a="34";
} else if (this.getField("Absence1").value == "Vacation (Maintenance)"){
a="56";
} else if (this.getField("Absence1").value == "Sick (Maintenance)"){
a="78";
} else if (this.getField("StandingWorkOrders1").value == "1122334 Maintenance"){
a="1122334";
} else if (this.getField("StandingWorkOrders1").value == "1122334 Maintenance"){
a="1122334";
} else if (this.getField("WO1").value == " "){
a=" ";
}
event.value = a;

 

In "Employee1" field first option Is " Lawrence 1234" it should probably be without space like this "Lawrence 1234".
In "Employee2" field you have same code as in "Employee1" code for "AbsencePayTypeJob1Emp1" field you should change to affect "AbsencePayTypeJob1Emp2" instead.
In "WO1EMP2" field you have some code in custom keystroke field. Is that suppose to be there?
There is lot of bugs in your file, and I'm not sure what exactly you mean by "Using two scripts in one field"? what scripts?
Anyway you can use something like this in WO1EMP1 field:

if (this.getField("AbsencePayTypeJob1Emp1").value == "Vacation"){
event.value ="12";
} else if (this.getField("AbsencePayTypeJob1Emp1").value == "Sick"){
event.value="34";
}
else event.value = this.getField("WO1").valueAsString;

Adapt it to your needs. Hope this helps 🙂

TOPICS
Acrobat SDK and JavaScript

Views

43

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Need help with custom calculation script

Contributor ,
Dec 02, 2020

Copy link to clipboard

Copied

Please help, I don't know how to apply these together in the same text field.  Thank you!

event.value = this.getField("WO1").valueAsString;

var a ="";
if (this.getField("Absence1").value == "Vacation (Construction)"){
a="12";
} else if (this.getField("Absence1").value == "Sick (Construction"){
a="34";
} else if (this.getField("Absence1").value == "Vacation (Maintenance)"){
a="56";
} else if (this.getField("Absence1").value == "Sick (Maintenance)"){
a="78";
} else if (this.getField("StandingWorkOrders1").value == "1122334 Maintenance"){
a="1122334";
} else if (this.getField("StandingWorkOrders1").value == "1122334 Maintenance"){
a="1122334";
} else if (this.getField("WO1").value == " "){
a=" ";
}
event.value = a;

 

In "Employee1" field first option Is " Lawrence 1234" it should probably be without space like this "Lawrence 1234".
In "Employee2" field you have same code as in "Employee1" code for "AbsencePayTypeJob1Emp1" field you should change to affect "AbsencePayTypeJob1Emp2" instead.
In "WO1EMP2" field you have some code in custom keystroke field. Is that suppose to be there?
There is lot of bugs in your file, and I'm not sure what exactly you mean by "Using two scripts in one field"? what scripts?
Anyway you can use something like this in WO1EMP1 field:

if (this.getField("AbsencePayTypeJob1Emp1").value == "Vacation"){
event.value ="12";
} else if (this.getField("AbsencePayTypeJob1Emp1").value == "Sick"){
event.value="34";
}
else event.value = this.getField("WO1").valueAsString;

Adapt it to your needs. Hope this helps 🙂

TOPICS
Acrobat SDK and JavaScript

Views

44

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 02, 2020 0
Engaged ,
Dec 02, 2020

Copy link to clipboard

Copied

Where in your file should this code go?

What for is first line event.value = this.getField("WO1").valueAsString;?

You have some duplicate lines,missing bracket at "Sick (Construction").

How do you get "Vacation Maintenance and "Sick Maintenance" options?

In dropdown field check "Commit selected value Immediately".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 02, 2020 0
Contributor ,
Dec 03, 2020

Copy link to clipboard

Copied

I updated the document with more explanation of what I need to do.  I can't post the actual document I'm working on because there are names and employee #'s.  I need the custom calculation script to go into the WO1Emp1 and WO1Emp2 text fields.  The first line event is to populate what has been entered in the work order # text field (WO1).  I put a script in the Employee Name text fields to switch the Absence dropdown list.  I need different work order numbers to populate depending on the employee name selection.  I must have missed checking the 'commit selected value immediately' button, but I still can't get the work order numbers to populate.  I need both WO1Emp1 and WO1Emp2 to populate from WO1 text field, unless an employee chooses absence then I need that number to change.  Eg.  WO1 text field filled in, populates to WO1Emp1 and WO1Emp2, Employee 2 chooses Vacation then WO1Emp2 work order number changes.  I hope this helps!  Thank you so much for helping me out with this!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2020 0
Enthusiast ,
Dec 03, 2020

Copy link to clipboard

Copied

In "Employee1" field first option Is " Lawrence 1234" it should probably be without space like this "Lawrence 1234".
In "Employee2" field you have same code as in "Employee1" code for "AbsencePayTypeJob1Emp1" field you should change to affect "AbsencePayTypeJob1Emp2" instead.
In "WO1EMP2" field you have some code in custom keystroke field. Is that suppose to be there?
There is lot of bugs in your file, and I'm not sure what exactly you mean by "Using two scripts in one field"? what scripts?
Anyway you can use something like this in WO1EMP1 field:

if (this.getField("AbsencePayTypeJob1Emp1").value == "Vacation"){
event.value ="12";
} else if (this.getField("AbsencePayTypeJob1Emp1").value == "Sick"){
event.value="34";
}
else event.value = this.getField("WO1").valueAsString;

Adapt it to your needs. Hope this helps 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2020 0
Contributor ,
Dec 03, 2020

Copy link to clipboard

Copied

YES!  That's exactly what I need to do!!  I needed an 'else' in there!  Sorry about my document, my original is all good.  I had to put together a simplied version and it's wasn't so easy.  I can't tell you how much I appreciate your help, you made my day!  Thank you so much!!!  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2020 0