Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

onBefore Transform script not working

Suresh Kathavar
Tera Contributor

I have created a OnBefore transform script to perform a task, script in initiating but particular block of code is not working. Earlier i tried with includes to match string from my glide record. Later i even tried with indexOf also with TRIM

Here is my current code

var searchTerm = 'Marked for deletion';
if ((trim(source.u_description).indexOf(trim(searchTerm)) > -1))
    {
        gs.log("Welcome to update on TRIM");
        target.u_ad_delete_status = 'In Progress';
    }

 

1 ACCEPTED SOLUTION

pratikjagtap
Giga Guru
Giga Guru

Hi @Suresh Kathavar ,

Use below script :

 

var searchTerm = 'Marked for deletion';
var description = (source.u_description || '').toString().trim();

if (description.indexOf(searchTerm.trim()) > -1) {
gs.log("Matched string found. Setting delete status to In Progress");
target.u_ad_delete_status = 'In Progress';
}

 

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik

View solution in original post

1 REPLY 1

pratikjagtap
Giga Guru
Giga Guru

Hi @Suresh Kathavar ,

Use below script :

 

var searchTerm = 'Marked for deletion';
var description = (source.u_description || '').toString().trim();

if (description.indexOf(searchTerm.trim()) > -1) {
gs.log("Matched string found. Setting delete status to In Progress");
target.u_ad_delete_status = 'In Progress';
}

 

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik