Incorrect Development Approval Group Populated Due to "STARTSWITH" Query in Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 09:49 AM - edited 05-19-2025 10:04 PM
Hi All,
A CI is created through a catalog item. After creation, the CI form includes a tab to specify the CI owner, support group, development group, and development approval group. The development approval group is automatically populated based on the selected development group. This works correctly for most CIs, but for one particular CI, the development approval group is being set incorrectly.
Upon investigation, I found that a Script Include is responsible for this behavior—specifically, a section of the code(highlighted below) that uses the "STARTSWITH" operator in a query. Since the group names are very similar, I suspect the "STARTSWITH" condition is matching the wrong group. To ensure the correct development approval group is selected, I believe this operator should be changed to an exact match instead. Even not aware how to check if there are any other CIs are impacted on this, till now it looks good for other CIs. I have attached Script Include and scripts in workflow activity where it is called and pics for your reference .
Thank You
Script Include : -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 10:52 AM
Hello @1_DipikaD ,
You are absolutely correct. The 'STARTSWITH' operator should be avoided since the query could potentially return multiple results in random order, while you need an exact match here.
So please either replace it with the '=' operator...
...or, even better, just use the sys_id of the group that I guess is already present in your "current.variables" object (assuming that your Catalog Item uses a reference variable to select the approval group), so you would not have to deal with the group names at all.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:04 AM - edited 05-19-2025 11:06 AM
Hi @Robert H ,
Thanks for your response.
I have already tried that Replacing 'STARTSWITH' with '=' . When I tested it did not auto populate the development approval group. The field appeared with no value.
The getApprovalGrp function is using 'STARTSWITH' with addquery
How can we construct the approval group name first then pass it in the query. Also tried the below script but the result is same , it did not show any value on that field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:21 AM - edited 05-19-2025 11:22 AM
Hello @1_DipikaD ,
Your screen shots are not showing the full group names.
But I guess the name of the corresponding approval group for the "CTS:APS-GLAD_Mario" development group is "CTS:APS-GLAD-Mario-Approval_Group"?
So in other words, your naming convention is to just add "-Approval_Group" to the name?
If so then there is a typo in your script because it currently adds "_Approval_Group" (with an underscore instead of a hyphen as the first character).
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:55 AM
Hi @Robert H ,
Thanks for finding my mistake. I changed _ to - and it's working now.
One last thing want to ask that can we optimize the code with better quality if possible. Is this code is okay to implement ? Is there any possibility that it could impact adversely ? And how can I check if similar thing is happening with any other CIs ?
Thanks once again.