Receiving output as [object object] when calling Flow action from client script or ui policy

Nellore Raveend
Tera Contributor

Hi All,

 

I have a Flow designer action and we are getting correct output on Flow designer action. When we using code snippet and called that script in the Ui policy to retrieve that output. we are getting the output as "[object Object],[object Object]" . I am not sure why i am getting this output. I am attaching the screen shots for your reference. Please go through it and let me know what need to be done here.

 

Flow action output :

NelloreRaveend_3-1679470545044.png

 

 

 flow action (code snippet) script:

(function() {

var inputs = {};

inputs['email'] = ; // String

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

var status = completion.status;

// Available Outputs:
var outputs = completion.outputs;
var user = outputs['user']; // Array.Object
});

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

using flow action script in ui policy:

NelloreRaveend_1-1679470264598.png

 

Populating the values in catalog form variable :

NelloreRaveend_2-1679470426564.png

 

Please look into this and let me know if require any additional information.

Thanks in Advance,

Raveendra

1 ACCEPTED SOLUTION

Hi @Nellore Raveend ,

 

The result is right in front of you mate 🙂. You just need to run a for loop on the JSON object and join the elements using "comma" like below :-

 

var result = user.map(function(val) {
  return val.name;
}).join(',');

var finalValue = result;

gs.print(result);

 

Add the above code after line 19 and before 20.

 

Replace the "manager" variable with "finalValue " and the magic should happen.

 

Please mark this as correct as you have your solution now 🙂

 

Regards,
Dhruv

View solution in original post

4 REPLIES 4

Dhruv Chandan
Giga Guru

Hi,

 

Could you use "JSON.stringify()" in the UI Policy like below :-

g_form.setValue('google_di_group_email_manager',JSON.stringify(user)); 

 

As the "user" variable contains an object you'll get an idea about the Key-Value pair of JSON object. The output should be like the one mentioned on the flow screenshot share by you

"{user":["Nellore Raveendra","Jocelyn Leong"]}"

 

If the output is the similar as above then we can do walk to the desired value like below :-

user.user[0] //this should throw some light on the output. 

 

Hope this helps.

 

Regards,
Dhruv

Hi @Dhruv Chandan 

 

Thanks for your quick reply, I made the changes as you suggested but we are not getting the output as expected . Please see the below attached screen shots .

 

NelloreRaveend_0-1679477079642.pngNelloreRaveend_1-1679477107513.png

 

Now we are receiving the output as " "[{\"name\":\"Nellore Raveendra\"},{\"name\":\"Jocelyn Leong\"}]" " . But we need the output like " Nellore Raveendra, Jocelyn Leong " . Could you please suggest what need to be done here.

 

Once again appreciated for your quick response.

Thanks in Advance,

Raveendra

Hi @Nellore Raveend ,

 

The result is right in front of you mate 🙂. You just need to run a for loop on the JSON object and join the elements using "comma" like below :-

 

var result = user.map(function(val) {
  return val.name;
}).join(',');

var finalValue = result;

gs.print(result);

 

Add the above code after line 19 and before 20.

 

Replace the "manager" variable with "finalValue " and the magic should happen.

 

Please mark this as correct as you have your solution now 🙂

 

Regards,
Dhruv

Nellore Raveend
Tera Contributor

Thanks @Dhruv Chandan 

 

Its working as expected now.