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

Making a basic invoice pdf and cannot get my total field to set the value right.

Community Beginner ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

var total
{
for(i2 = 0; i2 < 18; i2++)// Itteration through Lines
{
var itemVolume = String(this.getField('105' + 'Qu' + i2).valueAsString); // Declares Item volume variable and targets each lines volume field
if(itemVolume > 0)// Checks for values of 1 or greater
console.println(itemVolume)
{
total + (this.getField('105' + 'Pri' + i2)).valueAsString;
this.getField("105Total").valueAsString = total
}
}
}

 

 

 

My Field names are 105PriX and 105QuX  X being 0-18 It is currently just setting my total field to the word [Object Field] if im not mistaken i should be solving that with .valueAsString? Would appreciate any and all help thank you very much!

TOPICS
JavaScript

Views

467

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 ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

You doesn't you set any value for total.

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 Beginner ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

Total is being set based off the values of (this.getField('105' + 'Pri' + i2) do i need to set it to 0 to start with?

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 Beginner ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

When i try setting a value for total other than the total + (this.getField('105' + 'Pri' + i2)).valueAsString; it just over rides me trying to set the value in the loop and will return whatever i set the value to.

 

 

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 ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

Try this:

total = total + Number(this.getField('105' + 'Pri' + i2).valueAsString);

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 Beginner ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

Awesome thank you very much solved one problem only thing is now it keeps building up the total variable every time i run the program Would it be better to set total to 0 outside of the loop so it resets once it finishes my for loop?  Or would it be better to have a clear button that sets total to 0? Sorry started this project months ago so a little rusty on js thanks for the help!

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 ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

LATEST

For the loop use:

var total = 0;

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