Trung
Kilo Guru

In the script if you want query a field from base table that exist in table (extend) but not in base table. Example: we query caller_id from task table (we known that field caller_id exist in incident table).

so we can use script:

var gr = new GlideRecord("task");
gr.addQuery("ref_incident.caller_id", "7fe2dd84dbc56410ab46f9b7f49619a9");
gr.query();
if (gr.next()) {
    gs.print(gr.number)
}

  and the secret for this script above is "ref_[table name].[field name]", and 'table name' is table be extended from base table, and for the example is incident, 'field name' the name of field only exist in extend table.

And also you can get the data from field a field from base table that exist in table (extend) but not in base table with syntax "ref_[table name].[field name]". Example: I want to get caller_id from GlideRecord that query from task => "gr.ref_incident.caller_id".

And you can apply it to condition when query in table. just append the encoded query to sysparm_query

Comments
Marek Remi_
Tera Expert

Thanks Trung, just used your post to add custom fields to sysevent_email_action.recipient_fields . They were not showing in "Users/Groups in fields" list so I had to use a script to add them. 

Version history
Last update:
‎06-13-2021 09:00 PM
Updated by: