Current number value is not being passed to Catalog task's Request Item field

mattmg
Tera Guru

Hi All, 

 

I have a small button on the Requested Item, which allows me to create ad-hoc task and relate it to the current RITM:

 

var catalogtask = new GlideRecord("sc_task");

catalogtask.short_description = "Any other equipment - WEEE ticket";
catalogtask.description = "Please list all additional not registered devices in a flied 'Any Other equipment' ";
catalogtask.assignment_group = "af7227d6db57c410bf0e5858dc961925";
catalogtask.request_item = current.number;

var sysID = catalogtask.insert();

current.sc_task= sysID;
gs.addInfoMessage("WEEE " + catalogtask.number + " for any other equipment has been created");

action.setRedirectURL(catalogtask);

 

I did not change anything in this script in the last 4 months, but I noticed that

 

catalogtask.request_item = current.number;

 

is not passing the correctly number to the Request Item field on the new task:

mattmg_0-1713362536922.png

 

Can any advise what is going on, I can't figure it out.

 

I tried add .getDisplayValue(), and I can pass it to any string field.

 

14 REPLIES 14

Ubada Barmawar
Giga Guru

try passing sys_id instead of number, because "request item" is a reference field.

**bleep** it, it tried before, but I though I am going to give it once again a go, it works! Many thanks

Actually, it now pass the value, but when you try to save it, it disappears 

Krushna R Birla
Kilo Sage

Hi @mattmg 

 

I have modified your code, please use below code

 

var catalogtask = new GlideRecord("sc_task");
catalogtask.initialize();
catalogtask.short_description = "Any other equipment - WEEE ticket";
catalogtask.description = "Please list all additional not registered devices in a flied 'Any Other equipment' ";
catalogtask.assignment_group = "af7227d6db57c410bf0e5858dc961925";
catalogtask.request_item = current.sys_id.toString();

var sysID = catalogtask.insert();

current.sc_task = sysID;
gs.addInfoMessage("WEEE " + catalogtask.number + " for any other equipment has been created");

action.setRedirectURL(catalogtask);
 

This will definitely helps you to resolved your issue. Let me know in case you need to understand the flow or you can DM on LinkedIn.

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla