Apostrophe in field map script

Bindhu1
Tera Contributor

Hi team, I have a issue where I have a string value with apostrophe that needs to be set as a close code while running the transform map, I am unable to map the value as it is showing error, is there any way I can do it, please let me know.

Tried Scenarios: 

1. if (source.u_code == "Issue/ Finding won't be solved") {  
                         return "accepted";
                }

2. if (source.u_code == 'Issue/ Finding won\'t be solved') {
                          return "accepted";
                }

these above things doesn't seem to work. Below is the code for reference

Bindhu1_0-1693993590810.png

Thanks in advance.

 

2 REPLIES 2

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
You can change the string like below-

source={};
source.u_code = "Issue/ Finding won't be solved";//string surrounded with double quotes but within sentence single quote can be used.

if (source.u_code == "Issue/ Finding won't be solved") {  
                       gs.info("ok")
                }

 

 


Thanks and Regards,

Saurabh Gupta

Vishal Birajdar
Giga Sage

Hello @Bindhu1 

 

You can just put your message in double quotes (" ") instead of single quotes

 

 

Vishal Birajdar
ServiceNow Developer

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