- 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
10-27-2022 03:58 AM
Hi John,
Thanks for the solution. What we were looking for, we got that from the regular expression you have posted. It's giving us the findings as we want. Thanks again.
In case of any other doubts, will mention that under the same thread.
Regards,
Sudhangshu