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.

Setting the Default Location

GUPE
Kilo Explorer

Hi,

Does anyone know how i can get the location field to auto-populate with the customers location.

We previously had a default value and i have now removed this so the location shows as blank but I want to link this to the users location.

Any help or advice on this would be great.

Thanks in advance.

2 REPLIES 2

stephmcl303
Tera Guru

Hi,



you can use an on-change client script to do this something like the below....



<code>


function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading)
          return;


    if (newValue == '') {
          g_form.setValue("location", "");
          return;
    }
    var caller = g_form.getReference("customer", setLocationFromCaller);
}


function setLocationFromCaller(customer) {
    g_form.setValue("location", customer.location);


}


</code>


RKumar3
Tera Guru

You can write an "After" business rule for the record table e.g. Incident and add below code in the same.



current.location = current.caller_id.location;



It should work fine.