How to join 2 of the same CDTs/DictionaryI

Hi, 

I have multiple CDTs in which I want to join each element with a common seperator.

For example,

CDT1: {field1: "Test", field2: "Something", field3: "AnotherThing"},

CDT2: {field1: "Test2", field2: "Something2", field3: "AnotherThing2"},

CDT3: {field1: "Test3", field2: "Something3", field3: "AnotherThing3"},

I wish to join these three into a single cdt like this:

cdtFinal: {

field1: "Test;Test2;Test3",

field2:"Something;Something2;Something3",

field3: "AnotherThing;AnotherThing2;AnotherThing3"

}

Is there any way I can do this? Another note is, I do not know how many cdts I will be joining, so I would have a list of the same type of cdts but with an unknown length. So I would like to be able to do this through a loop if possible. Let me know if you have anymore questions. 

Thanks for the help!

Ian

  Discussion posts and replies are publicly visible

Parents
  • Hi 

    Try something like this 

    load(
      
     local!cdt1: {SOURCE_NAME: "Test", DESIGN_TYPE: "Something", PHASE: "AnotherThing"},
    
    local!cdt2: {SOURCE_NAME: "Test2", DESIGN_TYPE: "Something2", PHASE: "AnotherThing2"},
    
    local!cdt3: {SOURCE_NAME: "Test3", DESIGN_TYPE: "Something3", PHASE: "AnotherThing3"},
    
    local!finalCdt:{local!cdt1,local!cdt2,local!cdt3},
    
    
    
    'type!{http://www.test.com/test/}CM_CLAIM_TYPE'(
      SOURCE_NAME: joinarray({local!finalCdt.SOURCE_NAME},";"),
      DESIGN_TYPE:joinarray({local!finalCdt.DESIGN_TYPE},";"),
      PHASE:joinarray({local!finalCdt.PHASE},";")
    )
    
    )

    cdt1,cdt2,cdt3 is of type CM_CLAIM_TYPE. Define a rule input of "finalCdt" and you can pass as many number of cdts to that rule input

    Let me know if you have any queries.

Reply
  • Hi 

    Try something like this 

    load(
      
     local!cdt1: {SOURCE_NAME: "Test", DESIGN_TYPE: "Something", PHASE: "AnotherThing"},
    
    local!cdt2: {SOURCE_NAME: "Test2", DESIGN_TYPE: "Something2", PHASE: "AnotherThing2"},
    
    local!cdt3: {SOURCE_NAME: "Test3", DESIGN_TYPE: "Something3", PHASE: "AnotherThing3"},
    
    local!finalCdt:{local!cdt1,local!cdt2,local!cdt3},
    
    
    
    'type!{http://www.test.com/test/}CM_CLAIM_TYPE'(
      SOURCE_NAME: joinarray({local!finalCdt.SOURCE_NAME},";"),
      DESIGN_TYPE:joinarray({local!finalCdt.DESIGN_TYPE},";"),
      PHASE:joinarray({local!finalCdt.PHASE},";")
    )
    
    )

    cdt1,cdt2,cdt3 is of type CM_CLAIM_TYPE. Define a rule input of "finalCdt" and you can pass as many number of cdts to that rule input

    Let me know if you have any queries.

Children