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.

Unable to use backslash '\' in the run script activity of workflow

Gaurav Bhatia
Mega Guru

Hi All,

I have created a workflow on RITM table. In that workflow I have used a run script activity. Inside that activity, I am inserting a record in custom table. While setting one field value of that table I am getting an error. Field should be as shown below-

var domain = '';

var deviceName = '';

Now I am setting the value of above 2 variables in the script. The value coming dynamically. Now I wanted to concatenate these 2 variable value add would like to add a backslash in b/w them like below-

Var obj = domain + '\' + deviceName;

Example: var obj = UK\test;

now this backslash is giving error

find_real_file.png

 

If I use any space or any other character just after backslash then I am not getting error. But I don't want to use any space after that. See no error when I have uses space

find_real_file.png

 

I tried substring, split and trim and slice. But did not work.

 

Please help.

 

Regards,

Gaurav

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

try this.  ( \' ) is an escape character so prefixing this with another backslash will remove one backslash and you will only left with one.  

var obj = domain + '\\' + deviceName; 

 

 

 

 

Regards,
Muhammad

View solution in original post

3 REPLIES 3

MrMuhammad
Giga Sage

try this.  ( \' ) is an escape character so prefixing this with another backslash will remove one backslash and you will only left with one.  

var obj = domain + '\\' + deviceName; 

 

 

 

 

Regards,
Muhammad

Thanks. It worked.

Happy to Help. 🙂

Regards,
Muhammad