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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to upgrade category through LAPI 1

Status
Not open for further replies.

LivelinkDotnet

Programmer
Jul 5, 2010
18
0
0
IN
We have modified the length of one attribute in one category . When we go to category page of any object to whome this category is assigned . On this page Upgrade button apears.
There are around more than 1lacks items , so we want to this task through LAPI. So that we can upgrade objects in batches and not all at one time.
we have found some below funtion
LL_UpgradeObjectCategory
UpgradeCategoryReferences
Can we use above function
if yes but when i try to use
LL_UpgradeObjectCategory ( _
ByVal session as Long, _
ByVal objID as Long, _
ByVal catID as Long, _
ByVal catVersion as Long, _
ByVal upgradeInfo as Long ) as Long

how use last parameter upgradeInfo , i have just declared llvaluealloc upgradeInfo , but when i run application due to this function application breaks.
We are using LAPI in vb.

Please help its very urgent
Thanks in advance




 
// We have updated length of Applicant Number attribute in MYCategory. Now i want to upgrade all items associated with this category. In below code i am trying to upgrade only one item whose node is 611312. Below code is not throwing any error. But also m not getting any value item processed. How i can keep track of how many items processed. i want to upgrade items in batches.
Please help how to retrieve infomration from parameters, what is upgradeinfo upgradeoutput parameters.
Please reply its urgent

Option Explicit

Private lSession As Long
Private lStatus As Long

Friend Sub upgrade()
On Error GoTo errTrap
Dim lCATVERSION As Long
Dim sSearchAttribute As String
Dim lAttrInfo As Long
Dim lCatID As Long
Dim upgradeInfo As Long
Dim upgradeOutput As Long
Dim buf As Long



LL_ValueAlloc lCATVERSION
LL_ValueAlloc lAttrInfo
LL_ValueAlloc lCatID
LL_ValueAlloc upgradeInfo
LL_ValueAlloc upgradeOutput


'Fetch the category version
LL_ValueSetAssocInArgs lCatID
LL_AssocSetInteger lCatID, "ID", 3951 --- "MYCategory" node id = 3951
LL_ValueSetAssocInArgs upgradeInfo
LL_ValueSetAssoc (upgradeOutput)
LL_ValueSetAssocInArgs upgradeInfo
LL_AssocSetInteger upgradeInfo, "LastID", 611312



lStatus = LL_FetchCategoryVersion(lSession, lCatID, lCATVERSION)
If lStatus <> LL_OK Then
MsgBox ("failed fetching category version")
Else
lStatus = LL_AttrGetInfo(lSession, lCATVERSION, "Applicant Number", 0, lAttrInfo)
lStatus = LL_UpgradeCategoryReferences(lSession, lCatID, upgradeInfo, upgradeOutput)

lStatus = LL_AssocGetInteger(upgradeOutput, "ItemsUpgraded", buf)
If lStatus <> LL_OK Then
MsgBox ("failed")
Else
MsgBox (buf)
End If
'lStatus = LL_UpgradeObjectCategory(lSession, 1809399, lCatID, lCATVERSION, upgradeInfo)

If lStatus <> LL_OK Then
MsgBox ("failed upgrade")
Exit Sub
Else

MsgBox ("Successful")
End If
End If
exitFunc:
Exit Sub
errTrap:
Resume exitFunc

End Sub
Friend Sub connect()
If Intilize() Then
Call upgrade
Else
MsgBox ("failed initilize")
End If
End Sub
Public Function Intilize() As Boolean

Dim status As Long
Intilize = True
status = LL_Initialize(LL_HEADER_VERSION)
If status <> LL_OK Then
Intilize = False
End If

status = LL_SessionAlloc(lSession, "stallsys01", 2099, "", "LivelinkDotNet", "LivelinkDotNet")
If status <> LL_OK Then
Intilize = False
End If

End Function

Private Sub Command1_Click()
Call connect
End Sub

Private Sub Command2_Click()
Call upgrade
End Sub


