Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding News to Channels via LAPI 1

Status
Not open for further replies.

tyddynonn

Programmer
May 21, 2004
2
GB
Anyone had any success creating News Items via LAPI (VB version)?

LL_CreateObjectEx works great for Documents, Folders, ..even Channels! ... but whenever I try to create a News Item I get a 'Container Error'.

Code Snippet follows...
------------------------
Code:
    Call LL_ValueAlloc(aCreateInfo)  ' The assoc val for the Creation Info
    Call LL_ValueSetAssocInArgs(aCreateInfo)
    
    Call LL_ValueAlloc(aRequest)    ' The assoc val for the Request info
    Call LL_ValueSetAssocInArgs(aRequest)
    
    Call LL_AssocSetValue(aCreateInfo, "Request", aRequest)  ' & attach the Request Assoc


' **** Now fill in the fields in the aRequest Assoc with the data required to create the News Item
'News:
'Key               Value Type    Value Description
'_________________________________________________
'Story             String        the text containing the body of the news item
'DateEffective     Date          a value object of type Date specifying the date
'                                on which the news item becomes effective
'DateExpiration    Date          a value object of type Date specifying the
'                                date on which the news item expires
'Headline          String        the text representing the title of the news item
'IMG_ID            Integer       the object ID of an image (*.gif) file associated with
'                                the news item
'Comment           String        the comments associated with the news item


Call LL_AssocSetString(aRequest, "Story", objNewsItem.Body)
Call LL_AssocSetDate(aRequest, "DateEffective", MakeCDate(Now()))
Call LL_AssocSetDate(aRequest, "DateExpiration", MakeCDate(DateAdd("d", 5, Now())))
Call LL_AssocSetString(aRequest, "Headline", objNewsItem.Summary)
Call LL_AssocSetInteger(aRequest, "IMG_ID", 0)
Call LL_AssocSetString(aRequest, "Comment", "This is the Comment text")

' Now ensure we have a Unique Name for the News Item...

    Call LL_ValueAlloc(aNodeInfo)
    Call LL_ValueSetAssocInArgs(aNodeInfo)
    Call LL_ValueAlloc(vName)
    
    Call LL_AssocSetString(aNodeInfo, "Name", objNewsItem.Title)
    Call LL_AssocSetInteger(aNodeInfo, "SubType", LL_NEWSSUBTYPE)
    
    status = LL_GetUniqueObject(m_lSession, VolID, objNewsItem.ChannelID, aNodeInfo, vName)
    If status <> LL_OK Then
        LL_ErrorMsg m_lSession, "Getting Unique name for " & objNewsItem.Title
        CreateNewsItem = -1
        GoTo Exit_CreateNewsItem
    End If
    Call LL_ValueGetString(vName, sBuffer, 256, BUFSIZ)
    sUniqueName = Left(sBuffer, BUFSIZ)

'Long     LL_CreateObjectEx( _
'                    ByVal     session     as     Long, _
'                    ByVal     parentVolID as     Long, _
'                    ByVal     parentID    as     Long, _
'                    ByVal     objType     as     Long, _
'                    ByVal     objSubType  as     Long, _
'                    ByVal     name        as     String, _
'                    ByVal     createInfo  as     Long, _
'                    ByVal     objectInfo  as     Long )

' Now create the Object...**** ALWAYS FAILS WITH A 'Container Error' *************

    status = LL_CreateObjectEx(m_lSession, _
                                ChannelVolID, _
                                objNewsItem.ChannelID, _
                                LL_OBJECTTYPE, _
                                LL_NEWSSUBTYPE, _
                                sUniqueName, _
                                aCreateInfo, _
                                m_TempObject)
    If status <> LL_OK Then
        LL_ErrorMsg m_lSession, "Creating News Item: " & objNewsItem.Title
        CreateNewsItem = -1
        GoTo Exit_CreateNewsItem
    End If
 
We haven't done this specifically but we do quite a bit of LAPI development. You will find that you run into frustrating errors like this all the time when dealing with LAPI development. A good trick is to run the Livelink Builder and set a debug break on the LAPI call you are using. When your LAPI code executes the Builder will break on the Oscript that is called from LAPI. You can then trace through the Oscript (which is doing the actual updates to Livelink) and figure out what the problem is. Sometimes you even get a good error status in the Oscript code that isn't returned to LAPI. Most of the time you have to look at the values of the variables and try to figure out where the problem is.

LL_CreateObjectEx is in the APIDOC ospace under the APIDocuments object.
 
Finally got an answer from Opentext:

In the CreateObjectEx Call, you need to set

- ParentVolID to the the ChannelID (e.g. 123456)
- ParentID to -ChannelID (e.g. -123456)
- objType to NEWSSUBTYPE
- objSubType to NEWSSUBSTYPE

then it works!

Roll on a documentation update......

 
The DateEffective and DateExpiration in my function does not work. I Only have 01.01.1970 (and the creation Time)
in the Database.

What do i wrong?

I use VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top