By selecting the Opened for I want to Auto populate Contact number by using the Sciptinclude

kranthi2
Tera Expert

Hi,

i have used the below script with contact number modifications but it is not working as expected. hence contact number is not populating

please find the below mentioned Screenshots for the same.

 

onChange.pngScript.png

 

variable.png

 

Please help me out if i can do any modifications in the script.

Thanks,

18 REPLIES 18

I have tried it but nu luck.

Ankur Bawiskar
Tera Patron
Tera Patron

@kranthi2 

If you are on Utah or later release you can use auto-populate feature

Did you explore that?

New in Utah! Auto-populate variable based on a reference 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes Ankur, i have used the same feature and it is working fine as well.

But if i login to the end user then Contact number is not populating.

(or)

If i impersonate then it is not working hence my boss is suggested to use the Scriptinclude.

 

Please help me on the same.

 

Thanks, 

 

Community Alums
Not applicable

@kranthi2 , base on your code, it should work. Try below:

- Set the UI Type to 'All'

- Inside Script Include, add log message

gs.info('contact_no', contact_no); // add this line
return contact_no;

 - Inside Client script, add an alert to see if you can get the value

if (contact_num) {
	alert(contact_num); // add this line
	g_form.setValue('u_pre_contact', contact_num);
}

 - Make sure you have that value for selected user in user record.