server side script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 12:38 PM
1) record a query with some specifications and
2) open that form(I mean record).
3) I need to write the server side script for getting the record's sys_id which I have opened in step 2 and then query few actions
how to obtain record's sys_id through server side script in ATF ?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 01:04 PM
Hey @admin11345_ ,
Please use below code and make needful changes in it,
var tableName = 'your_table_name'; // Replace with the actual table name
var conditionField = 'field_name'; // Optional, add field name if needed
var conditionValue = 'field_value'; // Optional, add field value if needed
var gr = new GlideRecord(tableName);
if (conditionField) {
gr.addQuery(conditionField, conditionValue);
}
gr.query();
if (gr.next()) {
var sysId = gr.getValue('sys_id'); // Get the sys_id directly
gs.info('Record sys_id: ' + sysId);
} else {
gs.info('No matching records found.');
}
gr.close();
Regards,
Kamlesh