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

Question

Question

In Workflow, How can I find the linked Documents from a Document Relationship

asked on January 31, 2014 Show version history

 When using a Document Relationship in the repository, how can I find linked documents to a particular entry? Is there a search I can do to find those entries with the specific relationship type and relating to an entry of a particular ID? I have had no luck trying to set that type of search up yet.

1 0

Answer

SELECTED ANSWER
replied on January 31, 2014

There is nothing built-in. You would have to use a script. See the GetEntryLinks method in RepositoryAccess or FindLinks in LFDocument in LFSO in your SDK documentation.

1 0
replied on February 3, 2014

How would I go about traversing through the collection? Is it going to come back like an array would be?

0 0
replied on February 3, 2014
You would basically do something like for each Indvlink in linkcollection, and then iterate through based on the values of Indvlink.
0 0
replied on February 5, 2014 Show version history

Hi Kenneth,

 

Are you using VB.NET?

I had a similar task where I was trying to find the document ID's of all the documents that are linked to the starting entry in Workflow, so I set up the following script. (You would just need to change it to look at your server, repository, and specify a username & password to log in under)

 

            Dim myRepoReg As Laserfiche.RepositoryAccess.RepositoryRegistration = New Laserfiche.RepositoryAccess.RepositoryRegistration("your server name", "your repository")
            Dim MySession As New Laserfiche.RepositoryAccess.Session

            MySession.LogIn("username","password",myRepoReg)

            Dim Entry as Integer = GetTokenValue("Entry ID")
            Dim IDList as String = ""
            Dim Links as EntryLinkCollection
            Dim Count as Integer = 0


            Links = EntryLink.GetEntryLinks(Entry,MySession)

            For each Link as EntryLinkInfo in Links
                if Count = 0 Then
                    IDList = Link.TargetId.ToString
                    Count = Count + 1
                Else
                    IDList = IDList + "," + Link.TargetId.ToString
                End If

            Next

            SetTokenValue("LinkedDocumentIDs",IDList)

            'MsgBox(GetTokenValue("LinkedDocumentIDs"))

            MySession.LogOut

 

This brings back a list of the linked Document ID's in the token LinkedDocumentIDs delimited by a commaIf you were looking for only documents linked with a specific relationship you could probably add more IF/ELSE conditions in the For Each section.

 

 

It's not great but I hope it helps!

Dom

1 0
replied on February 5, 2014

Workflow SDK scripts provide a connection already to Laserfiche so I would recommend the script above but without the login/logout portion.

 

In WF 9.1, that would be

 

Dim mySesssion as Session = me.RASession

 

In addition, the entry id can be retrieved by calling:

 

me.BoundEntryId or

me.LaserficheApi.StartingEntryId or

me.LaserficheApi.BoundEntryId

 

 

 

1 0
replied on February 5, 2014

Dom,

 

If you're using that script in Workflow, you should use the built-in connection rather than making your own. Workflow cleans up its own script connections, but your script could leave open connections if something goes wrong.

 

In WF 9.1, RepositoryAccess is the default reference for SDK Script activities, so use something like this:

 

Dim Entry as Integer = me.BoundEntryId
Dim Session as Session = me.RASession
Dim IDList as String = ""
Dim Links as EntryLinkCollection
Dim Count as Integer = 0


Links = EntryLink.GetEntryLinks(Entry,Session)

In WF 9.0, you have to install RepositoryAccess first and then add it as a referenceto your script, but then you can just tell WF to use it as the script connection:

 

Dim wrapper as ConnectionWrapperRA = me.ConnectToRA(ConnectionMethodRA.RepositoryAccess90)           
dim docinfo as Laserfiche.RepositoryAccess.Documentinfo = wrapper.BoundEntry 

 

3 0
replied on February 7, 2014

Thanks for the tips! 

I didn't realise you could use the RepositoryAccess reference in version 9.0 - whereabouts could I install it if I was running WF 9.0?

Thanks,

Dom

0 0
replied on February 7, 2014

You could get it by installing the SDK runtime.

0 0
replied on July 10, 2014

Can someone post a full script that does the job?

0 0
replied on September 9, 2014 Show version history

Hi Ken,

 

If I remember correctly this was the script I finally ended up using:

            Dim MySession as Session = me.RASession
            Dim Entry as Integer = me.BoundEntryId
            Dim IDList as String = ""
            Dim Links as EntryLinkCollection
            Dim Count as Integer = 0

            Links = EntryLink.GetEntryLinks(Entry,MySession)

            For each Link as EntryLinkInfo in Links
                if Count = 0 Then
                    IDList = Link.TargetId.ToString
                    Count = Count + 1
                Else
                    IDList = IDList + "," + Link.TargetId.ToString
                End If

            Next

            SetTokenValue("LinkedDocumentIDs",IDList)

            'MsgBox(GetTokenValue("LinkedDocumentIDs"))

I then used the Split Function found in Token Dialogue... to separate the EntryID's returned from the script and put them into a multi-value token. (whenever a "," is found).

7 0
replied on September 9, 2014

Hi Dominic,

 

I haven't looked at this in a while, but assuming my cursory look at the code is accurate and that code runs perfectly, then you using the function of Split on every , would work to give you a multi-value token with the various IDs. 

0 0
replied on February 29, 2016

I would rather have a Find Links over a Delete Links so that we can determine what to do with the links just like with the Find Entries activities.

0 0
replied on August 24, 2016

This script worked perfectly for me and just saved me hours!!!!  Yaay Laserfiche Answers and Dominic!!!!

0 0
replied on September 15, 2016

Is this ability being considered as a new activity in a future version of Workflow?

1 0
replied on February 4, 2017

As someone who does not understand much of what was said above, but none-the-less still need to find all linked entries, I would greatly appreciate this being a drag and drop activity in future versions.

0 0
replied on March 1, 2017

Is this possible yet in Workflow 10.2 without needing to use the SDK? Thanks

0 0
replied on March 1, 2017

Not as of 10.2. There weren't a lot of new features for Workflow in 10.2

0 0
replied on March 1, 2017

Please please please please please please please please please. Get it into 10.3....... It sure would help.

2 0
replied on June 1, 2017

Agreed, we're have multiple clients with need for this functionality. 

0 0
replied on April 3, 2018

I solved this by using the SDK Script someone posted elsewhere on this site and it worked.

0 0
replied on February 26, 2020

Late post; we have developed a custom workflow activity that will retrieve the linked entries associated with any selected repository entry.   The custom activity returns an entry collection that can be used to feed a For Each Entry activity to allow you to iterate through the link collection.  Other link properties returned are the link entry ID, link relationship, link reverse relationship, and link description.  Here is a screen shot of the custom activity properties pane;

This and other custom workflow activities are available on the Products page of the Qfiche website at http://qfiche.com/products.  The custom workflow activities available for download are fully functional 30 day demos.

0 0
replied on January 13, 2022

Thank you - this SDK script worked perfectly! cool

0 0

Replies

You are not allowed to reply in this post.
replied on January 31, 2014 Show version history

The advanced search syntax for a document relationship search is {LF:Relation= "relationshipname"}

You can find some more information on document link searches in the 8.3 Advanced Search Syntax paper. Most of the information still applies to version 9.

replied on February 7, 2014

Script to search for document ID's linked to starting entry in WF (Updated version).

 

Dim MySession as Session = me.RASession
            Dim Entry as Integer = me.BoundEntryId
            Dim IDList as String = ""
            Dim Links as EntryLinkCollection
            Dim Count as Integer = 0


            Links = EntryLink.GetEntryLinks(Entry,MySession)

            For each Link as EntryLinkInfo in Links
                if Count = 0 Then
                    IDList = Link.TargetId.ToString
                    Count = Count + 1
                Else
                    IDList = IDList + "," + Link.TargetId.ToString
                End If

            Next

            SetTokenValue("LinkedDocumentIDs",IDList)

 

You are not allowed to follow up in this post.

Sign in to reply to this post.