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

That's great idea, thanks. But I run in to the problem: when I logged url out: there is no "sys_is_related_list" in  it:  find_real_file.png
So script fails to update any fields. When I click ok on alert url reloads and than it contains this parameter. 

Hi,

if you are clicking new button from the related list of any form that parameter should be there

that would help you identify if record is being created from normal table list or from related list

did you add alert for url? what came

can you share the complete one?

Regards
Ankur

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

I jus alerted URL:  find_real_file.png

and this is full alert:
find_real_file.png

Hi,

it should contain that parameter

Did you check for some other table?

You are on incident form and click on New button for incident task in related list; you should see that

Is this because you customized the New button on that related list table?

Regards
Ankur

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

I was customizing copy of OOTB "new" ui action but now I completely removed it and I'm using regular "New" ui action on that related list. This parameter is there but not in the moment when client script runs but a while after.

I quickly changed this client script to incident_task and it url doesn't contain this parameter either:
find_real_file.png