Please reply its urgent


 
If you simply want to upgrade the Category across the entire system you can do that from the Category Volume rather than creating a LAPI application to do it for you if you will be doing this on an irregular basis.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Thanks :) Ya it is one time actvity
Can you please provide some more info on how to go for it
i couldn't see any option in Category volume

 
Not sure what all is being attempted here. But here are some tips. If a category object has been changed like the name, attribute etc, and then there is no programming involved here except in these circumstances as explained later. Once you change the category definition, all one has to do is to click the functions menu in the category object and say 'Upgrade Items’. Livelink will calculate the number of outdated nodes to which the category is applied and process it in a batch fashion. It will say the number upgraded and skipped.
When will I be needed to program the upgrading?
A small example will help here. Assume I have a category called
SSN, State.The boss now says that SSN should be made mandatory and add another one saying "Who is responsible" again mandatory. If you click 'upgrade items' as in above way then all the nodes will realize that the two keys are mandatory and it will say "H'mm these are mandatory, do I have a value for it, if not I will stay with what the boss said, and skip it. Note folders and other containers do not enforce mandatoriness by default so they will get upgraded. Suppose w e try to work around this like this. I find a convenient folder somewhere and put a entry in SSN and the other mandatory attribute and say "apply changes to sub items",Livelink is now happy, but your 1 lac(lakh is 100000 in india or 0.1 million as they say here) items now have the same values, which is next to useless to the livelink search engine. Not sure if it will take existing values in a nodes and change it with the hard coded ones. That is for you to test.

In closing categories should be planned ahead of time to alleviate these administrative overheads and one should understand how they are made to work in livelink. Programming either in oscript, or lapi or web services should bear in mind the business rules with which the product is designed. I write this to help other readers your case may be just solved by doing the 'Upgrade Items' as Greg mentioned.


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008
 
As mentioned earlier we are trying to upgrade categatory using LAPI
we have written below code which is running and upgrading the category but after upgradation it removes all attribute values
Private lSession As Long
Private lStatus As Long

Friend Sub Upgrade()

'The following program is a sample of upgrading an individual document with a new category.

'Initialize the Livelink API. 'The LL_Initialize call initializes the Livelink API, and, in the process, verifies that the text 'definition files and *.dll files are of compatible versions. If initialization fails, an error message 'is printed and execution terminates. Otherwise, execution continues.



'If Not (lStatus) Then

' MsgBox Date & " " & time & ": LL_Initialize Failed, Wrong header or DLL"
'End
'End If

'Allocate value objects. 'The value objects that will be used later in the program are allocated.
'(Value objects are used extensively in Livelink to store many kinds of 'information.
'In this program they store the allocated session and Livelink 'Library object information.)
'If allocation fails, an error message is printed 'and execution terminates. Otherwise, execution continues.
' grab some value objects
' Dim lmessage As Long
' lStatus = LL_ValueAlloc(lmessage)
'
' If (lStatus <> LL_OK) Then
' MsgBox Date & " " & time & ": LL_ValueAlloc(lMessage) failed"
' End
' End If

'Allocate a session and connect to the Livelink server.
'Upon successful initialization, the LL_SessionAllocEx call allocates a session
'and attempts to connect to the Livelink server.
'If the connection cannot be made '( LL_SessionAllocEx does not return LL_OK), execution skips, 'where the connection error is retrieved by making the LL_SessionStatus call and 'is displayed. Otherwise, execution continues. '
'Allocate our session '

'lStatus = LL_SessionAllocEx(lSession, "K0013", 2099, "LIVELINKK0013", "Admin", "livelink", 0)
'lStatus = LL_SessionAllocEx(lSession, "K0013", 2099, "LIVELINKK0013", "Admin", "", 0)

'If (lStatus <> LL_OK) Then

'lStatus = LL_SessionStatus(lSession, siz, lmessage)

'If (lStatus <> LL_OK) Then lStatus = LL_ValueGetString(lmessage, buf, 255, siz)
'End
'End If
'End If

Dim curCatID As Long
Dim buf As Long

