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!

How to write required attribute value in CreateObjectEx 2

Status
Not open for further replies.

psmello

Programmer
May 14, 2003
10
US
I'm trying to write the value of a custom required attribute called Document Date which is in the standard date format (Month field, day field, year field). I tested this manually to see that the attribute is required.

I am trying to programatically add a document and populate this attribute. I can add documents without a problem, so it's just the attribute part that I need help with. The code snippet is below:

If (status = LL_OK) Then
status = LL_ValueAlloc(createInfo)
End If
If (status = LL_OK) Then
status = LL_ValueAlloc(lObjInfo)
End If
If (status = LL_OK) Then
status = LL_ValueAlloc(verInfo)
End If

If (status = LL_OK) Then
status = LL_ValueSetAssocInArgs(createInfo)
End If

If g_strDate = "" Then
g_strDate = CStr(month(Now) & "/" & day(Now) & "/" & _
year(Now))
End If

sYear = year(CDate(g_strDate))
sMonth = month(CDate(g_strDate))
sDay = day(CDate(g_strDate))

If (status = LL_OK) Then
status = LL_AssocSetAssoc(g_strDate, "Document Date")
End If

status = LL_CreateObjectEx(session, parentVol, lParentID, LL_VERSIONOBJECTTYPE, lType, sName, createInfo, lObjInfo)

I parse out the date into the day, month and year, but don't apply it since I didn't see a way to do this in the call.

Any help would be greatly appreciated. Thanks to all who have helped in the past too.

Peter Mello
 
The createInfo parameter will take three types of assocs one is
createInfo.Categories that is what you will need to manipulate for your category stuff with something like

LL_FetchCategoryVersion(Session_ID, CatID, CatVer)
or
LL_SetObjectAttributesEx(Session_ID, ObjID, CatVersion)

This if from the documentation and I have no means to test this personally Soory

Everybody is ignorant, only on different subjects. - Will Rogers

appnair

 
i did manage to write a quick one in java which basically
looks at a hardcoded category called test ,adds a line and adds a document,i checked it and it does retain the category info .If you have an email id I will send it but it is written in java ,my cup of tea(coffee)

Everybody is ignorant, only on different subjects. - Will Rogers

appnair

 
My email address is: psmello@adelphia.net

Thanks for all your help.

Peter Mello
 
To AppNair:

Could you please resend me the email with the Java code to add a doc with a category? I lost all saved emails recently.

Many thanks,

psmello
 
I'm stuck at this point. The entire function is listed below. I get no error at CreateObjectEx, but no doc is created. If I remark out these lines (just before the call to CreateObjectEx)

status = LL_AssocSetInteger(createInfo, "request", cRequest)
status = LL_AssocSetInteger(createInfo, "Categories", categories)

