You are viewing limited content. For full access, please sign in.

Question

Question

SDK - How to create a document and metadata when user has create rights only

asked on November 10, 2014

We have an app that allows users to import documents.  The users have "create=allow" but "edit=deny" rights on the template fields.  Currently, this app uses the "import list" feature, which seems to create the documents and metadata entries at the same time.  So, we have had no securtiy issues with this approach.

I am trying to change this to use classes such as DocumentImporter, Document, and EntryInfo instead of import lists.  My code looks like this:

DocID = Document.Create(fs.CurrentFilePath + "\\" + fs.CurrentFileName, _LFVolumeName, EntryNameOption.None, LFSession);

DocumentImporter di = new DocumentImporter();

di.Document = Document.GetDocumentInfo(DocID, LFSession);

if (fs.CurrentFileName.ToLower().EndsWith(".tif"))

{

try

{

di.ImportImages(infotemp.FullName);

}

catch (Exception ex)

{

// tif extension but not readable by Laserfiche. Import as electronic file.

if (ex.Message == "Lfi_GetFileInfo failed.")

{

di.ImportEdoc("application/unknown", infotemp.FullName);

}

}

}

else

{

di.ImportEdoc(GetMimeType(infotemp), infotemp.FullName);

}

EntryInfo ei = Entry.GetEntryInfo(DocID, LFSession);

ei.SetTemplate(LFTemplateName);

ei.SetFieldValues(FVC);

ei.Save();

fs.EntryID = ei.Id;

 

The ei.Save call returns error "Access denied. (9013)"  I assume this is because the entry activity represents an "edit" action instead of a "create" action.

How can I work around this?

 

0 0

Answers

APPROVED ANSWER
replied on November 13, 2014

Instead of using the Document.Create method as in your code sample, I would suggest creating the document through the DocumentInfo.Create method (which creates a locked DocumentInfo object) to pass to the importer as well as index.

1 0
SELECTED ANSWER
replied on November 13, 2014

Hi Pete,

Depending on what version of the SDK you're using, you may be running into a bug. There was at least one version of SDK 9 that implemented DocumentImporter in a slightly goofy way, that could cause the issue you're seeing here. I'd definitely recommend that you start by updating to the newest version of the SDK, if that's an option.

If that doesn't fix the issue, there are other things you can try. I see you're not setting an entry lock on the document before assigning metadata, which could also cause this issue.  After you create the entry, try locking it, assigning metadata, and then releasing the lock afterwards.  If you're still running into the issue after that, you might want to try using the service account to assign metadata rather than the importing user's account.

Hopefully one of those suggestions fixes the problem. Let us know if not!

0 0

Replies

replied on November 13, 2014

I was able to make it work using DocumentInfo as suggested.  Thank you!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.