Transform script to check string contains

Nisha30
Kilo Sage

Hi Community,

I have below code OnAfter which is not working. This is to if the string contains the intended string if yes then need to set a Target field with specific value . This is via uploading via excel. Any suggestions please.

 

if(source.u_sprint.toString().indexOf('Sprint 1')>-1)

Target.sprint = "P SP 1";

if(source.u_sprint.toString().indexOf('Sprint 2')>-1)

Target.sprint = "P SP 2";

if(source.u_sprint.toString().indexOf('Sprint 3')>-1)

Target.sprint = "P SP 3";

 

Thanks

 

9 REPLIES 9

Sandeep Rajput
Tera Patron
Tera Patron

@Nisha30 Please update the script as follows and check if the change works.

 

if(source.u_sprint.toString().indexOf('Sprint 1')>-1)
target.sprint = "P SP 1";
if(source.u_sprint.toString().indexOf('Sprint 2')>-1)
target.sprint = "P SP 2";
if(source.u_sprint.toString().indexOf('Sprint 3')>-1)
target.sprint = "P SP 3";

Hope this helps.

Hi @Sandeep Rajput 

Thanks for response not sure what is the difference in here with the existing code.

Thanks

 

Hi @Nisha30 

you use Target.sprint instead of target.sprint.

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

another issue is the value in the excel sheet for field 'sprint' is getting inserted as new record even though choice= ignore and the source.u_sprint gives the inserted record sys_id. thats wierd why it should give the insetted record sys_id and not the string from excel sheet.

 

any leads on this please

thanks