We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

onafter transform script help

Priya123
Tera Contributor

In continuation to my previous query, 

 

 need to write a onafter transform script to update a couple of Fields after the import / transform. But i do see one option is via Glide... but i would not have a specific way to search every record  to update the same .. is there a better way to perform this operation as i need to update a couple of fields after every Row is completed

 

sample: i need to update the status and state fields based on the dates imported

 

 

Tried this but doesnt seem to work right 

I need to check for conditions before updating, so i used a similiar script

 

on the customer project table 

if (target.<datefield value> > sysDate )

{

target.phase == 'value to be updated'

}

 

am trying this way as there is no specific way to search for records using Glide

1 ACCEPTED SOLUTION

Riya Verma
Kilo Sage

Hi @Priya123 ,

 

Hope you are doing great.

 

To achieve this, you can use an "onafter" transform script in ServiceNow to update fields after the import/transform process. In your case, you want to update the 'status' and 'state' fields based on certain date conditions.

if (target.<datefield value> > gs.now()) {
    target.status = 'new status value';
    target.state = 'new state value';
}
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

View solution in original post

2 REPLIES 2

Riya Verma
Kilo Sage

Hi @Priya123 ,

 

Hope you are doing great.

 

To achieve this, you can use an "onafter" transform script in ServiceNow to update fields after the import/transform process. In your case, you want to update the 'status' and 'state' fields based on certain date conditions.

if (target.<datefield value> > gs.now()) {
    target.status = 'new status value';
    target.state = 'new state value';
}
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Priya123
Tera Contributor

This is what i tried and it did not Work ..