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

Uttam Sai
Tera Contributor

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
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

Hello Uttam,

Could you please share the screenshot of flow designer what error you are getting when using the gs.getProperty()

THanks

@Uttam Sai 

it should work fine. it's server side and gs.getProperty() should work there.

Share the script and screenshots

Regards
Ankur

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

Pavankumar_1
Mega Patron

Hi,

As Ankur mentioned it is not good to use the static values in Flow and use system properties.

I knew that system properties will not work to get system properties in flow.

Please refer below article 

https://community.servicenow.com/community?id=community_article&sys_id=4725e2941b830150a59033f2cd4bcbd0

 

Hope you it helps you.

Please Mark Correct/helpful if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Naga Ravindra R
Kilo Sage

Hello there,

 

You can store the sys_id's of assignment groups in the system properties. Make sure type is string in system property. And use them in flow by calling as below:

gs.getProperty('property name of respective assignment group');