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-23-2024 10:09 AM
You have use Break statement like below and it should work, If that also didnt work then try changing the Output type of "matchedacc" to "String" instead of "True/False"
(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 = false;
break;
}
}
outputs.matchedacc = match;
outputs.cicom = ciAcc;
outputs.ibaccount = gr.account;
outputs.ibitemaccount = ibAcc;
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 06:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 08:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 01:18 PM - edited ‎04-22-2024 01:20 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-22-2024 12:28 PM
I fixed the code like you suggested- thank you
But it is still not working
Is there a better way to do this?
I need to return values to a Flow so I can run IF statements in the Flow (If true, else if false)
Please see the attachments
Thank you again for your help!