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
10 replies
Subscribers
6 subscribers
Views
4699 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
Is it possible to output multiple document links with a!documentDownloadLink, wi
Chris
over 9 years ago
Is it possible to output multiple document links with a!documentDownloadLink, within a!linkField, that display on the same line? Or any other solution for document links would work as well.. Similar to how joinarray(links,", ") would separate an array into a comma delmited output on the same line. My code is below, but I can't seem to creat anything that does not display links on one line each.
a!linkField(
links:
apply(
a!documentDownloadLink,
merge(
local!docs,
local!docNames
)
)
)
OriginalPostID-165099
OriginalPostID-165099
Discussion posts and replies are publicly visible
Parents
0
Chris
over 9 years ago
As I was thinking on a similar strategy, I was able to get this working today by wrapping the Rich Text field in an applyComponents() call, and utilizing a few helper functions. This rule will now take in a single folder ID and display all documents in one line with a nice text separator - should be great for entity backed records with attachment folder IDs stored in the DB. Essentially the expressions create arrays of documents and names, insert null values every other slot then iterate through creating either a rich text component of documentDownloadLink (where a document exists), or the text separator " | " where there is no document. I use a helper array there since null document values are a hassle, but this can probably be simplified. The rule also allows optional parameters for singleLine (display), recursiveSearch, noDocDisplayMessage and separatorText.
load(
local!singleLine: if(isnull(ri!singleLine),true(),ri!singleLine),
local!recursiveSearch: if(isnull(ri!recursiveSearch),false(),ri!recursiveSearch),
local!separatorText: if(isnull(ri!separatorText)," | ",ri!separatorText),
local!noDocFoundMessage: if(isnull(ri!noDocFoundMessage),"No documents found",ri!noDocFoundMessage),
local!docs: getdocumentsfromfolder(ri!folderId,local!recursiveSearch),
local!noDocs: or(isnull(local!docs),length(local!docs)=0),
local!docNames: if(local!noDocs,null,apply(fn!document,local!docs,"name")),
local!docs2: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
local!docs,
2,
0
),
","
),
","
),
1
)
),
local!docNames2: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
local!docNames,
2,
0
),
","
),
","
),
1
)
),
local!which: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
{
rule!CreateArrayFromSingleValue(1,length(local!docNames))
},
2,
0
),
","
),
","
),
1
)
),
if(local!noDocs,
a!richTextDisplayField(
value: a!richTextItem(
text: local!noDocFoundMessage/*,
style: "STRONG"*/
)
),
if(not(local!singleLine),
a!linkField(
links: apply(
a!documentDownloadLink,
merge(
local!docs,
local!docNames
)
)
),
a!richTextDisplayField(
value: a!applyComponents(
function: rule!docRichTextComponents(
docName: _,
doc: _,
which: _,
separatorText: _
),
array: merge(
local!docNames2,
local!docs2,
local!which,
rule!CreateArrayFromSingleValue(local!separatorText,length(docs2))
)
)
)
)
)
)
Helper function rule!docRichTextComponents:
if(
ri!which = 0,
a!richTextItem(
text: ri!separatorText
),
a!richTextItem(
text: ri!docName,
link: a!documentDownloadLink(ri!doc,ri!docName)
)
)
Helper function rule!docDisplay_Insert:
=insert(ri!array,ri!value,ri!insertAt)
Helper function rule!createArrayFromSingleValue
=split(ri!SingleValue & rept("(*)"&ri!SingleValue,max(0,ri!DesiredLength-1)),"(*)")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Chris
over 9 years ago
As I was thinking on a similar strategy, I was able to get this working today by wrapping the Rich Text field in an applyComponents() call, and utilizing a few helper functions. This rule will now take in a single folder ID and display all documents in one line with a nice text separator - should be great for entity backed records with attachment folder IDs stored in the DB. Essentially the expressions create arrays of documents and names, insert null values every other slot then iterate through creating either a rich text component of documentDownloadLink (where a document exists), or the text separator " | " where there is no document. I use a helper array there since null document values are a hassle, but this can probably be simplified. The rule also allows optional parameters for singleLine (display), recursiveSearch, noDocDisplayMessage and separatorText.
load(
local!singleLine: if(isnull(ri!singleLine),true(),ri!singleLine),
local!recursiveSearch: if(isnull(ri!recursiveSearch),false(),ri!recursiveSearch),
local!separatorText: if(isnull(ri!separatorText)," | ",ri!separatorText),
local!noDocFoundMessage: if(isnull(ri!noDocFoundMessage),"No documents found",ri!noDocFoundMessage),
local!docs: getdocumentsfromfolder(ri!folderId,local!recursiveSearch),
local!noDocs: or(isnull(local!docs),length(local!docs)=0),
local!docNames: if(local!noDocs,null,apply(fn!document,local!docs,"name")),
local!docs2: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
local!docs,
2,
0
),
","
),
","
),
1
)
),
local!docNames2: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
local!docNames,
2,
0
),
","
),
","
),
1
)
),
local!which: if(local!noDocs,null,rdrop(
split(
joinarray(
apply(
rule!docDisplay_Insert,
{
rule!CreateArrayFromSingleValue(1,length(local!docNames))
},
2,
0
),
","
),
","
),
1
)
),
if(local!noDocs,
a!richTextDisplayField(
value: a!richTextItem(
text: local!noDocFoundMessage/*,
style: "STRONG"*/
)
),
if(not(local!singleLine),
a!linkField(
links: apply(
a!documentDownloadLink,
merge(
local!docs,
local!docNames
)
)
),
a!richTextDisplayField(
value: a!applyComponents(
function: rule!docRichTextComponents(
docName: _,
doc: _,
which: _,
separatorText: _
),
array: merge(
local!docNames2,
local!docs2,
local!which,
rule!CreateArrayFromSingleValue(local!separatorText,length(docs2))
)
)
)
)
)
)
Helper function rule!docRichTextComponents:
if(
ri!which = 0,
a!richTextItem(
text: ri!separatorText
),
a!richTextItem(
text: ri!docName,
link: a!documentDownloadLink(ri!doc,ri!docName)
)
)
Helper function rule!docDisplay_Insert:
=insert(ri!array,ri!value,ri!insertAt)
Helper function rule!createArrayFromSingleValue
=split(ri!SingleValue & rept("(*)"&ri!SingleValue,max(0,ri!DesiredLength-1)),"(*)")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data