,Choice value with special character not working in transform script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 06:17 AM - edited 02-20-2023 06:18 AM
Hi,
I have created property to store choice values and mapping in onbefore transform script using property. It is working fine for other values except for one value which has special character in choice label and backend value(OOB).
Property x has below values and 3rd one not working ie., mapping is not happening and resulting in empty, as a work around, I'm updating records with these values from list view using "update all" after records created. what I have observed is first value has special character "/" and its working, 3rd value has additional '' special character,may that's causing issue, anyway to make this work??
{
"Application(s) / Isolated Network":"Application(s) / Isolated Network",
"Infrastructure Specific Testing":"Infrastructure Specific Testing",
"Application(s) / 'Live' test":"Application(s) / 'Live' Test",
"Data Center Failover":"Data Center Failover"
}
Onbefore script:
var methodValue = gs.getProperty('x');
var obj = JSON.parse(methodValue.toString());
target.exercise_method = obj[source.u_exercise_type];
Regards,
Shravani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 07:11 AM
Hi Shravani,
I have tried the below script in background seems working fine
var y = gs.getProperty("x"); // Property with name x created containing JSON name value pair
gs.log(y);
var z="Application(s) / 'Live' test";
var json = JSON.parse(y);
gs.log(json["Application(s) / Isolated Network"]);
gs.log(json["Infrastructure Specific Testing"]);
gs.log(json["Application(s) / 'Live' test"]);
gs.log(json["Data Center Failover"]);
gs.log(json[z]);
If my answer has helped with your question, please mark it as helpful and give it a thumbs up!
Regards,
Harshal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 07:40 AM
Hello,
It may be an issue with this line:
JSON.parse(methodValue.toString()
You could try using:
var obj = JSON.parse(methodValue);
instead.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!