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
2710 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
Matthew Kornfield
Appian Employee
over 9 years ago
Chris, it seems that you cannot pass a dynamic number of parameters into this function since it expects the parameters to be comma separated arrays of strings and not lists of variant i.e. ncolumn(string[] column_headers, string[] column, string[] column2...) for up to ten columns.
There are two workarounds I see possible
1) Make your own expression rule to dynamically generate the HTML (a bit clunky at first but may scale better)
2) Based off the length of the result of the apply function, create a set of if conditionals and pass the parameters using the index function, i.e.
local!columnArray: apply(rule!test_getData(data:local!data,field_),local!fields),
if( length(local!columnArray) = 1,
ncolumn(local!columns,index(local!columnArray,1,{}),
if(length(local!columnArray = 2),
ncolumn(local!columns,index(local!columnArray,1,{}),index(local!columnArray,2,{})),
...
etc.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Matthew Kornfield
Appian Employee
over 9 years ago
Chris, it seems that you cannot pass a dynamic number of parameters into this function since it expects the parameters to be comma separated arrays of strings and not lists of variant i.e. ncolumn(string[] column_headers, string[] column, string[] column2...) for up to ten columns.
There are two workarounds I see possible
1) Make your own expression rule to dynamically generate the HTML (a bit clunky at first but may scale better)
2) Based off the length of the result of the apply function, create a set of if conditionals and pass the parameters using the index function, i.e.
local!columnArray: apply(rule!test_getData(data:local!data,field_),local!fields),
if( length(local!columnArray) = 1,
ncolumn(local!columns,index(local!columnArray,1,{}),
if(length(local!columnArray = 2),
ncolumn(local!columns,index(local!columnArray,1,{}),index(local!columnArray,2,{})),
...
etc.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data