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

Question

Question

Return the Entry ID of a newly created document

SDK
asked on June 20, 2017 Show version history

I am leveraging this code to do as it says - create a document/assign a template:

http://answers.laserfiche.com/questions/49295/Using-RA-to-create-a-document-assign-a-template-and-populate-fields

 

All seems to work fine.  What I'd like to do is return the 'Entry ID' of this newly created document.  The only way I can determine how this might be done is to recursively go thru the contents of a folder looking for the document with the document name I care about - certainly this isn't the only way... is it?

 

        private void GetAllDocuments(Session session)
        {

            string myFolder = @"Laserfiche\z_Training Manual";
            string searchParameters = String.Format("{{LF:Lookin=\"{0}\"}}", myFolder);

            Search lfSearch = new Search(session, searchParameters);
            SearchListingSettings settings = new SearchListingSettings();
            settings.AddColumn(SystemColumn.Id);

            lfSearch.Run();

            SearchResultListing searchResults = lfSearch.GetResultListing(settings);

            foreach (EntryListingRow item in searchResults)
            {
                Int32 docId = (Int32)item[SystemColumn.Id];
                //Console.Write(docId);
                //DocumentInfo docInfo = new DocumentInfo(docId, session);


                EntryInfo entryInfo = Entry.GetEntryInfo(docId, session);
                if (entryInfo.EntryType == EntryType.Shortcut)
                    entryInfo = Entry.GetEntryInfo(((ShortcutInfo)entryInfo).TargetId, session);

                // Now entry should be the DocumentInfo
                if (entryInfo.EntryType == EntryType.Document)
                {
                    DocumentInfo docInfo = (DocumentInfo)entryInfo;
                    // check for docInfo.Name match?
                }

            }

        }

 

0 0

Answer

SELECTED ANSWER
replied on June 20, 2017

DocumentInfo.Id is the ID of the document.

0 0
replied on June 20, 2017

ouch - you are correct.  Thank you.

                FolderInfo parentFolder = Folder.GetFolderInfo("\\someFolder", session);
                DocumentInfo document = new DocumentInfo(session);
                document.Create(parentFolder, "myNewDocument - " + DateTime.UtcNow.ToString(), EntryNameOption.None);

// after document.Create, document.Id will have valid value

 

0 0

Replies

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

Sign in to reply to this post.