Hello everyone,I am trying to use expandcdt() function

Hi,

I am trying to expand my CDT using expandcdt() function. It is given that the expand field parameter accepts input in "???function.expandcdt.param.expandField.description???" format. I am unable to figure out the input.

My CDT structure looks something like below,

   empId: ""

  empDepartment: Department(nested CDT)

       dId:

       dName: ""

   empGender: Gender(nested CDT)

       gId:

       gName: ""

   lastName: ""

   firstName: ""

Could you please help me with an example.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi,

    The expandcdt smart service function documentation is misleading. It is not documented well.

    Here's an example of how you can use this function:

    load(

     local!topicCdt:  {

                         {id: 1, topic: "SimpleTopic1", subTopicList: {"item1", "item2", "item3"}},

                         {id: 2, topic: "SimpleTopic2", subTopicList: {"item4", "item5", "item6"}}

                      },

       expandcdt(

       cdt: local!topicCdt,

       expandField: "subTopicList"

     )

    )

    And the output would be :

    List of Dictionary: 6 items Dictionary

    id: 1 topic: "SimpleTopic1" subTopicList: "item1"

    Dictionary

    id: 1 topic: "SimpleTopic1" subTopicList: "item2"

    Dictionary

    id: 1 topic: "SimpleTopic1" subTopicList: "item3"

    Dictionary

    id: 2 topic: "SimpleTopic2" subTopicList: "item4"

    Dictionary

    id: 2 topic: "SimpleTopic2" subTopicList: "item5"

    Dictionary

    id: 2 topic: "SimpleTopic2" subTopicList: "item6"

     

    Hope this answers your question. Good luck!

     

    Regards,

    Sunil Zacharia

  • Hi Sunil,

    If given in your mentioned format it is working.If i tried taking my cdt as a rule input as below,

    expandcdt(
    cdt:ri!employee,
    expandField:"empGender"
    )

    I am getting the error-"Expression evaluation error at function 'expandcdt'"

  • 0
    Certified Lead Developer
    in reply to soujanyac0001
    expandcdt works only on list fields. What's the structure of your employee cdt and what type is empGender?
Reply Children