17-02-2014 01:54 PM
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?
Thanks
24-02-2014 02:01 PM
Hello Dominique
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
See http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=50120000000mqrvAAA
It should be possible to call the conversion tool using API script (Administration API)
See http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=50120000000mqReAAI
Note that this can be time consuming.
24-02-2014 11:14 AM
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.
19-02-2014 11:53 AM - edited 19-02-2014 12:46 PM
Hi,
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
18-02-2014 01:44 PM
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?
18-02-2014 09:57 AM
hi,
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.