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.

Is it the best practice to use sys_id in Flow Designer Script

Uttam Sai
Tera Expert

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;

1 ACCEPTED SOLUTION

Arav
Tera Guru

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

View solution in original post

8 REPLIES 8

Arav
Tera Guru

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

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

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

The script doesn't work if i use gs.getProperty() in Flow Designer 

Any other suggestions?