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

@ursnani 

Hi, thank you but that still returns false, when it should be true... 

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 That didnt work either. I've added inputs and they work but returning just those values are blank:

var ibRec = inputs.ibRecord;
var ciAcc = inputs.ibCIRecord;
var ibAcc = inputs.ibAccount;
var match = false;
//var ibAcc = '';
var gr = new GlideRecord('sn_install_base_item');
//gr.addQuery('configuration_item',ibRec.configuration_item);
gr.addQuery('configuration_item',ciAcc);
gr.query();
 
outputs.matchedAcc = match;
outputs.ciCom = ciAcc;
outputs.ibAccount = gr.account;
outputs.ibItemAccount = ibAcc;
 
Can you help? 
see attachment
 
Thank you

 

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

 

outputs.matchedacc = match;
outputs.cicom = ciAcc;
outputs.ibaccount = gr.account;
 outputs.ibitemaccount = ibAcc;

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