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
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"
id: 1 topic: "SimpleTopic1" subTopicList: "item3"
id: 2 topic: "SimpleTopic2" subTopicList: "item4"
id: 2 topic: "SimpleTopic2" subTopicList: "item5"
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'"
Here's another example with nested cdt's
load( local!subCdt: {it1: "item1", it2: "item2", it3: "item3"}, local!topicCdt: { {id: 1, topic: "SimpleTopic1", subTopicList: {a: local!subCdt, b: local!subCdt, c: local!subCdt}} }, expandcdt( cdt: local!topicCdt, expandField: "subTopicList" ))
local!subCdt: {it1: "item1", it2: "item2", it3: "item3"},
{id: 1, topic: "SimpleTopic1", subTopicList: {a: local!subCdt, b: local!subCdt, c: local!subCdt}}
Output:
List of Dictionary: 1 item Dictionary
id: 1 topic: "SimpleTopic1"
nest.a: Dictionary
it1: "item1"
it2: "item2"
it3: "item3"
nest.b: Dictionary
nest.c: Dictionary