Setting predefined value on newly created form

Dotychczas
Mega Guru

Hello experts, 

I'm trying to create new record from related list and set some predefined values on the form. I copied "New" ui action:

find_real_file.png

in line 8 I'm trying to set value of audit field but after running this ui action I get info message saying "Record not found". What am I doing wrong?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

don't update OOB ui action

you can use onLoad client script or display business rule on that related list table and set the audit field

onLoad client script on that related list table

function onLoad(){

	var url = top.location.href;
	if(g_form.isNewRecord() && url.indexOf('sys_is_related_list=true') > -1){
		g_form.setValue('audit', '18603524db7830509507a15505961943');
	}

}

Regards
Ankur

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

View solution in original post

15 REPLIES 15

Shruti
Mega Sage
Mega Sage

Hi,

Remove line 8 and paste uri.set('sysparm_query','audit=18603524db7830509507a15505961943'); in line 6

It seems to worked partially: find_real_file.png

field seems to be filed up and when I click on "i" icon I can see the preview of correct record but even if display on audit table is set to name field it's still blank. When I manually change it, the name is displayed properly. 

Try uri.set('sysparm_query','audit='+parent.audit);

uri.set('sysparm_query','audit='+parent.audit_field_name_parent_table);

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

don't update OOB ui action

you can use onLoad client script or display business rule on that related list table and set the audit field

onLoad client script on that related list table

function onLoad(){

	var url = top.location.href;
	if(g_form.isNewRecord() && url.indexOf('sys_is_related_list=true') > -1){
		g_form.setValue('audit', '18603524db7830509507a15505961943');
	}

}

Regards
Ankur

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