setting reference field value

_bhishek
Tera Guru

Hi All,

I have a small query .

I have one configuration item field for RITM and TASK both which is referencing to cmdb_ci table .For one catalog item i want to display one configuration item .

I tried run script in workflow with below 

task.cmdb_ci="Automated Regulation";

Also i tried with Insert update BR with setting valuse of cmdb ci field to same value on RITM table .

But value is not being displayed .Please suggest me what am i missing here .Or suggest any other way to achieve this .

Thanks .

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

For SC Task you can use this

task.setDisplayValue("cmdb_ci","Automated Regulation");

For RITM Record you can use Run Script activity in your workflow

current.setDisplayValue("cmdb_ci","Automated Regulation");

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Tony Chatfield1
Kilo Patron

Hi, for a reference field you need to populate the sys_id of the reference record, not it's 'name'
if you do not have the sys_id you will need to use GlideRecord to look it up.
Assuming the name is unique, something like this should work.

var myCI = new GlideRecord('yourCITable');

if(myCi.get('fieldName', 'thenameOfTheCI')) { // use if conditon to ensure we only populate with a match

task.cmdb_ci = myCi.sys_id;

}

Hi Tony,

Thanks for your response .

It's working for task can you help me for RITM also .How can i set for RITM for same field.

Thanks.

Shruti
Mega Sage
Mega Sage

For RITM current.configuration_item = "sys_id of CI";

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

For SC Task you can use this

task.setDisplayValue("cmdb_ci","Automated Regulation");

For RITM Record you can use Run Script activity in your workflow

current.setDisplayValue("cmdb_ci","Automated Regulation");

Regards
Ankur

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