How to compare unknown values

Su522
Kilo Sage

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,

14 REPLIES 14

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);

 

Hi @Su522 

 

Please mark my answer as Correct of it resolves your issue.

 

Thanks.

Hi @Su522 

 

Please mark my answer as correct if it resolves your issue.

 

Thanks.

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.

@ursnani 

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!