How to compare unknown values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 05:42 AM
Using a FD Flow, how can I compare unknown values?
Use Case:
If there are multiple install base items attached to the CI, and all the companies on all the install base items are the Same {
do something
}
If there are multiple install base items attached to the CI, and all the companies on all the install base items are Not the same{
do something different
}
Help is greatly appreciated!
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 01:08 PM
Hi, thank you but that still returns false, when it should be true...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 01:23 PM
Hi @Su522
There are some errors in your code and I corrected and it worked. Use the below code
var ibRec = inputs.ibRecord; var match = true; var ibAcc = ''; var gr = new GlideRecord('sn_install_base_item'); gr.addQuery('configuration_item',ibRec.configuration_item); // hope ibRecord.configuration_item you are getting the sysid of CI gr.query(); while (gr.next()) { if (gs.nil(ibAcc)) { ibAcc = gr.account; //Sets Account value of 1st record from the List for the 1st time } if (ibAcc != gr.account) { match = false; break; } }
Please mark it as Correct if it resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 08:34 AM
@ursnani That didnt work either. I've added inputs and they work but returning just those values are blank:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 08:41 AM - edited ‎04-23-2024 08:43 AM
Hi @Su522
They are empty because you are using the label of the Outputs, use the Name instead, you will see the outputs like below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 10:00 AM
@ursnani Thank you! Yes that helped- I am getting output now.
The results are not working as expected though- false works, true does not.
Can you please help?
Here is the code I have now (and see attached):
(function execute(inputs, outputs) {
var ibRec = inputs.ibRecord;
var ciAcc = inputs.ibCIRecord;
var ibAcc = inputs.ibAccount;
var match = true;
//var ibAcc = '';
var gr = new GlideRecord('sn_install_base_item');
gr.addQuery('configuration_item',ciAcc);
gr.query();
while(gr.next()){
if(gr.nil(gr.account)){
ibAcc == gr.account; //Sets Account value of 1st record from the List for the 1st time
}
if(ibAcc == gr.account){ //For the 1st time this condition will be true & from next time it will compare with the 1st record account from above
match = true;
ciAcc = gr.account;
}
else{
match = false;
ciAcc = 'Boxeo USA';
}
}
outputs.matchedacc = match;
outputs.cicom = ciAcc;
outputs.ibaccount = gr.account;
outputs.ibitemaccount = ibAcc;
})(inputs, outputs);