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
8 replies
Subscribers
5 subscribers
Views
3836 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
#Plugin I am writing a plugin for Appian in Java (an expression function plugin)
malcolmp
over 9 years ago
#Plugin I am writing a plugin for Appian in Java (an expression function plugin) into which I am passing an array of document id’s. I’d like to access each document represented by those id’s, however I have been unable to. My goal is to use an open source pdf reader on these pdf documents I have passed into the plugin. It will look like this: pdfReaderArray.add(new PdfReader(doc.getInternalFilename())); The problem I am experiencing is, while I can see (through debug statements) that the document id’s exist and are not null, the document’s internal filename is always null. The public Java API has been very helpful as have some of the shared components I have looked at for guidance. I have tried using the getVersion method of the Content Service in this manner:
Document doc = (Document) cs.getVersion(pdfsToMerge[i], ContentConstants.VERSION_CURRENT);
This seems to return a document, however as the API indicates, the getVersion method: “Gets the spec...
OriginalPostID-163107
OriginalPostID-163107
Discussion posts and replies are publicly visible
0
malcolmp
over 9 years ago
...ified version of the content. If retrieving a Document the internalFilename property won't be populated; use download(Long, Integer, Boolean) instead.”
So I tried using:
Document doc = cs.download(pdfsToMerge[i], ContentConstants.VERSION_CURRENT, false)[0];
The result of this was an InvalidContentException: Invalid Content ID. I looked at Sureshk594 post on the forum on 3/10/15 and the comments on that, though it did not solve my problem. If anyone can help me figure out how to access a document/its internal filename when I have its id that would be most appreciated. Thanks.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
akshayan
Certified Lead Developer
over 9 years ago
You should be able to get the document using cs.download. Did you check if the document id exist in Appian?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolmp
over 9 years ago
Akshaya, thanks for your response! I printed out the id which I used to in the cs.getVersion(....), and then I printed out doc.getId() and the two were the same. So that makes me think that the document id did indeed exist in Appian. Does my use of the download method/syntax look correct?
Document doc = cs.download(pdfsToMerge[i], ContentConstants.VERSION_CURRENT, false)[0];
I began to wonder if perhaps there was something wrong with the ContentConstants.VERSION_CURRENT parameter. When I printed that out it said it was equal to -1. Does that sound right?
Thanks for your help.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
abhi.jana
Appian Employee
over 9 years ago
That is correct. The value is -1 for the current version constant
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
akshayan
Certified Lead Developer
over 9 years ago
To test if the id exist, you can go to designer -> Documents and search for the id. If the id exist, it will prompt you to download the document. Alternatively, you can use document unction and create a test expression to test if the id exist e.g., document(documetId,"name") should return the name of the document if document exists.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolmp
over 9 years ago
Abhi, thank you.
Akshaya, thank you. I searched for the id and it appears the document doesn't exist. I was not expecting that because it gave me an id that appeared to be legitimate. Perhaps the problem was that because I was using a local variable the document wasn't persisted to the Appian file system. I will try changing some things and see if I can fix that. Thanks again for your help, I appreciate it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
akshayan
Certified Lead Developer
over 9 years ago
Malcolm, Don't use the temporary id that is available as soon as you upload a file. Uploaded files get a permanent id only after the form is submitted. See the notes at
forum.appian.com/.../SAIL_Components.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolmp
over 9 years ago
This explains it. I was wondering if that was the problem, but then I thought it shouldn't be. I'll change my process. Thanks again!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel