08
Sep
Get Default link for a Node
Posted by Hussain, under LivelinkSometimes you may have a Livelink Object ID (the value of dataid from dtree) and you need to create a link to that object. Generally you can find most of the components that you need in the request object, such as the complete URL, but the actual Request Handler for that type of Livelink Object is a little more complex. You can follow the function calls used in the Browse pages, but sometimes you do not have enough information, for example when within a function where these objects are not available.
This article looks at an alternative method to get a link to that Livelink Object. For this we will use the Livelink URL that is used by the Notifications system (
| Text | | copy code | | ? |
| 01 | function String getDefaultURL (DAPINode inNode) |
| 02 | // Load the Notification Configuration information |
| 03 | Dynamic config=$LLAgent.Utils.ConfigLoad( prgCtx.USession().fDbConnect.fConnection, 100 ) |
| 04 | |
| 05 | // Convert the Node into a WebNode |
| 06 | Object webNode=$WebNode.WebNodes.GetItem(inNode.pSubType) |
| 07 | |
| 08 | // Get the Open action of the WebNode |
| 09 | Object open=webNode.Cmd("open") |
| 10 | |
| 11 | // String to store the return value |
| 12 | String nodeURL |
| 13 | |
| 14 | // if the Object in question is not a Document then use this link format |
| 15 | if (inNode.pSubType <> $TypeDocument) |
| 16 | nodeURL=Str.Format("%1?%2",config.URL,Str.Format(open.fQueryString,inNode.pID)) |
| 17 | |
| 18 | // For Documents point at the General Properties page |
| 19 | else |
| 20 | nodeURL=Str.Format("%1?func=ll&objid=%2&objaction=properties",config.URL,inNode.pID) |
| 21 | end |
| 22 | end |
In response to a question on the Knowledge Center, another approach for creating the nodeURL was provided by Kyle Swidrovich. This approach would replace the if .. then clause in the function with the following :
| Text | | copy code | | ? |
| 1 | nodeURL = Str.Format( "%1/open/%2", config.URL, inNode.pID) |
Having tested this approach, the only difference I’ve found is that the original code takes you to the browse page for Folders, Projects, Compound Documents etc and the Properties page for Documents, whereas the new one just calls the open action for that Object. Thus if a Document is a Word document it would be viewed – or you would see the Document Overview page depending on your configuration – and a ZIP file would be downloaded rather than showing the Properties dialog for the Object, in some cases this may be what you want.
Source: http://www.greggriffiths.org/livelink/development/oscript/snippets/defaultopenlink.html



Post a Comment