I get a document, but no date and an error value (most likely due to the lack of date population because it's a required field).

I tried my best to convert the Java code to VB6, but I'm afraid I'm stuck again. Any ideas would be greatly appreciated.

Thank you,

PSM

**********************************************************
Public Function Create_LLDoc(ByVal lParentID As Long, ByVal sName As String, _
ByVal lType As Long, ByVal sPath As String) As Long

Dim status As Long
Dim NodeID As Long
Dim nodeVol As Long
Dim lObjInfo As Long
Dim createInfo As Long
Dim verInfo As Long
Dim sYear As String
Dim sMonth As String
Dim sDay As String
Dim lYear As Long
Dim lMonth As Long
Dim lDay As Long
Dim catID As Long
Dim catVersion As Long
Dim attrValues As Long
Dim lDocDateID As Long
Dim categories As Long
Dim cRequest As Long
Dim extData As Long

status = LL_OK

Create_LLDoc = 0

If (status = LL_OK) Then
status = LL_ValueAlloc(createInfo)
End If
If (status = LL_OK) Then
status = LL_ValueAlloc(lObjInfo)
End If
If (status = LL_OK) Then
status = LL_ValueAlloc(verInfo)
End If

'Date conversion stuff
If g_strDate = "" Then
g_strDate = CStr(month(Now) & "/" & day(Now) & "/" & year(Now))
End If

sYear = year(CDate(g_strDate))
lYear = CLng(sYear)

sMonth = month(CDate(g_strDate))
lMonth = CLng(sMonth)

sDay = day(CDate(g_strDate))
lDay = CLng(sDay)

'Category stuff
If (status = LL_OK) Then
status = LL_ValueAlloc(catID)
End If

If (status = LL_OK) Then
status = LL_ValueSetAssoc(catID)
End If

If (status = LL_OK) Then
status = LL_ValueAlloc(catVersion)
End If

If (status = LL_OK) Then
status = LL_ValueAlloc(attrValues)
End If

If (status = LL_OK) Then
status = LL_ValueAlloc(categories)
End If

If (status = LL_OK) Then
status = LL_ValueAlloc(cRequest)
End If
If (status = LL_OK) Then
status = LL_ValueAlloc(extData)
End If

If (status = LL_OK) Then
status = LL_AssocSetInteger(catID, "ID", g_lngDocDateID)
End If

If (status = LL_OK) Then
status = LL_AssocSetInteger(catID, "Version", 0)
End If

If (status = LL_OK) Then
status = LL_FetchCategoryVersion(session, catID, catVersion)
End If

status = LL_ValueSetList(attrValues)
status = LL_ValueSetDateEx(attrValues, lYear, lMonth, lDay, 0, 0, 0)
'status = LL_ListSetDateEx(attrValues, 0, lYear, lMonth, lDay, 0, 0, 0)

If (status = LL_OK) Then
status = LL_AttrSetValues(session, catVersion, "Document Date", LL_ATTR_DATAVALUES, 0, attrValues)
End If

'Add category info to createInfo
status = LL_ValueSetList(categories)
status = LL_ValueSetInteger(categories, catVersion)

status = LL_ValueSetAssoc(cRequest)
status = LL_ValueSetAssoc(extData)
status = LL_ValueSetAssoc(categories)
status = LL_ValueSetAssoc(createInfo)

status = LL_AssocSetString(cRequest, "Comment", "")

status = LL_AssocSetInteger(createInfo, "request", cRequest)
status = LL_AssocSetInteger(createInfo, "requiredAttributes", extData)
status = LL_AssocSetInteger(createInfo, "Categories", categories)

' Add document
status = LL_CreateObjectEx(session, parentVol, lParentID, LL_VERSIONOBJECTTYPE, _
lType, sName, createInfo, lObjInfo)

DoEvents

If (status = LL_OK) Then
status = LL_ValueAlloc(NodeID)
End If

If (status = LL_OK) Then
status = LL_AssocGetInteger(lObjInfo, "ID", NodeID)
End If

If (status = LL_OK) Then
If lType = LL_DOCUMENTSUBTYPE Then
status = LL_CreateVersion(session, parentVol, NodeID, sPath, verInfo)
End If
Else
MsgBox "Error creating Livelink document", vbCritical, "Keyfile-Livelink Migration"

End If

'MsgBox "Create doc success"

Create_LLDoc = NodeID

End Function
 
Code:
Your call
status = LL_AssocSetInteger(createInfo, "requiredAttributes", extData)
is actually a call to additional node attributes and has nothing to do with the required attributes within a category
This call is valid only when you have an additional node attribute applied to a document check if that is true with yr administrator
the documentatio says for a node you can have three types
Code:
a value object of type Assoc, created using the Value API, containing the creation information for the object; the createInfo Assoc can contain the three Assocs described below
comment out these lines and see how it goes
 status = LL_AssocSetString(cRequest, "Comment", "")
// this is probably OK this ends up on the comment field in the gui  
    status = LL_AssocSetInteger(createInfo, "request", cRequest)
    status = LL_AssocSetInteger(createInfo, "requiredAttributes", extData)
Also I would worry about the date format only after you get yr program to create a document and apply a simple attribute
or in the worst case you could make the date thing unrequired while testing

Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top