Need to pass the Dynamic UserId as Input in terms of string

Rahul84
Tera Contributor

Hello @Ankur Bawiskar / @Brad Bowman  

This is regarding the execution of one of the ACTION in flow designer. I am executing the flow action using Onchange client script

I am successfully able to execute the action via catalog client script but receiving one of the error when passing the Userid as a input for the flow action.

I need to pass this Userid based on the selection of the requested for on the catalog form.

When I am giving the hard coded value for the UserId then client script and action execution is successful but when I am giving the dynamic value of the UserId based on the value in the requested for on the catalog.. then script and action execution is not successful.

 

Please see the below code.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue != '') {
(function() {
g_form.getReference('requested_for', getUser);
var inputs = {};
inputs['userid'] = userID; // string

GlideFlow.startAction('abc', inputs)
.then(function(execution) {
return execution.awaitCompletion();
}, errorResolver)
.then(function(completion) {

var status = completion.status;
// Available Outputs:
var outputs = completion.outputs;
var result = outputs['result']; // String
g_form.addInfoMessage(result);

});

function getUser(caller) {
var userID = caller.user_name;
}

function errorResolver(error) {
// Handle errors in error resolver
}
})();


}

 

Rahul84_0-1674747068886.png

 

5 REPLIES 5

Rahul84
Tera Contributor

@Ankur Bawiskar / @jaheerhattiwale :

Please help to resolve the above error : I am able to get the userid of the requested for user from the catalog form but not able to pass that as an input for the action. In line number 4 reqforUserid is coming as blank.
inputs['userid'] = reqforUserid ; // string
Please help to get the userid of the requested for user and pass that value in line 6 as input

inputs['userid'] = reqforUserid ; // string

 

Please see the below code.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue != '') {
(function() {
var reqforUserid = g_form.getReference('requested_for', getUser);
var inputs = {};
inputs['userid'] = reqforUserid ; // string

GlideFlow.startAction('abc', inputs)
.then(function(execution) {
return execution.awaitCompletion();
}, errorResolver)
.then(function(completion) {

var status = completion.status;
// Available Outputs:
var outputs = completion.outputs;
var result = outputs['result']; // String
g_form.addInfoMessage(result);

});

function getUser(caller) {
var userID = caller.user_name;

return userID;
}

function errorResolver(error) {
// Handle errors in error resolver
}
})();


}