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

Question

Question

Updating Metadata fields using ClientAutomation

SDK
asked on July 14, 2014 Show version history

Updating Metadata fields

 

ClientManager lfclient = new ClientManager();

 

I am passing PID and hwnd to a Windows app that is launched Via a custom button.

 

 

This works perfect. Now with the ClientWindowType.DocumentViewer object I need to update some of the meta data in the metadatapane and save it when a user clicks on a button in the popup window.

 

Should I use RA access and the DocumentID then call refresh or is there a way to access the metadata fields via Laserfiche.ClientAutomation.

 

 

0 0

Answers

APPROVED ANSWER
replied on July 16, 2014

I'm not sure if I'm 100% understanding your question. You have a button on the document viewer that launches your application with the PID and hwnd. Here are the steps to update the metadata and refresh the document viewer:

 

  1. Your application uses PID/hwnd from the command line parameters to locate the DocumentViewer object.
  2. Get the document viewer's ClientAutomation.RepositoryConnection by calling DocumentViewer.GetCurrentRepository().
  3. Call RepositoryConnection.GetConnectionString() to get the serialized connection info, then create a RepositoryAccess.Session by calling Session.CreateFromSerializedLFConnectionString (or use RepositoryConnection.GetSerializedConnection/Session.CreateFromSerializedConnection if you are using RA 9.0 or earlier).
  4. With the RepositoryAccess.Session object, you can update the document's metadata. You know the document ID from DocumentViewer.GetDocumentId() or if you launched your toolbar application with the %(DocumentID) token.
  5. After updating the metadata in RA, call DocumentViewer.Refresh() to refresh the document viewer.
3 0
SELECTED ANSWER
replied on July 16, 2014

For anybody who wants it here you go.

 

 

 

try{

// Find an existing client instance that is logged in to the repository

IEnumerable<ClientInstance> clients = lfclient.GetAllClientInstances();

foreach (ClientInstance client in clients)

{

if (client.ProcessID == pid)

{

IEnumerable<ClientWindow> windows = client.GetAllClientWindows();

foreach (ClientWindow window in windows)

{

if (window.Hwnd == (IntPtr)hwnd)

{

if (window.GetWindowType() == ClientWindowType.DocumentViewer)

{

DocumentViewer docwindow = (DocumentViewer)window;

RepositoryConnection Res = docwindow.GetCurrentRepository(); //Get the document viewer's ClientAutomation.RepositoryConnection

Res.GetConnectionString(); //Call RepositoryConnection.GetConnectionString() to get the serialized connection

 

//create a RepositoryAccess.Session by calling Session.CreateFromSerializedLFConnectionString

Session MySession = Session.CreateFromSerializedLFConnection(Res.GetSerializedConnection());

 

DocumentInfo doc;

doc = Document.GetDocumentInfo(docwindow.GetDocumentId(), MySession);

FieldValueCollection fieldValues = doc.GetFieldValues();

//update the MetaData

fieldValues["Company Name"] = cbSupplierlist.Text.Substring(0, cbSupplierlist.Text.IndexOf("-") -1);

fieldValues["MFG VendorID"] = cbSupplierlist.Text.Substring(cbSupplierlist.Text.IndexOf("-") + 1);

doc.SetFieldValues(fieldValues);

doc.Save();

 

 

docwindow.Refresh();

Application.Exit();

}

 

}

}

}

}

 

}

catch (Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}

}

}

 

 

 

1 0

Replies

replied on July 16, 2014 Show version history

After you update the metadata outside of the client, find the open DocumentViewer object and call Refresh(). This will reload everything including the metadata pane.

2 0
replied on July 16, 2014

this is what I did.  works perfect.

 

  1. Your application uses PID/hwnd from the command line parameters to locate the DocumentViewer object.
  2. Get the document viewer's ClientAutomation.RepositoryConnection by calling DocumentViewer.GetCurrentRepository().
  3. Call RepositoryConnection.GetConnectionString() to get the serialized connection info, then create a RepositoryAccess.Session by calling Session.CreateFromSerializedLFConnectionString (or use RepositoryConnection.GetSerializedConnection/Session.CreateFromSerializedConnection if you are using RA 9.0 or earlier).
  4. With the RepositoryAccess.Session object, you can update the document's metadata. You know the document ID from DocumentViewer.GetDocumentId() or if you launched your toolbar application with the %(DocumentID) token.
  5. After updating the metadata in RA, call DocumentViewer.Refresh() to refresh the document viewer

 

That is pure power now, thanks

2 0
replied on July 16, 2014

Hello Ray,

 

If your question has been answered, please click the "This answered my question" button on the response.

 

Marking this post will show that the topic has been resolved and will guide others with similar issues to check out the resolution.  Thanks!

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

Sign in to reply to this post.