- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 06:07 AM
Hi All,
I am working on the reclamation workflow . I have to pass four input variables and triggered the workflow from script include. The four input variables are 1. Domain Controller, User Name, AD GroupName and Shared Domain .
I am able to get all the input using Glide Query from different table . My only issue is how to send all the inputs to workflow inputs (Remove AD Group). Please find the script include which I have written for the above mentioned logic.
Script Include:
var RemoveAD = Class.create();
RemoveAD.prototype = {
initialize: function() {},
type: 'RemoveAD'
};
RemoveAD.revokeAD = function(softwareGr) {
var UserAdDomain;
var ADDomain;
var ADUserName;
var domainController = 'wmservice.corpnet1.com';
var gr_install = new GlideRecord("cmdb_sam_sw_install");
gr_install.addQuery('sys_id', softwareGr);
gr_install.query();
//gr_install.get('03f31264dbc658942973d844ca96198b');
if (gr_install.next()) {
var discoModel = gr_install.getValue('discovery_model');
//gs.print('Discovery Model:' +discoModel );
var softwaremodelids = SAMPremiumUtils.getSoftwareModelsFromDiscModel(discoModel);
//gs.print('SW Model IDs:' + softwaremodelids);
var gr = new GlideRecord('sn_client_sf_dist_application');
gr.addEncodedQuery('modelIN' + softwaremodelids);
gr.query();
if (gr.next()) {
// AD Domain, User AD Domain , AD UserName & Domain Controller(Pending )
ADDomain = gr.getValue('display_name');
UserAdDomain = gr_install.installed_on.assigned_to.u_ad_domain;
ADUserName = gr_install.installed_on.assigned_to.user_name;
gs.print(ADDomain);
}
// Condition to be applied for Domain Controller
}
//calling the workflow GSK AD - Remove User from Group
// Have to get the workflow input to pass & triggered the workflow
// Not sure about the syntax how to pass the input:ADDomain, UserAdDomain, ADUserName and domainController
var wfVars = {};
wfVars.
RemoveAD.startWorkflow("GSK AD - Remove User from Group", softwareGr, "", wfVars);
};
RemoveAD.startWorkflow = function(wfName, record, operation, wfVars) {
var wf = new global.Workflow();
var workflowId = wf.getWorkflowFromName(wfName);
if (gs.nil(workflowId)) {
gs.info('workflow: ' + wfName + ' not found');
return;
}
var contextId = wf.startFlow(workflowId, record, operation, wfVars);
return contextId;
};
Please help me in this regard.
Regards,
Aquib
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 08:37 PM
Try to run once and verify
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 08:36 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 07:47 AM
Hi Ankur,
I tried to run the test . I am getting below error in Run Server Script when triggering the workflow.
Run orchestration workflow(638b481d1b27cd50edcf7116464bcb41): org.mozilla.javascript.WrappedException: Wrapped java.lang.SecurityException: Method returned an object of type ComparisonCondition which is not allowed in scope sn_samp (<refname>; line 17)
Please recommend any troubleshooting steps as I am new to workflow.
Here is Run Script Activity :
//call Revocation workflow
//Check if com.snc.orchestration.client_sf_distribution plugin exist and activated
if(!gs.nil(current.user_subscription))
{
if(GlidePluginManager.isActive("com.sn_sam_saas")) {
try {
workflow.scratchpad.isReclamationAsync = false;
var responseObj = new global.SAMSaasIntegrationUtils().reclaimSubscription(current.user_subscription);
if (responseObj && responseObj.status === 'failure') {
current.reclamation_error = responseObj.error_message;
gs.error('Error during reclamation: ' + responseObj.error_message);
}
if(!gs.nil(responseObj)){
current.custom_properties.reclaim_response_payload = JSON.stringify(responseObj);
workflow.scratchpad.isReclamationAsync = responseObj.isReclamationAsync;
}
}
catch(err) {
if (typeof err === 'string') {
current.reclamation_error = err;
gs.error('Error during reclamation: ' + err);
}
else if (typeof err === 'object') {
current.reclamation_error = err.message ? err.message : JSON.stringify(err);
gs.error('Error during reclamation: ' + JSON.stringify(err));
}
}
} else {
gs.error("SAM SaaS License Management Integrations plugin is inactive, hence unable to reclaim subscription ");
}
}
else if(!gs.nil(current.sap_system_user)){
if(GlidePluginManager.isActive("com.sn_samp_sap")) {
//sap specific code if any for future. Without this condtion extra log is getting printed for sap.
}
}
else if (GlidePluginManager.isActive("com.snc.orchestration.client_sf_distribution")){
//plugin is active, get install record
var gr_install = new GlideRecord("cmdb_sam_sw_install");
if (gr_install.get(current.software_install) && gr_install.installed_on) {
if(gs.nil(gr_install.cloud_provider)){
var provider = sn_client_sf_dist.CSDUtil.getSoftwareManagementProvider(gr_install.installed_on);
if (provider) {
//sn_client_sf_dist.CSDUtil.revokeSoftware(gr_install);// This line is commented.
var removeADInclude = new global.RemoveAD.revokeAD(gr_install); Added the script include as per the modification.
} else {
gs.error("Can't reclaim. Software installation does not have a provider");
}
} else {
gs.info('This is not an on-premise device, hence skipping un-installation of software');
}
} else {
gs.error("Can't reclaim. Software installation does not exist or is invalid");
}
} else
gs.error("Client Software Distribution plugin is inactive, hence unable to reclaim software");
Note: Workflow is in Software Professional Scope and I have added the script include : var removeADInclude = new global.RemoveAD.revokeAD(gr_install); which is in Global Scope . I guess this is the issue which is causing ??
Please help me in this regard.
Regards,
Aquib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 02:42 AM
The Issue has been resolved . Issue with line:var removeADInclude = new global.RemoveAD.revokeAD(gr_install);
when updated to global.RemoveAD.revokeAD(gr_install); it worked . The workflow is getting updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 07:32 AM
I noticed you used SAMPremiumUtils, can you share more information on this script include?