- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 02:27 AM
Hi All,
Hope everyone is enjoying working in ServiceNow 😊.
I am developing a custom flow action which will react based on Name/ Values inputs datatype. as shown below
which will eventually return a Object with same data inside script step.
I have verified this object inside the logs and sending data as expected :
{"Name":"Nilesh","Dept":"SNOW"}
But when I am trying to use any function inside the script step for keys and values operations as follows, its giving unexpected result :
The output of this script should be like -
Name=Nilesh Dept=SNOW
but when action test is taken it shows different things as follow
replaceAll= function (from, to)
{
return this.replace(from.toString(), to, "g");
}
Also, when I am performing same operation through background script, I can see expected results.
I am new to developing the custom flow actions, but I still wonder how this is happening 😐.
Please let me know if I am doing anything wrong in syntax or some methods.
Thanks in Advance.
#serviceNow #flow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 10:31 AM
Hi All,
Thank you for your time and efforts, as we couldn't find anything related towards the solution of this issue. we did raise HI ticket and the issue is solved.
Following were the discussion points,
1. When we use flow data pill to populate user field data population, the text will be in its original form without escaping i.e. if user has entered any special characters inside field, that will be as it is, and may cause problems while you perform next operations.
e.g. User has entered data in address field which is multiline in the following format
At post A'bad
Dist Aurangabad , MH''- IN
as this data is multiline and having special characters we should first escape it so that the special characters from the sequence will be treated as simple string characters.
Know more about the escape Sequence
2. There is OOB JavaScript utility provided by ServiceNow to esacpe and unescape the string text called as JSUtil. this script include helps preventing the breaking into the strings cause of specials symbols, you can use it as follow
JSUtil.escapeText(String) and then serialize and JSUtil.unescapeText(String) and then de-serialize.
Note : Please take full API name if you are working for scoped Applications.
3. For better user performance and better efficiency, we should restrict fields on client side itself, use an onChange or onSubmit Client Script to capture the special characters
e.g. refer to this Community post
At the end coming to main problem, How I am able to pass correct string inside the flow action input is, I have created a flow variables for all these fields which may contain a special characters and then using JSUtil serialized it. At the end instead of passing simple data from field , I passed the flow variable with escaped text.
Hope this will help for you all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:40 PM
Hi @Ankur Bawiskar @Community Alums @John Zhang1 ,
Please help !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 12:10 AM
did you try creating output variable of type object or json?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 12:40 AM
Hello @Ankur Bawiskar ,
I did not try that as my goal is filling these fields data dynamically in html description which is string, so I want string output.
Thank you !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 01:00 AM
can you please share what's your business requirement along with screenshots?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader