Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Autopopulate field choice when another field choice is selected

Community Alums
Not applicable

Hi all,

On the "customer_account" table, I need a script that will autopopulate the choice "u_annual" in the field "billing_info" whenever the choice "u_years" is selected in the "billing_history" field.

Additionally, is there a way to update this for both existing records and future ones in the same script?

Thanks.

2 REPLIES 2

Vrushali  Kolte
Mega Sage

Hello @Community Alums ,


You can create an on change client script on "u_years" field and use the below script -



function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == 'billing_history'){
   g_form.setValue('billing_info','u_annual');  //please check the field and option names
}
}

Also, if you want to execute this use case at server side you can create a After insert/update BR, configure the condition and set the field value accordingly.


If my answer solves your issue, please mark it as Accepted and Helpful based on the impact.