• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add another value to my custom calculation script

Engaged ,
Aug 20, 2018 Aug 20, 2018

Copy link to clipboard

Copied

This works when I add the following script to the Custom Calculation in the 'JobType' text field, I type Regular in my 'Status' Text Field the number 1 shows up in 'Job Type' text field.

The problem is I also need to be able to type Temp so the number 2 shows up, but when I try to add it and and I type Regular in the 'Status' field 2 shows up in 'Job Type', not 1.  I've tried everything and it's probably so simple

var a ="";

     if (this.getField("Status").value == "Regular"){

     a="1";

     }

     event.value = a;

TOPICS
Acrobat SDK and JavaScript

Views

536

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
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 21, 2018 Aug 21, 2018

Use this code:

var a ="";

if (this.getField("Status").value == "Regular"){

    a="1";

} else if (this.getField("Status").value == "Temp"){

    a="2";

}

event.value = a;

Votes

Translate

Translate
Community Expert ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

Use this code:

var a ="";

if (this.getField("Status").value == "Regular"){

    a="1";

} else if (this.getField("Status").value == "Temp"){

    a="2";

}

event.value = a;

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

You are truly awesome!!  Thank you so much!!

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

So I'm not sure if you can help me with this as well, or at least tell me it can't be done.

Where I am having a glitch with what I am trying to do is with the Acting Rate for 'Auxiliary'.  Auxiliary is the the only one I don't want to auto populate to 'Acting' to Pay Type Description , it's hard to explain so I hope the code below makes sense

//The Status will be autopopulated from the Employee Drop Down List to Pay Type Description field

var a =""; 

if (this.getField("Status").value == "Regular"){ 

    a="1"; 

} else if (this.getField("Status").value == "Temp"){ 

    a="2"; 

} else if (this.getField("Status").value == "Auxiliary"){ 

    a="3"; 

event.value = a; 

// Place Acting Rate data into Pay Codes and Pay Type Description, except Auxiliary needs to remain the same on Pay Type Description if Acting, they can't change to 'Acting' as per below

var ActingData = { "1060 Foreman 1":{JobType: "089DO",

JobStep: "0632"

PayType: "Acting"},

                 "1031 Foreman 2":{ JobType: "048DO",

JobStep: "0694"

PayType: "Acting"},

                 "1054 Subforeman":{ JobType: "031DO",

JobStep: "0620"

PayType: "Acting"},

                 "1011 Equipment Operator 1":{ JobType: "068DO",

JobStep: "0970"

PayType: "Acting"},

                 "1015 Equipment Operator 4A":{ JobType: "091DO",

JobStep: "0260"

PayType: "Acting"},

                 "1021 Truck Driver 1":{ JobType: "031DO",

JobStep: "0810"

PayType: "Acting"},

                 "1022 Truck Driver 2":{ JobType: "047DO",

JobStep: "0320"

PayType: "Acting" },

                 "1023 Truck Driver 3":{ JobType: "071DO",

JobStep: "0980"

PayType: "Acting" },

                 "1039 Lead Hand Asphalt":{ JobType: "523DO",

JobStep: "1699"

PayType: "Acting" },

                 "1047 Rough Carpenter":{ JobType: "089DO",

JobStep: "0790"

PayType: "Acting" },

                 "1013 Sweeper Operator":{ JobType: "034DO",

JobStep: "0860"

PayType: "Acting" },

                 "1005 Painter Tradesman 1":{ JobType: "059DO",

JobStep: "0890"

PayType: "Acting" }};

function SetFieldValuesActingJob1Emp1(cActingName)

{

  this.getField("Type Job1Emp1").value = ActingData[cActingName].JobType;

  this.getField("Step Job1Emp1").value = ActingData[cActingName].JobStep;

  this.getField("PayTypeDesc Job1Emp1").value = ActingData[cActingName].Acting;

}

Votes

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
community guidelines
Community Expert ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

So if "Auxiliary" is selected, you don't want to set the value of "Type Job1Emp1", "Step Job1Emp1" and "PayTypeDesc Job1Emp1" to the data from the data-model, but clear them instead?

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

Just the "PayTypeDesc JobEmp1"

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

If an employee picks Tracey from the "Employee List" and I'm a regular employee it will auto populate

'Regular' to "PayTypeDesc Job1Emp1",

but then I pick an Acting Rate from the drop down called "Acting Rate Job1Emp1" it will change from

'Regular' to 'Acting' in "PayTypeDesc Job1Emp1" and populate "Type Job1Emp1", "Step Job1Emp1",

If a employee picks Sean from the from the "Employee List" drop down and he's an Auxiliary it will auto populate

'Auxiliary' to "PayTypeDesc Job1Emp2",

but then he would also pick an Acting Rate from the drop down called "Acting Rate Job1Emp2" but it would stay as 'Auxiliary' and still populate "Type Job1Emp1", "Step Job1Emp1"

Sorry, I know it's confusing and I'm sure there needs to be an 'else' in there somewhere, I just don't know where or how I could do this

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

Oops, I just replied to myself, can you still see my comment in this thread Try67?

Votes

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
community guidelines
Community Expert ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

Yes, but I'm having a hard time following your explanation...

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

Arg!  I just posted my comment to myself again!!  I'm seriously losing it here lol, hopefully you can see the comment I meant to replied to you here, twice

Votes

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
community guidelines
Community Expert ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

It doesn't matter who you reply to. All replies are posted on the public forum and are visible to everyone.

Votes

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
community guidelines
Engaged ,
Aug 21, 2018 Aug 21, 2018

Copy link to clipboard

Copied

LATEST

Awesome, and my apologies for the confusion, it's so hard to explain it.  I will work on it more and will ask again if I can come up with a clear description of what I need.

Votes

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
community guidelines