Code not behaving same when I used localVariable with fixed number, expressionrule

Hi Experts,

Below Block-A code line is working fine, whereas Block-B is not working even though "tointeger(index(rule!AB_getReviewKey(key: 100),"reviewkey",null()))" is returned 2.

Any comments please.

----------------------- Block-A -------------------------

a!localVariables(
local!reviewkey: 2,
local!excludeKeys: if(
local!reviewkey = 2,
{ 1, 3, 4},
if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })
),
local!excludeKeys
)

----------------------- Block-B -------------------------

a!localVariables(
local!reviewkey: tointeger(index(rule!AB_getReviewKey(key: 100),"reviewkey",null())),
local!excludeKeys: if(
local!reviewkey = 2,
{ 1, 3, 4},
if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })
),
local!excludeKeys
)

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Lead Developer
    in reply to swapnar6405

    You should amend rule!AB_getReviewKey to return a single item if the expected output is always single.  If it isn't, then you should use square brackets or index() when calling it in order to get a single value into your local variable.

    Also, when posting code snippets (even short ones like this) please use a Code Box and make sure to paste indented code - it makes it much easier to read / mentally process for us.

    a!localVariables(
      local!reviewkey: tointeger(
        index(  /* use index() to get an index (1) */
          property(rule!AB_getReviewKey(key: 100), "reviewkey", null()), /* use property() to get a property (.reviewKey) */
          1,
          null()
        )
      ),
      local!excludeKeys: if(
        local!reviewkey = 2,
        { 1, 3, 4},
        if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })
      ),
      
      local!excludeKeys
    )

Children