Record producer approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 01:11 AM
Hello Experts,
We have created a record producer to create a new application service.
As of now If user submit a request new application service will create.
we have created a workflow but not working , dont know how to achieve it.
Table - "cmdb_ci_service_discovered"
Approval group - "SN_New_Management"
Requirment
1. we want to add Group approvals on that request after approval only new record needs to be created.
kindly support to achieve!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 03:43 AM
try this
// Check if the current record was submitted from a record producer (catalog item)
var recordProducerGR = new GlideRecord('sc_item_produced_record');
recordProducerGR.addQuery('task', current.sys_id);
recordProducerGR.query();
// Check if there is a matching record producer for the current record
if (recordProducerGR.hasNext()) {
// Example: Trigger an approval
var approval = new GlideRecord('sysapproval_approver');
approval.initialize();
approval.sysapproval = current.sys_id;
approval.source_table = recordProducerGR.task.sys_class_name;
approval.document_id = current.sys_id;
approval.approver = gs.getUserID(); // Assign the current user as the approver
approval.state = 'requested'; // Set the initial state to 'requested'
approval.insert();
// Log the message
gs.info('Approval requested for record: ' + current.number);
} else {
// Example: End the workflow
// Log the message
gs.info('Workflow ended for record: ' + current.number);
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 04:05 AM
Hi @Ankur Bawiskar ,
Sry ,Still no luck
Record is created after submitting the req.
I have added two users on the approval activity in the workflow.FYI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 04:26 AM
did you add some logs and debug?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 04:42 AM
Hi @Ankur Bawiskar ,
No i have not done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 05:00 AM
please do this and share the analysis
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
