About Expression Rule Functions

I have three CDTs that contain some fields with the same value.

I want to create an expression rule that matches them and extracts only the fields that don't overlap.

What function can I use to make it?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Thanks, it looks like you can achieve your requirement that way.
    However, I understand step 1, but I don't understand what kind of expression to write for steps 2 and 3.
    If possible, can you show me a simple code sample?

  • 0
    Certified Lead Developer
    in reply to harukio2297

    Here is the sample example. Not sure exactly how your 3 CDTs looks like, consider this is an example

    a!localVariables(
      local!cdt1: {
        a!map(c1v1: 1, c1v2: 2, c1v3: 3)
      },
      local!cdt2: {
        a!map(c2v1: 1, c2v2: 4, c2v3: 5)
      },
      local!cdt3: {
        a!map(c3v1: 6, c3v2: 2, c3v3: 7)
      },
      
      local!values: tointeger(
        a!forEach(
          items: {local!cdt1, local!cdt2, local!cdt3},
          expression: a!localVariables(
            local!keys: a!keys(fv!item),
            index(fv!item, local!keys, {})
          )
        )
      ),
      local!finalValues: reject(
        fn!isnull,
        tointeger(
          a!forEach(
            items: local!values,
            expression: if(
              length(wherecontains(fv!item, local!values)) > 1,
              null,
              fv!item
            )
          )
        )
      ),
      local!finalValues
    )