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

Validation Script Help - Want Drop Down Choice to Autofill Another Field

Community Beginner ,
Aug 26, 2023 Aug 26, 2023

I have set a list of drop-down choices in my sponsorship field and I want my unit price to autofill based on what is selected in the sponsorship field.

 

In the unit price field  properties, I have entered this in the custom validation:

 if(this.getField("Sponsorship1.0").valueAsString=="AuSome Evening Premiere Sponsorship") event.value = "$7,500";
else event.value = ""

 

How do I add more than one validation script for the same field?

I have been googling trying to figure it out and I am still not sure. Any help is appreciated!!!

TOPICS
Edit and convert PDFs
1.6K
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 ,
Aug 26, 2023 Aug 26, 2023

This won't work as a validation script of a text field, instead use it as a custom calculation script.

There is an easier way, just add prices as export values of choices in dropdown field, then in text field as custom calculation script use this:

event.value = this.getField("Sponsorship1.0").value;

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 ,
Aug 26, 2023 Aug 26, 2023

You can't add more than one validation script, but you can add multiple conditions to your code.

The structure for that would be something like this:

 

var sponsorship = this.getField("Sponsorship1.0").valueAsString;
if (sponsorship=="AuSome Evening Premiere Sponsorship") event.value = "$7,500";
else if (sponsorship=="Something else") event.value = "$10,500";
else if (sponsorship=="Something else #2") event.value = "$1,500";
// etc.
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 Beginner ,
Aug 27, 2023 Aug 27, 2023

Thank you!

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 ,
Aug 26, 2023 Aug 26, 2023

This won't work as a validation script of a text field, instead use it as a custom calculation script.

There is an easier way, just add prices as export values of choices in dropdown field, then in text field as custom calculation script use this:

event.value = this.getField("Sponsorship1.0").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 Beginner ,
Aug 27, 2023 Aug 27, 2023

Thanks so much! It is working now! 

 

I entered the export values and now the unit price auto-populates based on the drop downs. Is there a way to make it so if a certain menu item is picked, they can enter whatever text they want in the unit price field. Basically overrided the export value if needed. I have a couple sponsorship options where they can choose how much they want to give and I want to be able to type that amount in my unit price field. 

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 ,
Aug 27, 2023 Aug 27, 2023

Yes, you can use this:

if(this.getField("Sponsorship1.0").valueAsString !== "Free text")
event.value = this.getField("Sponsorship1.0").value;

 

Replace "Free text" with choice you wish user to be able to enter text manually (you don't have to add export value for that choice)

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 Beginner ,
Aug 30, 2023 Aug 30, 2023

Ok can you clarify where I would put this under properties?? And would I keep the original custom calculation script and add this on or replace it, meaning replace this 

event.value = this.getField("Sponsorship1.0").value; ) with the above script?

 
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 ,
Aug 30, 2023 Aug 30, 2023
LATEST

Just replace "Free text" with 'certain item' user will pick to enter custom text.

Replace old script.

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