set reference field value using flow designer

Shrinidhi Amin
Tera Contributor

I have a text field variable in catalog .

I want to set the text field value to the  parent field of cmdb relationship table which is a reference field using flow designer.

Can someone suggest some solution .

Urgent requirement

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

not possible directly. but why to have it as text variable. If user doesn't give valid name the parent field cannot be set.

parent field is reference to cmdb_ci table so you will have to set sys_id in that field only

you will have to use inline f(x) script

script would look something like this

I assume user would enter name of CI which can be found in cmdb_ci table

var sysId = fd_data.trigger.current.sys_id;

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', sysId);
gr.query();
if(gr.next()){
	var name = gr.variables.enter_name;
	var rec = new GlideRecord('cmdb_ci');
	if(rec.get('name', name)){
		return rec.getUniqueValue();
	}
}

regards
Ankur

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

View solution in original post

9 REPLIES 9

@Shrinidhi Amin 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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

@Shrinidhi Amin 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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

hi @Ankur Bawiskar  sir my requirement is almost same but the difference  is to create a change task using of change request record . and the change request field is a reference field

can u help me

@Aman66 

Can you post a separate question as this is quite older one? Please tag me there

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

PriyaRanji
Tera Guru

Hello,

Is there any specific need to keep the field as string instead of reference? Since for mapping the CI relationship (cmdb_rel_ci) between child & parent CI, the CI should be exists in your configuration item. 

Parent - reference (ci)

child - reference (ci)

In the flow designer, before CI relationship creation please check whether already relationship exists or not. If not then create the relationship accordingly.

Thanks,

Priyanka R