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

abdulrehman
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
Kilo Sage

Hi @abdulrehmanAbdulrehmanT,

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

abdulrehman
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.

View solution in original post

8 REPLIES 8

Masthan Sharif
Kilo Sage

Hi @abdulrehmanAbdulrehmanT,

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

abdulrehman
Kilo Guru

yeah it works but i only wants to show the asset field on some items, not all 

 

abdulrehman
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);

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.