- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:47 AM
Hi Developer,
I'm creating a record in a table via the client script using the created record data method, and I need the sys_id of the newly created record, is there a way to get it in the client script?
this is my code in client script:
function handler({api, event, helpers, imports}) {
let objSelectedRecords = api.state.jsonSelectedRecords; //JSON.parse(api.state.jsonSelectedRecords);
let objFormValues = JSON.parse(api.state.jsonFormValue);
if (objFormValues.bulk_case) {
let tableBulkCase = 'x_nttdi_gosign_con_gosign_bulk_case';
let fieldsBulkCase = '';
fieldsBulkCase += `source_table=${objSelectedRecords.table}^`;
fieldsBulkCase += `source_record=${objSelectedRecords.sys_ids[0]}^`;
fieldsBulkCase += `case_source=${objSelectedRecords.sys_id_source}^`;
for (const propertyBulk in objFormValues) {
fieldsBulkCase += `${propertyBulk}=${objFormValues[propertyBulk].value}^`;
}
fieldsBulkCase = fieldsBulkCase.slice(0, -1);
api.data.create_record_bulk_case.execute({
table: tableBulkCase,
templateFields: fieldsBulkCase,
useSetDisplayValue: false
});
//I want to get the sys_id of created record
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:55 AM
I used this approach to get the sys_id: https://www.servicenow.com/community/next-experience-articles/how-to-create-a-record-and-immediately...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:54 AM
Hi @ersureshbe ,
I've managed to get sysID from this path of Glide Record data resource:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:40 AM
Hi, Is that code working? If not try with glideAjax to test that.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:42 AM