Transform map script to update the target field value based on other target field value

Sagar S
Tera Contributor

Need to update the target field value based on another target field , which script to use, currently tried with OnAfter transform script but it is not giving the expected behaviour. Please help if there is any issues in the below script.

 

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

    if (target.u_remediation_complete == "true") {
        target.state = 3;
        target.update();
    }
 
   

})(source, map, log, target);
 
After loading excel sheet, u_remediation_complete field is updating false and also state is not updating Complete as well, 
1 REPLY 1

Vishal Birajdar
Giga Sage

HI @Sagar S 

 

You can try onBefore transform map script :

 

var sourceValue = source.u_remediation_complete;

if(sourceValue == 'true'){

target.state = '3';

}

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates