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

Question

Question

How to get Document ID from a Token?

asked on June 21, 2018

Hi all,

 

Using workflow, I make a simple search and return the document's ID into a token.

Now I'm trying to past this token in my SDK to make an export but I have an error.

 

This is my SDK

 Laserfiche.DocumentServices.DocumentExporter DocEx = new Laserfiche.DocumentServices.DocumentExporter();
DocumentInfo DI = Document.GetDocumentInfo(GetTokenValue("IDNewDoc"), RASession);
DocEx.ExportElecDoc(DI, Convert.ToString(GetTokenValue("Chemin")));
Can not convert from "object" to "string"

 

How can I resolve this please ?

 

Thanks in advance.

Regards

 

0 0

Answer

SELECTED ANSWER
replied on June 22, 2018

You could just set the script's default entry to your search result and then use:

DocumentInfo DI = (DocumentInfo)this.BoundEntryInfo;

(That way you save an unneeded call to Laserfiche to get an entry you already have.)

2 0

Replies

replied on June 21, 2018 Show version history

You can convert the result of a GetTokenValue to a string like so,

GetTokenValue("IDNewDoc").ToString()

However, that isn't what you want in this case because the overload for GetDocumentInfo will treat a string as a path, not an Entry ID.

If you're confident you'll get a numeric value you can do a cast like so,

(int)GetTokenValue("IDNewDoc")

Or I suppose you could do .ToString() and int.Parse() on the result so you can catch any errors with non-numeric values in the token.

 

Something to note is that GetTokenValue always returns an "object" so you need a .ToString() at the end or a cast whenever you reference tokens. (Convert.To_______ can work too, but it isn't really necessary).

0 0
replied on June 22, 2018

Hi,

 

Thanks all!

@████████, I didn't try your solution but ty anyway.

@████████I didn't think to change the default entry. I didn't understand what this object could to do ; now I know and this is very simple XD

 

Thanks you very much.

Regards

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

Sign in to reply to this post.