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

Question

Question

Calling GetEntryByPath doesn't accept tokens in the path

SDK
asked on February 19, 2015

When attempting to move a document to another folder, we call GetEntryByPath to see if the destination exists. If not, we use LFFolder.Create to create the destination first. If the destination path uses tokens (e.g. \Test\%(Date)), then the GetEntryByPath call fails because it treats the token literally. However, the LFFolder.Create call recognizes the token and creates the appropriate folder. A conflict arises if the destination path (using a token) already exists. The GetEntryByPath fails because of the token and the LFFolder.Create fails because the folder already exists.

Can GetEntryByPath be called with an option to interpret tokens to prevent this conflict?

Thank you.

0 0

Answer

SELECTED ANSWER
replied on February 19, 2015

It appears the following syntax is working for our situation:
 

      LFApplication app = new LFApplication();
      LFConnection conn = new LFConnection();
      LFServer serv;
      LFDatabase db;

      serv = app.GetServerByName("Server");
      db = serv.GetDatabaseByName("Repository");
      conn.UserName = "user";
      conn.Password = "pwd";
      conn.Create(db);

      string newPath = @"\Temp\%(Date)";
      LFTokenSubstitutionEngine sub = new LFTokenSubstitutionEngine();
      sub.RegisterSystemTokens();
      newPath = sub.SubstituteTokens(newPath, sub.GetDefaultContext(conn, null, null), conn.Locale);

        conn.Terminate();

 

2 0

Replies

replied on February 19, 2015 Show version history

Then you would need to write your own token processor, it's a not a built-in feature of LFSO.

Correction: You can use the LFTokenSubstitutionEngine class to replace tokens.

1 0
replied on February 19, 2015

Is this from Workflow or your own SDK application?

0 0
replied on February 19, 2015

Our own LFSO83 SDK application, thank you.

0 0
replied on February 19, 2015

Thank you, I have started looking into the LFTokenSubstitutionEngine class. I can see the class in the toolkit, but am unable to find documentation or sample code in the 8.3 or 9.2 SDK Help files. Is there another source available to explain how to use this class?  

0 0
SELECTED ANSWER
replied on February 19, 2015

It appears the following syntax is working for our situation:
 

      LFApplication app = new LFApplication();
      LFConnection conn = new LFConnection();
      LFServer serv;
      LFDatabase db;

      serv = app.GetServerByName("Server");
      db = serv.GetDatabaseByName("Repository");
      conn.UserName = "user";
      conn.Password = "pwd";
      conn.Create(db);

      string newPath = @"\Temp\%(Date)";
      LFTokenSubstitutionEngine sub = new LFTokenSubstitutionEngine();
      sub.RegisterSystemTokens();
      newPath = sub.SubstituteTokens(newPath, sub.GetDefaultContext(conn, null, null), conn.Locale);

        conn.Terminate();

 

2 0
replied on February 20, 2015

Yes, that's the correct usage. Sorry I didn't get a chance to get back to you.
 

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

Sign in to reply to this post.