- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 08:49 PM
HI Team,
I am using the below script in Flow designer and it works fine .
Could you please let me know if it is best practice to use sys_id of a record directly in flow designer script.
If not please let me know the alternatives we can use.
Thank you
var var1 = fd_data._2__get_catalog_variables.<variable name>;
var assignmentgroup = "";
if(var1=='X')
{
assignmentgroup='<sys_id of XYZ>';
}
else if(var1=='Y')
{
assignmentgroup='<sys_id of ABC>';
}
return assignmentgroup;
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 09:28 PM
Hi,
Is there a need to use scripts ? Can't data pills be used to compare the catalog variable with assignment group references directly ? That way you don't have to hard code sys_ids.
Thanks,
Arav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 09:28 PM
Hi,
Is there a need to use scripts ? Can't data pills be used to compare the catalog variable with assignment group references directly ? That way you don't have to hard code sys_ids.
Thanks,
Arav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 12:42 AM
Hi Arav,
could you please let me know how to edit the existing flow designer steps using Data pills , I want to add if- condition to the existing Flow Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 09:49 PM
Hi,
it's not recommended to use hard-coded sysIds
Why not use system properties to hold those sysIds and use gs.getProperty()
var var1 = fd_data._2__get_catalog_variables.<variable name>;
var assignmentgroup = "";
if(var1=='X')
{
assignmentgroup= gs.getProperty('propertyXYZ'); // this property holds XYZ group sysId
}
else if(var1=='Y')
{
assignmentgroup = gs.getProperty('propertyABC'); // this property holds ABC group sysId
}
return assignmentgroup;
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 12:21 AM
Hi Ankur,
The script doesn't work if i use gs.getProperty() in Flow Designer
Any other suggestions?