Hello everybody, a question about expressions and arrays here. I have

Certified Associate Developer
Hello everybody, a question about expressions and arrays here.

I have a function that takes an array of users.

I have multiple arrays of users that I want to call my function on after applying a merge (ie: I want to call my function on the first element of each array, then the second of each array, etc etc). However the apply function treats the result of a merge as individual arguments instead of a single array object when calling my expression. Wrapping the _ placeholder in the apply function with curly brackets causes a syntax error as does casting the result of the merge to a user list.

Has anyone dealt with this before and if so how did you resolve it?

OriginalPostID-138030

OriginalPostID-138030

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    It still sounds doable to me; it sounds like you're saying your CDT has a mulitple-type integer component (let's call it CDT.UserIDs), and you'll be using an array of such CDTs.

    Your sub-rule, I think, should be doing the check across the ID array of *one* CDT, such as: "apply(rule!checkUserIDActive, ri!thisCDT.UserIDs". (this would be rule "myFunction_sub", ri!thisCDT would be "any type")

    You would then call this from a parent rule, such as this: apply(rule!myFunction_sub, local!arrayOfCDTs)

    If you need to handle an array which will contain various different CDTs, all that really matters is that they either all contain a field named "UserIDs" or at least a set of such property names that you know up-front (like one has "UserIDs" but another one has "LoginIDs"). You would simply use the property() function in myFunction_sub to check which 'IDs' property the CDT member has prior to doing the apply.
Reply
  • 0
    Certified Lead Developer
    It still sounds doable to me; it sounds like you're saying your CDT has a mulitple-type integer component (let's call it CDT.UserIDs), and you'll be using an array of such CDTs.

    Your sub-rule, I think, should be doing the check across the ID array of *one* CDT, such as: "apply(rule!checkUserIDActive, ri!thisCDT.UserIDs". (this would be rule "myFunction_sub", ri!thisCDT would be "any type")

    You would then call this from a parent rule, such as this: apply(rule!myFunction_sub, local!arrayOfCDTs)

    If you need to handle an array which will contain various different CDTs, all that really matters is that they either all contain a field named "UserIDs" or at least a set of such property names that you know up-front (like one has "UserIDs" but another one has "LoginIDs"). You would simply use the property() function in myFunction_sub to check which 'IDs' property the CDT member has prior to doing the apply.
Children
No Data