I have a really strange issue happening on a SAIL form. Basically I have a two l

I have a really strange issue happening on a SAIL form. Basically I have a two local variables which contain any type arrays (X and Y). I then have a 3rd local variable (Z) where I'm trying to place either array X or array Y, based on a local boolean variable which I've set using an expression.

=load(
local!arrayX:ri!input1,
local!arrayY:ri!input2,
local!isBoolean:if(local!integerA=0,true,false),
local!arrayZ:if(local!isBoolean,local!arrayX,local!arrayY)
)

The issue is that array Z is always returning only the first index of either array X or array Y. I want it to return the whole array. I'm not really sure why this is happening. And the strangest part is that if I set local!isBoolean as true or false directly (not using an expression), then array Z returns the entire array that I want.

Anyone seen anything similar? This seems really odd. I've displayed the values of all of my arrays and boolean variable on the form so I know that th...

SAIL issue with boolean expression.doc

OriginalPostID-146293

OriginalPostID-146293

  • ...ey are correct, but still I'm having this issue. I've attached screenprints to show my displays and the exact SAIL code.
  • @michaelm410 Could you please debug the length of arrays X and Y using length function?. Please do let me know if the number of records is equal to length of the arrays.
  • Hi, length() of array X is 5 and length of array Y is 4. Length of array Z is 1. Attached a screenprint with the new displays. This is puzzling.

  • May I please know how the assignment to Z is being done?
  • Its in original post..
    local!arrayZ: if(local!isBoolean,local!arrayX,local!arrayY)
    Here is the exact code snippet:
    local!ruleOutputModifiedFinal:if(local!isStateOrFederalOriginationFailingBoolean,local!ruleOutputModified,ri!VW_RuleOutput_AccountBenefit_new),

    Boolean is set as follows:

    local!isStateOrFederalOriginationFailing:toboolean(if(rule!APN_isEmpty(local!accountOutput),not(local!stateDoODetails.IsStateDoOPassing),if(rule!APN_isEmpty(local!stateDoODetails),tointeger(local!accountOutput.IsOriginationDatePassing)=0,or(tointeger(local!accountOutput.IsOriginationDatePassing)=0,not(local!stateDoODetails.IsStateDoOPassing))))),
    local!isStateOrFederalOriginationFailingBoolean:if(local!isStateOrFederalOriginationFailing,true(),false()),

    However if I just set the boolean as simply true or false as below, then everything works fine. That doesn't solve my problem though because I need the boolean set by the expression:

    local!isStateOrFederalOriginationFailingBoolean:true,
  • Could you please quickly try using the following way of assignment?
    local!isStateOrFederalOriginationFailingBoolean:if(local!isStateOrFederalOriginationFailing[1],ri!VW_RuleOutput_AccountBenefit_new)
  • Please ignore the above snippet and try the below:
    local!isStateOrFederalOriginationFailingBoolean:if(local!isStateOrFederalOriginationFailing[1],local!ruleOutputModified, ri!VW_RuleOutput_AccountBenefit_new)
  • Sorry again, here goes the snippet again:
    local!ruleOutputModifiedFinal:if(local!isStateOrFederalOriginationFailing[1],local!ruleOutputModified, ri!VW_RuleOutput_AccountBenefit_new)
  • Wow, that did it. So strange that you would need to That had me stuck for the last few hours. I can't thank you enough!
  • Strange that you would need to specify the index [1] like that.. with only one boolean value in that variable. Thanks again so much!
  • Great to hear that, If we assess the code we can observe few things as follows:

    1. You are using toboolean() function and it actually returns a boolean array.
    2. fn!if() accepts a single boolean value. (If you use toboolean function even on a single value, the function turns the value into an array. ex. toboolean(true)={true})
    3. You can use a boolean array inside if() function for few scenarios. But prior to using an boolean array inside if() function, try to understand the results obtained by providing an array input, so that you can use it on need basis.

    Try executing the below snippet, the outputs will let you know why you are able to return only one row always:
    load(
    local!a:{1,2,3},
    /*
    Execute each if statement one at a time
    if({true},local!a,null),
    if({true,true},local!a,null),
    if({true,true,true},local!a,null)
    */
    )
    Hope that helps!! :)
  • That makes perfect sense now. Thanks a bunch.
  • One more example to play with it. This tells that the final result for each evaluation of Nested-IFs series is determined by the sequence of associated boolean values within each IF. For example in 2nd evaluation, a sequence of False->True resulted in to "IF2-True", and in 3rd evaluation a sequence of False->False->False is resulted in to "IF3-False". This type of coding style dramatically reduces the dependency of looping functions like apply().

    Check results for this expression:

    if({true, false, false}, "IF1-True",
    if({false, true, false}, "IF2-True",
    if({true, false, false}, "IF3-True",
    "IF3-False"
    )
    )
    )
  • Michael, you are passing an array of booleans as the first argument to if(). When you do this, Appian evaluates the arguments as parallel arrays one index at a time. You should go through your code and make sure you have scalars when you should have scalars. The most common cause of this is not correctly indexing the intended scalar output of a query rule array output.

    Query rules and DataSubset.data are always array so if your intended output is scalar you should wrap the output with index(_,1,null). Fixing the issue at the root cause will prevent downstream errors such as this one.

    On EASi we wrote utility rules that encapsulate all our queries that do this indexing automatically. Using these utility rules consistently has resolved all dimensionality bugs related to queries.

 Discussion posts and replies are publicly visible