Script help to set choice list

Service Manager
Kilo Guru

Hi All,

 

We are importing the records into a custom table but we would like to set the value of choice list filed "status" to closed only when we import state as closed. I tried with onchange /onload client script but it didn't work.

 

Thanks

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,

 

Client scripts will not be triggered during the import set process. You can do this via Transform script at the field level. You can update the target value if the source value is closed.

https://docs.servicenow.com/bundle/jakarta-platform-administration/page/script/server-scripting/concept/c_TransformMapScripts.html

 

Thanks,

Pradeep Sharma

Thanks

I tried below code in run script of transform map but unfortunately it didn't work.

 

if(source.field_name = "0" ){                         // field value is the string value coming from the source table              

 

        target.field_name   = "3" ;           // this choice value should already be existing one in choice list of the target table's field

 

}

Hi,

 

Try with the below Field map script.

if(source.field_name == "0" ){                        
 answer  = "3" ;          
 
}

 

 

Unfortunately it didn't work.

actually we have to override the choice field  state to "3(closed)" based on another choice field(status). Only if status  is "0"(closed) then state is "3" and if the status isn't "0" then it would be work in progress (2 )

 

Thanks