How to call flow designer action from OnSubmit client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 11:02 PM
Hello,
From the Onsubmit Client script, I'm trying to trigger the Flow Designer action. But it is not working.
As you can see from the code below, I'm trying to call a flow designer action, and based on the output, if output is true, I need to send an error message and stop from submitting the request, and if output is false, it can submit the request. However, the code below is not working. Can somebody tell me what went wrong in the code below?
function onSubmit() {
//Type appropriate comment here, and begin script below
(function() {
var userID = g_form.request_For.sys_id;
var denyInternet = 'DENYINTERNETACCESS.LG';
var phising = 'PHISHING.DIA';
var inputs = {};
inputs['user_sys_id'] = userID; // String
inputs['group_name'] = denyInternet, phising; // String
GlideFlow.startAction('x_iem_iam.privisusermemberofgroup', inputs)
.then(function(execution) {
return execution.awaitCompletion();
}, errorResolver)
.then(function(completion) {
var status = completion.status;
// Available Outputs:
var outputs = completion.outputs;
var ismemberofgroup = outputs['ismemberofgroup']; // True/False
if (ismemberofgroup == false) {
return true;
} else {
g_form.addErrorMessage('You are part of the Phishing group which restricts access to internet. Please contact the CyberSecurity team for additional details');
return false;
}
});
function errorResolver(error) {
// Handle errors in error resolver
}
})();
}
Thanks,
JRY
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 11:28 PM
Try once by replacing
inputs['group_name'] = denyInternet, phising; // String
with
inputs['group_name'] = denyInternet + ',' + phising; // String

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 01:53 AM
Hello! How did you solve this? I have a similar requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 02:42 AM
Can you explain your business use-case for this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 04:36 AM
Hello,
Sure! I have a task in which after a record producer is submitted (it creates a demand), I need to take the info from 3 fields: the number of the demand, the requester's company code and the service for which the demand was created.
I was thinking to create an onSubmit catalog client script so when it is submitter, the logic should check the type of service the demand has and if it is one of 4 specific ones (mentioned in my task), then I need to check if a folder with the company code of the requester exists in a SharePoint location.
Here are 2 scenarios:
1. Company code folder doesn't exist -> an error message should be displayed
2. Company code folder exists -> a subfolder with the demand number should be created inside the "initial" folder.
Reading more about the Microsoft SharePoint Scope I've realized that I think it is better to solve the task by:
1. Creating a flow (when demand is inserted with the specific services)
2. Have a scoped action which checks if the folder exists in SharePoint and if so, to created the subfolder.
The only problem with this is that I've used PowerShell scripting and I don't know how get it working.
What do you think will be the better approach to solve the task?
Thank you,
Elena

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 04:59 AM
Now that I think of it, I guess it is better to create a catalog client script because if the folder doesn't exist, I need to display the error message to the user....