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

Custom calculation Script help!

New Here ,
Oct 07, 2024 Oct 07, 2024

I am having issues with this script. The custom calucation scirpt that I put in is correct and when I go to preview and drop down my first box and click on a product the second box next to it changes to the formula I am needing. BUT when I go to the drop down on the second box and click on the correct option it goes back to the first product typed in the options of that product. It won't let me choose another one in the drop down menu.. I am hoping someone can help me with this. Sorry if this kind of confusing I am trying to word this in the best way possible. I have also attached a screen shot of the first dropdown and second dropdown. 

TOPICS
General troubleshooting , JavaScript
1.8K
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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 07, 2024 Oct 07, 2024

That's because you use script as calculation script, try to use script under 'Validate'.

View solution in original post

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 ,
Oct 07, 2024 Oct 07, 2024

That's because you use script as calculation script, try to use script under 'Validate'.

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 ,
Apr 15, 2025 Apr 15, 2025

Can I please get help with a custom calculation?

I have a date field for Date of Violation, but I need an auto-calculation for +13 months from the date indicated in Date of Violation.

Would I then put the code under Validate or Calculate?

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 ,
Apr 15, 2025 Apr 15, 2025

What are the names of your fields?

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 ,
Apr 15, 2025 Apr 15, 2025

Date of Violation (DOV):

13 Months From DOV:

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 ,
Apr 16, 2025 Apr 16, 2025

Try using the following as a custom validation script for the "Date17_af_date" field.
If you're using a different date format, make sure to update "mm/dd/yyyy" accordingly. Otherwise, you can leave it as is:

var m13 = this.getField("Date18_af_date");

if(event.value == "")
 m13.value = "";
else{
 var date = util.scand("mm/dd/yyyy", event.value);
 date.setMonth(date.getMonth() + 13);
 m13.value = util.printd("mm/dd/yyyy", date);}

 

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 ,
Apr 16, 2025 Apr 16, 2025

It didn't work :(. I verified I was using the same format indicated (mm/dd/yyyy). Then I copied and pasted the code into the "Run custom validation script" in "Date18_af_date". Did I do that right?

 

What I would ike to happen is someone chooses the date in "Date17_af_date". When they choose the date (I used a Date field) in "Date17_af_date", then a date 13 months after will auto populate in "Date18_af_date". I also used a Date field for "Date18_af_date", should I use something different like a Text box instead?

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 ,
Apr 16, 2025 Apr 16, 2025

You used script in the wrong field, if you read my post you can see I wrote to put script in "Date17_af_date".

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 ,
Apr 16, 2025 Apr 16, 2025
LATEST

THANK YOU VERY MUCH FOR YOU HELP!

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