Learn the best way to point to a particular group record from a script.
The Situation
- Often times a script will need to reference a particular group (such as an advanced approval script).
- Best Practice states that scripts should use the sys_id of the group rather than the name (because the name will often change).
- Referencing a sys_id in a script makes it difficult to change groups in the future, which reduces flexibility.
The Solution
- Create a new System Property (table = sys_properties), and store the sys_id as the value of the property.
- In your script, reference the system property you created using “gs.getProperty(‘property name here’, ‘default value if desired’)”
Optional, but Recommended:
- After saving, use the related list to assign that System Property to a category.
- Create a new module under the related application that uses “URL from arguments”, and set the URL to be “system_properties_ui.do?sysparm_category={your category name here}”.
Categories: Developers, Scripting Tips
Leave a Reply