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

Creating an Invoice

New Here ,
Mar 03, 2023 Mar 03, 2023

I am creating a form to use as an invoice.  I want a text field to populate dependent on a dropdown selection.  My dropdown is titled "Expense" and it holds Option 1, Option 2 and Option 3.  If Option 1 is chosen, the "Total" field shoudl be "$85", Option 2 and 3 = "$125".  Every script I have tried isn't working.  Any sugestions is appreciated.

TOPICS
JavaScript
2.0K
Translate
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 03, 2023 Mar 03, 2023

As custom calculation script of "Total" field use this:

var drop = this.getField("Expense").valueAsString;
if(drop == "Option 1")event.value = 85;
else if(drop == "Option 2" || drop == "Option 3")event.value = 125;
else
event.value = "";
Translate
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
New Here ,
Mar 03, 2023 Mar 03, 2023

It still isn't working for me.  I am very new at this.  Does this look correct to you? 

 

var drop = this.getField("Expense").valueAsString;

if(Total == "Transport from scene to morgue")event.value = 85;

else if(Total == "Transport from morgue to ME")event.value = 125;

else if(Total == "Transport from ME to morgue")event.value = 125;

else event.value = "";

Translate
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 03, 2023 Mar 03, 2023

No. Why did you replace "drop" in line 1 with "Total" in the other lines?

Translate
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
New Here ,
Mar 03, 2023 Mar 03, 2023

I am very new at this aspect of the program.  I changed them all back to "drop" and it still doesn't work.  It now says:

var drop = this.getField("Expense").valueAsString;

if(drop == "Transport from scene to morgue")event.value = 85;

else if(drop == "Transport from morgue to ME")event.value = 125;

else if(drop == "Transport from ME to morgue")event.value = 125;

else event.value = "";

 

It still isn't populating but isn't throwing any errors.  Any help appreciated.

Translate
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 03, 2023 Mar 03, 2023

Check that field name and dropdown choices are all correct.

If you have export value set in dropdown then change "Transport from scene to morgue" to the export value...etc.

If nothing works, please share your file with us.

 

Translate
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
New Here ,
Mar 15, 2023 Mar 15, 2023
LATEST

I finally got it!  I had to put it to the side for a few days.  Thank you so much!  I need to create multiple rows using the same exact thing.  Is there a simple way to do that without having to redo the javascript on each one?

Translate
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