- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 12:36 AM - edited 03-22-2023 12:37 AM
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 :
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:
Populating the values in catalog form variable :
Please look into this and let me know if require any additional information.
Thanks in Advance,
Raveendra
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 02:43 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 12:49 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 02:27 AM
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 .
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 02:43 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 03:19 AM