How to call flow designer action from OnSubmit client Script

JRY
Mega Guru

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

 

11 REPLIES 11

Muhammad Khan
Mega Sage
Mega Sage

Try once by replacing 

 

inputs['group_name'] = denyInternet, phising; // String

 

with

 

inputs['group_name'] = denyInternet + ',' + phising; // String

Elena Pomana
Tera Guru

Hello! How did you solve this? I have a similar requirement

@Elena Pomana 

Can you explain your business use-case  for this?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

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....