Need to update the location based on the Short description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 04:24 AM
we have short description like [S1871R02] and we need to update the 1871 into the location field in incident.
we wrote script already but when we try to update the incident location is not matching with short description.
Business Rule script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 03:51 AM
I think you have found out the reason why it is not finding the right record. the location name extracted from short decsription is M0111 but the complete name on location field is different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 04:58 AM
The Name is not exactly "M0516" so the GlideRecord query is not finding a match. If you're saying now that your Location naming convention will always START WITH M plus the numeric value, not EQUAL it, then the addQuery line to find this record would be
locRef.addQuery("name", "STARTSWITH", numericPart);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 06:51 AM
Hi @Brad Bowman ,
Thank you for helping on this
we have given the this script now its working
locRef.addQuery("name", 'CONTAINS', numericPart);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 04:57 AM
Hi,
var locRef = new GlideRecord("cmn_location");
locRef.addQuery("name", 'M' + numericPart);
locRef.query();
Can you log getRowCount over here.
Then after your if (locRef.next()) {
Log the sys_id returned : locRef.sys_id
Use this sys_id in your query filter on cmn_location to see if the right sys_id is being returned and then set it on location field on incident form .
Still if it is not updating in that case you need to check any BR's if updation of location field is being aborted.