lStatus = LL_ValueAlloc(curCatID)
lStatus = LL_ValueSetAssoc(curCatID)
lStatus = LL_AssocSetInteger(curCatID, "ID", 3951) 'CatID of People Folders Category ID

If (lStatus <> LL_OK) Then
MsgBox ("Failed")
End If


' the new category ' get the latest category format
Dim catVersion As Long
lStatus = LL_ValueAlloc(catVersion)
lStatus = LL_ValueSetAssoc(catVersion)
lStatus = LL_FetchCategoryVersion(lSession, curCatID, catVersion) ' get the new categoryversion
Dim objID As Long
Dim catIDList As Long
Dim catID As Long
Dim upgradeInfo

lStatus = LL_ValueAlloc(catIDList)
lStatus = LL_ValueAlloc(objID)
lStatus = LL_ValueAlloc(catID)
lStatus = LL_ValueAlloc(upgradeInfo)
lStatus = LL_ValueSetAssoc(objID)
lStatus = LL_AssocSetInteger(objID, "ID", 1154777) 'You can get the categoryIDs of Peoplefolder whose objID 1154777

Dim lCatDocVersion As Long
lStatus = LL_ValueAlloc(lCatDocVersion)
lStatus = LL_ValueSetAssocInArgs(catID)
lStatus = LL_AssocSetInteger(catID, "ID", 3951) '# is the category ID.
lStatus = LL_GetObjectAttributesEx(lSession, objID, catID, lCatDocVersion) ' get the Peoplefolder category data

Dim DataAssocOut As Long ' Get the data out of the Peoplefolders category

lStatus = LL_ValueAlloc(DataAssocOut)
lStatus = LL_ValueSetAssocInArgs(DataAssocOut)
lStatus = LL_AttrGetInfo(lSession, lCatDocVersion, "Applicant Number", 0, DataAssocOut)
lStatus = LL_AssocGetInteger(DataAssocOut, "length", buf)
'lStatus = LL_AssocGetValue(lCatDocVersion, "Applicant Number", DataAssocOut)
'lStatus = LL_AssocGetInteger(DataAssocOut, "value", buf)

' put the document into the category upgrade assoc ' -catVersion ' - catID ' - DisplayName ' - ID ' - type ' - version ' - data ' set this from the original document ' - ID ' - Values ' - definition ' - Children ' - DisplayName ' - FixedRows ' - ID ' - MaxRows ' - Name ' - NextID ' - NumRows ' - Required ' - Type ' - ValueTemplate ' - ID ' - Values

lStatus = LL_AssocSetValue(catVersion, "Applicant Number", DataAssocOut) ' do not add a version to upgrade.

lStatus = LL_ValueSetAssoc(upgradeInfo)

lStatus = LL_AssocSetBoolean(upgradeInfo, "AddVersion", False)

lStatus = LL_ListObjectCategoryIDs(lSession, objID, catIDList) ' get the category ID assocs that are on the object

Dim intLength As Long

lStatus = LL_ValueGetLength(catIDList, intLength)

Dim i As Integer

For i = 0 To intLength - 1
lStatus = LL_ListGetValue(catIDList, i, catID)
'lStatus = LL_UpgradeObjectCategory(lSession, objID, catID, catVersion, upgradeInfo)
lStatus = LL_UpgradeObjectCategory(lSession, objID, catID, , upgradeInfo)
Next i

End Sub

Public Function Intilize() As Boolean

Dim status As Long
Intilize = True
status = LL_Initialize(LL_HEADER_VERSION)
If status <> LL_OK Then
Intilize = False
End If

status = LL_SessionAlloc(lSession, "stallsys01", 2099, "", "agachake", "agachake")
If status <> LL_OK Then
Intilize = False
End If

End Function

Private Sub Command1_Click()
Call connect
End Sub
Friend Sub connect()
If Intilize() Then
MsgBox ("Initialization")
'Call upgrade
Else
MsgBox ("failed initilize")
End If
End Sub

Private Sub Command2_Click()
Call Upgrade
End Sub

please help which option we need to set so that after upgradation attribute values should not get removed

Thanks in Advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top