get List of Item from CDT

Hello!

please may I know if there is anyway to get the list of items in a CDT?

For example, if there are 3 items namely the "id", "customerId" and "contacts" within the CDT, how could I get a list of Text containing the name of the items above (i.e. something like an array:{"id","customerId", "contacts"})?

Shall I do a queryrule or something?

Thanks for your time

OriginalPostID-238884



  Discussion posts and replies are publicly visible

Parents
  • Do you want only the attributes of the CDT Type? If you want the attribute fields as well as the values, I would suggest another approach - use the a!toJson function.
    Eg: If local!cdt is a CDT with data like this: {id: 1, customerId:23, contacts: {"contact1", "contact2"}} etc, you can just use a!toJson(local!cdt).

    If you just want the attributes of a CDT - there is another solution:
    Assume that the type of your CDT is Customer. Then you can find the attributes in the Customer CDT as follows:
    fn!split(fn!stripwith(fn!tostring(type!Customer()) , "=[] "),",")

    It will return all the fields in the CDT as an array
Reply
  • Do you want only the attributes of the CDT Type? If you want the attribute fields as well as the values, I would suggest another approach - use the a!toJson function.
    Eg: If local!cdt is a CDT with data like this: {id: 1, customerId:23, contacts: {"contact1", "contact2"}} etc, you can just use a!toJson(local!cdt).

    If you just want the attributes of a CDT - there is another solution:
    Assume that the type of your CDT is Customer. Then you can find the attributes in the Customer CDT as follows:
    fn!split(fn!stripwith(fn!tostring(type!Customer()) , "=[] "),",")

    It will return all the fields in the CDT as an array
Children
No Data