Does the script works with out runtransform script function in on before transform script?

KM SN
Tera Expert

I have writtern script without starting run transformscript function but used source and target objects will it going to work for that matter whatever may be the type of transform script.

transform script.png

 

1 ACCEPTED SOLUTION

Hi @KM SN,

 

I can confirm (as tested and verified on an instance), you can indeed leverage the target.field_name (in your case (target.user_name) in an onAfter Transform Script.

 

You will need to wrap them within the function braces as shown below, but it can simply log  the target.user_name as desired.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

 

Screenshot 2024-07-03 at 09.36.34.png

View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @KM SN,

 

To answer your question directly: Yes - both 'source' and 'target' objects are available.

Providing a little more information and context, you'll notice in the function parameters some keywords/objects available for each Script Type of which source and target are declared.

 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

// Add your code here

})(source, map, log, target);

 

 

SN Docs link to Transform Map Scripts and Variables: https://docs.servicenow.com/bundle/washingtondc-integrate-applications/page/script/server-scripting/...

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

Hi Robbie, Thanks for reply

You mistaken me, the actual query is does target and source parameters will work if i use them in the script without the function as indicated in the screenshot of line one.

Thanks
 Mani

Hi @KM SN,

 

I can confirm (as tested and verified on an instance), you can indeed leverage the target.field_name (in your case (target.user_name) in an onAfter Transform Script.

 

You will need to wrap them within the function braces as shown below, but it can simply log  the target.user_name as desired.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

 

Screenshot 2024-07-03 at 09.36.34.png

Thanks for reply.

Regards
Mani