You are viewing limited content. For full access, please sign in.

Question

Posted to Laserfiche Cloud

Question

new designer in Cloud default values for address field

asked on December 13

How can I put default values for Province and Country so that initiators do not have to type in Saskatchewan Canada ?

0 0

Answer

SELECTED ANSWER
replied two days ago

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.

1 0

Replies

replied two days ago

You can use JavaScript to do it by adding the following code:

 

LFForm.setFieldValues({variableName: "AddressDelivery"}, {country: "Canada", province: "Saskatchewan"});

 

1 0
replied two days ago

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?

0 0
SELECTED ANSWER
replied two days ago

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.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.