How to insert values directly to table after approving the request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 12:48 AM
Hi,
can some one guide me how to approach below scenario:
1) after submitting the catalog form
2) approval should go to one assignment group
3)once RITM gets approves, all the records(here we are using multi row variable sets) should directly create or update in one custom table
4) before creating the record we need to check if we have same combination of data exists in table if exists it should update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 01:20 AM - edited 11-20-2023 01:24 AM
Hi @MounikaS ,
You can workflow on sc_req_Item table and in Use the Set Values activity to set the assignment group to which ever group you like.
In run script activity paste below script and change script depends on your requirement
var stateinfo=current.variables.approval;
if(stateinfo=='approved'){
var TargRec = current.variables.target_record;//as per the varible on item you want to insert or update record
var UndRec = new GlideRecord('custom_table'); // Replace 'custom_table' with the actual table name
if (TargRec == 'abc') {//change as per your need
// Create a new record
UndRec.initialize();
UndRec.short_description = current.variables.shrt_desc; // Field 1
UndRec.description = current.variables.desc; // Field 2
// Set other fields as needed
var newRecordSysId = UndRec.insert();
gs.print('New record created with Sys ID: ' + newRecordSysId);
} else if (TargRec == 'bca') {/change as per your need
// Update an existing record
if (UndRec.next()) {
UndRec.short_description = current.variables.shrt_desc; // Field 1
UndRec.description = current.variables.desc; // Field 2
// Update other fields as needed
UndRec.update();
gs.print('Existing record updated with Sys ID: ' + UndRec.getUniqueValue());
}
}
Please mark it as solution proposed and helpful if it serves your purpose.
Thanks,
Anand