Copy link to clipboard
Copied
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!!!
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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 = ""
Copy link to clipboard
Copied
Thank you!
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Just replace "Free text" with 'certain item' user will pick to enter custom text.
Replace old script.