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

Question

Question

SDK/SDK Script Info on Document Links

asked on June 30, 2021

Working on an IBM Visual Info migration, we had a situation where we need to create links between documents using the SDK. This is a poorly documented area of both the SDK and the on line help, so I'm posting this in the hopes that is saves someone else some time. (Don't forget to "This was helpful" if it does, we love points!) 

So you need to start with the Admin Console, Metadata, Document Links. There are two link types pre-defined, and then you can define your own:

 

This is important, because each of these items is referred by its ID, which is numeric starting at 1.

After some futzing around we found this code to work:

 

            Dim EL As EntryLinkInfo = Nothing
            EL = EntryLink.Create(TargetDocInfo, NoteDocInfo, 3, "Link to document notes.", LF_Session)

 

Based on this SDK Reference:

Public Shared Function Create ( _
	source As EntryInfo, _
	target As EntryInfo, _
	linkTypeId As Integer, _
	description As String, _
	session As Session _
) As EntryLinkInfo

The problem was that there was no obvious information about the values of the linkTypeID.  We found that 0 caused an error, 1 gave you this:

 

and 2 gave you this:

That's when the light bulb went off. We defined out own type, and called it using a value of 3:

 

So linkTypeID points to what are descriptive labels. But, without them you cannot create a link. Finally, EntryLinkInfo does not seem to have an Update or Dispose property, and the document is not locked while the link is created. You just create it or delete it. 

 

2 0

Replies

replied on June 30, 2021

Use EntryLinkType.EnumAll to see the available link types and their ID:

DocumentInfo doc1 = Document.GetDocumentInfo(@"\doc1", session);
DocumentInfo doc2 = Document.GetDocumentInfo(@"\doc2", session);

// If you already know the ID of the link definition:
//EntryLinkTypeInfo entryLinkDef = EntryLinkType.GetInfo(linkTypeId, session);

// If you want to see all link types to get the ID for a specific link type:
foreach (EntryLinkTypeInfo entryLinkDef in EntryLinkType.EnumAll(session))
{
    if (entryLinkDef.SourceLabel == "Attachment")
    {
        EntryLinkInfo linkInfo = EntryLink.Create(doc1, doc2, entryLinkDef.Id, "Linking doc1 to doc2", session);
    }
}

 

2 0
replied on June 30, 2021

Thanks Robert - That's useful code. 

 

The gap I found was the relationship between the EntryLinkType and the Link definitions which are created in the Admin Console. That was the head scratcher we got hung up on.

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

Sign in to reply to this post.