populate one field value in same table another field.

siva58
Tera Contributor

i am created new table with below columns.

1. program manager --> reference to program table 

2. user --> reference to user table.

and similarly i have created few string fields.

1, program managers

2. user name 

3. user email

 

my requirement is i need to populate program manager (reference) field value in the program managers (string)field.

7 REPLIES 7

Sai Kumar B
Mega Sage
Mega Sage

@siva58 

You can write onChange client script with the below code on program manager reference field

 

//Inside the onChange() function paste the below code
if(newValue) {
g_form.setValue('<pass string_field_name>', newValue); //newValue is program manager reference field value
}

 

need solution in BR 

@siva58 

You can try before/update business rule

(function executeRule(current, previous /*null when async*/ ) {

   if(JSUtil.notNil(current.getValue('program_manager')) { //If program manager is not nil
    current.setValue('program_managers', current.program_manager.name);  //Set the string field with program manager name
}

})(current, previous);

Pavankumar_1
Mega Patron

Hi @siva58 ,

If you are trying on the catalog item use Catalog Data Lookup Definition.

Refer below article use can easily populate the values based on the other reference fields.

https://www.servicenow.com/community/developer-articles/catalog-data-lookup-definition-on-any-table-....

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar