- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 03:03 AM
Hi all,
I want to create a custom check on the 'Instance Scan' module, where we have got the recommendation as follows:
" Reference fields already store the Sys ID of the referenced record. Using gr.fieldname.sys_id is a dot-walk and instructs the platform to perform another query only to return the same value. This is an unnecessary overhead. Call the field as normal. For example, gr.getValue('reference_field'). "
We somehow want to capture all the records in which the script field has this expression-
<glideRecord object>.<fieldname>.sys_id.
We have tried using the following regular expression, but somehow it's not showing up any findings.
"/[a-zA-Z]\.[a-zA-Z]\.sys\/_id/"
Any kind of help would be appreciated.
Thanks & Regards,
Sudhangshu Das
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:59 AM
Improvement to the regex (though this is still a naive solution)
/\b[a-zA-Z_$][a-zA-Z\d_$]*\s*\.(?:\s*\w+\s*\.)+\s*sys_id\b/
Though even this could be missed by some weird coding practices...
var someValue = gr /* Some comments in the middle of my expression*/
.some_ref /* this is the blah blah record */
.some_column /* some explaination of the value we are getting*/
maybe I'm being overly pedantic but I'd look at AST, feels like the juice is worth the squeeze for someone to figure out the AST parser method to catch these as it would be a commonly desired check
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 06:38 PM
@sudhangshu, Yes it makes sense. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 04:00 AM
Hi Vamsi,
We tried the above, and as I said previously, we need to capture records where there is multiple dot walking happening. Single dot-walk to the SysID is acceptable.
So for that we have found the solution. The regular expression given by @John Dewhurst in the thread below is working as expected.
Thanks for your time.
Regards,
Sudhangshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 04:06 AM
Instance Scan findings will provide you the original record that has a problem. Better you can go into the actual record and rectify the issue and do a rescan of the check that identifies the record.
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:41 AM
/\b\w+\.\w+\.sys_id\b/
would be a naive way to do it, variable names can actually include dollars and numbers as well so would have to cater for that, then there could be whitespace so it might actually look more like...
/\b([a-zA-Z_$][a-zA-Z\d_$]*)\s*\.\s*\w+\s*\.\s*sys_id\b/
Though this would catch comments and the like as well, you will need to use AST functionality for a good test that won't return false positives, I'm not an AST expert though yet so someone else would need to help with that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:59 AM
Improvement to the regex (though this is still a naive solution)
/\b[a-zA-Z_$][a-zA-Z\d_$]*\s*\.(?:\s*\w+\s*\.)+\s*sys_id\b/
Though even this could be missed by some weird coding practices...
var someValue = gr /* Some comments in the middle of my expression*/
.some_ref /* this is the blah blah record */
.some_column /* some explaination of the value we are getting*/
maybe I'm being overly pedantic but I'd look at AST, feels like the juice is worth the squeeze for someone to figure out the AST parser method to catch these as it would be a commonly desired check