How can I put default values for Province and Country so that initiators do not have to type in Saskatchewan Canada ?
Question
Question
new designer in Cloud default values for address field
Answer
If you're using a different form for the Approval (with the same variable), then it won't overwrite it. If you're using the same form throughout, then you can modify the code by adding an if statement to check if the value is empty before setting the field value:
if (LFForm.getFieldValues({variableName: "AddressDelivery"}).province == "") { LFForm.setFieldValues({variableName: "AddressDelivery"}, {province: "Saskatchewan", country: "Canada"}); }
You could additionally check that the country is empty as well, but if they've entered a province then my assumption would be that they've entered a country, and this if statement will only run if they haven't entered a province at all so you're likely fine.
Replies
You can use JavaScript to do it by adding the following code:
LFForm.setFieldValues({variableName: "AddressDelivery"}, {country: "Canada", province: "Saskatchewan"});
Thanks @████████,
with this script in place, If an Initiator changes the province to Manitoba, then the Form loads for the Approver, will the JavaScript over-write Manitoba and change it back to Saskatchewan?
If you're using a different form for the Approval (with the same variable), then it won't overwrite it. If you're using the same form throughout, then you can modify the code by adding an if statement to check if the value is empty before setting the field value:
if (LFForm.getFieldValues({variableName: "AddressDelivery"}).province == "") { LFForm.setFieldValues({variableName: "AddressDelivery"}, {province: "Saskatchewan", country: "Canada"}); }
You could additionally check that the country is empty as well, but if they've entered a province then my assumption would be that they've entered a country, and this if statement will only run if they haven't entered a province at all so you're likely fine.