Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
4 replies
Subscribers
8 subscribers
Views
2711 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Today's logic problem: I'm looking to dynamically generate an ncolumnta
Chris
over 9 years ago
Today's logic problem: I'm looking to dynamically generate an ncolumntable() for use in HTML documentation. For example, we collect task history in SQL and like to attach this in HTML emails and audit documents - each process may utilize a different set of history information, so I would like to build this table dynamically based on column header and field inputs, but can't seem to get the code working correctly. The idea is something like this:
load(
local!columns: {"Task","Owner"},
local!fields: {"task","owner"},
local!data: {{task: "Approval",owner: "Jim"},{task: "Submit",owner: "Steve"},{task: "Review",owner: "Joe"}},
ncolumntable(
local!columns,
apply(rule!test_getData(data: local!data, field: _),
local!fields
)
)
)
Where rule!test_getData() is defined simply as (data - Any Type, field - text):
index(ri!data,ri!field,null)
Since ncolumntable() is expecting a different array for each column, the...
OriginalPostID-195148
OriginalPostID-195148
Discussion posts and replies are publicly visible
Parents
0
Chris
over 9 years ago
Thanks Matthew. I ended up with a variation of #2, this seems to work for a dynamic amount of columns:
load(
local!columns: {"Task","Owner"},
local!fields: {"task","owner"},
local!data: {{task: "Approval",owner: "Jim"},{task: "Submit",owner: "Steve"},{task: "Review",owner: "Joe"}},
local!columnArray: apply(rule!test_getData(data:local!data,field: _),local!fields),
local!items: length(local!columnArray),
ncolumntable(
columnHeaders: local!columns,
column1: apply(fn!tostring,index(local!columnArray,1,null)),
column2: if(local!items>1,apply(fn!tostring,index(local!columnArray,2,null)),{}),
column3: if(local!items>2,apply(fn!tostring,index(local!columnArray,3,null)),{}),
column4: if(local!items>3,apply(fn!tostring,index(local!columnArray,4,null)),{}),
column5: if(local!items>4,apply(fn!tostring,index(local!columnArray,5,null)),{}),
column6: if(local!items>5,apply(fn!tostring,index(local!columnArray,6,null)),{}),
column7: if(local!items>6,apply(fn!tostring,index(local!columnArray,7,null)),{}),
column8: if(local!items>7,apply(fn!tostring,index(local!columnArray,8,null)),{}),
column9: if(local!items>8,apply(fn!tostring,index(local!columnArray,9,null)),{}),
column10: if(local!items>9,apply(fn!tostring,index(local!columnArray,10,null)),{})
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Chris
over 9 years ago
Thanks Matthew. I ended up with a variation of #2, this seems to work for a dynamic amount of columns:
load(
local!columns: {"Task","Owner"},
local!fields: {"task","owner"},
local!data: {{task: "Approval",owner: "Jim"},{task: "Submit",owner: "Steve"},{task: "Review",owner: "Joe"}},
local!columnArray: apply(rule!test_getData(data:local!data,field: _),local!fields),
local!items: length(local!columnArray),
ncolumntable(
columnHeaders: local!columns,
column1: apply(fn!tostring,index(local!columnArray,1,null)),
column2: if(local!items>1,apply(fn!tostring,index(local!columnArray,2,null)),{}),
column3: if(local!items>2,apply(fn!tostring,index(local!columnArray,3,null)),{}),
column4: if(local!items>3,apply(fn!tostring,index(local!columnArray,4,null)),{}),
column5: if(local!items>4,apply(fn!tostring,index(local!columnArray,5,null)),{}),
column6: if(local!items>5,apply(fn!tostring,index(local!columnArray,6,null)),{}),
column7: if(local!items>6,apply(fn!tostring,index(local!columnArray,7,null)),{}),
column8: if(local!items>7,apply(fn!tostring,index(local!columnArray,8,null)),{}),
column9: if(local!items>8,apply(fn!tostring,index(local!columnArray,9,null)),{}),
column10: if(local!items>9,apply(fn!tostring,index(local!columnArray,10,null)),{})
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data