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

Export value is not calculating

Explorer ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

Good morning!

I'm trying something new and looking for a little help : )

I assigned export values to some drop down selections in my form. The values are not calculating in the score field I set up. The score field has a custom script which uses a copy of the drop down fields arranged in an array.

This script works on other forms with number fields validated from 0-4.

What could be keeping the export values of the drop down selections from calculating? Could it be the way I'm naming the fields?

When I try to change the format of the drop down fields to Number, I get a message saying, "The format does not match one or more values specified in the dropdown list. To change the format for this dropdown, first change the dropdown list values in the Options panel to match this format," although, I have assigned each dropdown selection an export value ranging from 0 to 4.

Any suggestions?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

421

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

What kind of calculation did you set up? How did you implement it? If you used a script, post the code.

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
Explorer ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

There are a few sets of questions with drop down selections at the end of each question. Another table is set up at the very end to display percentages for each set of questions.

In the table at the end, each array is hidden and each array leads to a visible score field.

This is what each score field does. I'm thinking it doesn't work because my new form has different names for the fields (which I did enter into the script) or I need to do something else with the dropdown aspect:

var fieldsObj = [["Field1","Score1"], ["Field2","Score2"]];

for (var i in fieldsObj) {

    calcAll(fieldsObj[0], fieldsObj[1]);

}

function calcAll(FieldArrName, FieldScoreName) {

    var f = this.getField(FieldArrName);

    var a = f.getArray();

    var isNotNull = false;

    var termSum = 0;

    var calcDen = 0;

    for (var j=0; j<a.length; j++) {

        if (a.value != a.defaultValue) {

         isNotNull = true;

          termSum += a.value;

          calcDen++;

        }

    }

     

    var s = this.getField(FieldScoreName);

    if (isNotNull){

        s.value = 2* termSum/(calcDen*8);

    }

    else {

        s.value = "";

    }

}

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

Are there any error messages in the JS Console?

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
Explorer ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

I have a couple windows open and there are different messages that appear for each when I press "ctrl+shift+J". I'm not sure which JS Console to look at?

There is an update 11.0.22 that should be installed. Do you think that would make a difference?

Also, I tried naming one set of fields the same names as the original script names but that didn't work either.

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

The window in question is titled "JavaScript Debugger". Press Ctrl+J to display it. Clear its contents (the text area in the lower half, under Console) and then change the value of one of the fields in the file. Any error messages will appear in that text area.

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
Explorer ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

I found it! It gives me these messages:

TypeError: s is null

27:Field:Calculate

TypeError: s is null

27:Field:Calculate

I'm going to start over and name the fields in my new document the same as the old document containing the working script. The only difference will be the fields in the new form will be drop down fields with export values assigned to each selection. That should work, right? Unless, there is something else I need to do regarding the "drop down" properties? Would the change in drop down affect how the script works?

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
LEGEND ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

If a field object is null then there has been no connection to the field. Carefully check your field names.

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

LATEST

Yes, that should work. Remember that JS is case-sensitive. So if a field is called "Text1", it won't work if you try to access "text1"...

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