I need to copy the last 7 characters of the RITM number into a new field I created on sc_req_item

Suzanne Coffman
Tera Guru

Based on this post Solved: Flow Designer - adding "substring to remove last c... - ServiceNow Community

and others I have tried a number of approaches to a script in the Update Requested Item Record action of a fb flow to copy the last 7 characters (the numeric part) of the RITM number into a new field I created on the sc_req_item table called u_contractor_id.

 

I am new to scripting

 

I have tried multiple variations of the following:

return substring(fd_data.trigger.request_item.number,4,7)
 
and
var a = fd_data.trigger.request_item.number;
//var st = a.toString(); it should already be a string?
var cid = a.substring(4,7)
//gs.print(cid);
 
Suggestions?  
1 ACCEPTED SOLUTION

Can you show your configuration? 
Please compare it with this (working) example:

MarkusKraus_1-1684473435993.png

Note that the applied transformations are as follows:

1.) Substring (Start Index=4, Leave End Index empty)

2.) Convert String to Number (No arguments)

 

 

 

View solution in original post

5 REPLIES 5

Suzanne Coffman
Tera Guru

The transform approach worked.  Neither script worked.

But that's fine, I'd rather avoid using scripts anyway.

It turns out the "not a valid record" error I kept getting was do to a bad catalog variable.