Context: MEGA 2009 SP5
The introduction of a field (drag&drop of a MEGA Object) into a comment or a textual property modifies the "Referenced Object" link to indicates what MEGA object is referenced in the comment.
This mechanism works properly with the GUI (property pages dialog box).
Changing the comment via API does not modify the Reference Object.
My trail is doing something like
- oMyObject.getProp("Comment") = "a big text with this field ~ZTZERTZERTE[My Referenced Object]"
Is there a proper way to update a comment via API and ensures that the 'Referenced Object' link is updated accordingly?
I think that you should create the link.
For example :
' Introduce the object oObj2 in comment's oObj1 oObj1.GetProp("Comment") = "blabla ~c4MwxK0R5jE0[oObj2] blabla" ' Introduce the object oObj2 in collection's oObj1 oObj1.GetCollection("Referenced Object").Add MegaRoot.GetObjectFromId("~c4MwxK0R5jE0[oObj2]")
I hope that this answer will help you.
Thank for the reply.
My concern is there are multiple situations to manage that are probably already handled by the tool:
- Example The object already references 10 objects before the update.
Should I remove all of them before creating the links?
How can I be sure these 10 objects are due to the comment property and not another text in the source object?
I suggest that you use the basic functions from vb like "InStr" :
For Each oObj in myObjToCheck.GetCollection("Referenced Object") ' Use of GetFormated to get the text with the form "~absID[ObjName]" If Instr(myObjToCheck.GetFormated("Comment","Field"), "~" & oObj.GetProp("Absolute Identifier") & "[" & oObj.ShortName & "]") = 0 Then ' UnLink with Remove on the object (obtained from GetCollection) oObj.Remove End If Next
What kind of updates are you trying to perform on the comment?
We have a program to do update comments, however it's done in word. The comment is extracted to word and the updates are performed there, when they are uploaded again this is done as an RTF field and this allows us to safeguard the referenced objects and any formatting in the text.
If I understand
This links is calculated by parsing the text. This is not done in interactive mode when using the text editor.
I am not aware of an API function that enables to trigger the calculation at object level.
However, there is a conversion tool in Administration.exe that triggers the calculation for the whole repository
It should be possible to call the conversion tool using API script (Administration API)
Note that this can be time consuming.