create asset reference field on requested.item table and re-reference it to sc_task table

AbdulrehmanT
Kilo Guru

Hey,

Happy Monday!!
I need some help. In service now I have created a reference field name assets that is coming from hardware table on request_item, now I want the same field on sc_task table with same data from RITM asset field.. But it should be read only. (the asset field on sc_task should only pull data of requested.item asset field)

How I can achieve this?

3 ACCEPTED SOLUTIONS

Masthan Sharif
Tera Guru

Hi @AbdulrehmanTAbdulrehmanT,

Hope you're doing well!

 

You can dot walk to get the field on to the Catalog Task table (from RITM table), please check the following example that I tried

I created a field 'Related Asset' on RITM table/form

MasthanSharif_0-1751897042619.png

I went to the form layout of Catalog Task(sc_task), select the Requested Item field, expand selected reference field and dot walk to the exact field on the reference field's table field, in my case I dot walked from Requested Item field on Catalog Task to Related Asset field on RITM table

 

MasthanSharif_2-1751897391152.png

MasthanSharif_3-1751897443391.png

 

MasthanSharif_4-1751897602486.png

 

 

Best Regards,

Sharif

View solution in original post

AbdulrehmanT
Kilo Guru

I have found the solution, created a business rule on requested_item by creating a reference field(alm_hardware) on both table i.e. sc_task, sc_req_item

Before - Insert/update
Condition - Assets<< changes 

(function executeRule(current, previous /null when async/) {

var taskGR = new GlideRecord('sc_task');
taskGR.addQuery('request_item', current.sys_id); // Link to RITM
taskGR.query();

while (taskGR.next()) {
taskGR.u_ritm_assedt = current.u_asset; // Copy the asset from RITM
taskGR.update(); // Save changes
}

})(current, previous);

View solution in original post

The no code solution would have been a dotwalked field, so it's always exactly the same and only show it on the form for the items you want it on (ui policy). You now have 2 custom fields that need to be in sync, instead of handling everything through one field, without any scripts.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@AbdulrehmanT 

you can use before insert business rule on sc_task and set the value

current.assetFieldTask = current.request_item.assetFieldRITM;

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

could you please give me the cmplete code

 

Mark Manders
Mega Patron

Just dotwalk the field from the RITM. No need to create it on sc_task. You already have the RITM on the task, so dotwalking to the field is easy and a UI policy can make it read only.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

could you please tell me how to do dot walk