Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Please fix this script

1dusjhyahnt
Tera Contributor

var ritmGR = new GlideRecord("sc_req_item");
ritmGR.get(current.sys_id);
var groupName = ritmGR.variables.group_name;
gr.initialize();
current.description="added + " + groupName;//here i am fetching sys_id not group name , requirement is fetching group name.
gr.insert();

 

I am fetching sys_id in description not group name so please fix it

3 REPLIES 3

Sarika S Nair1
Kilo Sage

Hi @1dusjhyahnt 

try 

var groupName = ritmGR.variables.group_name.getDisplayValue();

kps sumanth
Mega Guru

Hello @1dusjhyahnt ,

 

Please replace your line number 3 to below and it will work as expected, I have validated in my PDI.

var groupName = ritmGR.variables.group_name.getDisplayValue().toString();


Please mark this as accepted if this works for you.

AshishKM
Kilo Patron
Kilo Patron

Hi @1dusjhyahnt , 

 

Please be sure and explain the business case for this script.

You are using the current.sys_id to get a reference of record from RITM table and again updating the description of same record using the current.description

 

and this gr.initialize() and gr.insert() , what's role of these two lines in this code because this gr not declared ( may be you have more code but not shared here ) 

 

if you are trying to copy groupname to description in the same record then only one line of code will update that.

 

current.description = current.group_name.getDisplayValue().toString();

 

 

So explain the use case and where you are using this script code ( script include, BR, fix script etc. )

 

-Thanks,

AshishKM

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution