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
08-28-2023 12:09 AM
client script code:
var ga = new GlideAjax('checkci');
ga.addParam('sysparm_name', 'getCI');
ga.addParam('sysparm_ci', g_form.getValue("field name"));
ga.getXMLWait(updateCI);
}
function updateCI(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.alert('your error message');
return false;
}
Script include:
var checkci = Class.create();
checkci.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCI: function () {
var ci = this.getParameter('sysparm_ci');
var loc = new GlideRecord('your table name');
loc.addQuery('name',ci);
loc.query();
if (loc.next()){
return 'true';
}
}
});
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:50 AM
Hello @Nayan Dhamane
Thanks for the script!
I have tried below but no luck, can you pls check?
Script include.
var checkci = Class.create();
checkci.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCI: function() {
var ciName = this.getParameter('sysparm_ci');
var ciGR = new GlideRecord('cmdb_ci_service_discovered'); // Replace with your actual CI table name
ciGR.addQuery('name', ciName);
ciGR.query();
if (ciGR.next()) {
return 'true';
}
return 'false';
},
type: 'checkci'
});
Onsubmit catalog client script.
function onSubmit() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('checkci');
ga.addParam('sysparm_name', 'getCI');
ga.addParam('sysparm_ci', g_form.getValue("name"));
ga.getXMLWait(updateCI);
function updateCI(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.alert('Already Exists');
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:15 AM
Hello @akin9 ,
Mostly looks good to me just would suggest to add else statemtent to return false.
Please add logs in the script include to debugg it and check where you are facing an issue.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 01:21 AM
Hello @akin9 ,
Unfortunately workflows and flows are triggered from record producers once a record is actually created. So the application service would need to be created first, the workflow/flow would detect that and launch the approval and go from there. If you want a step in between the creation of the record the service catalog would be the best method to accomplish this where you could have a flow run that initiate the approval and once approved create the business service with the data from the request.
This above response is provided by a ServiceNow employee - link
Please use a catalog item for approval instead of record producer.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
