cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Comment by API including Referenced Object mechanism

Highlighted
New Contributor

How to change Comment by API including Referenced Object mechanism

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

 

Tags (4)
5 Replies
Occasional Contributor

Re: How to change Comment by API including Referenced Object mechanism

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.

 

New Contributor

Re: How to change Comment by API including Referenced Object mechanism

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?

Occasional Contributor

Re: How to change Comment by API including Referenced Object mechanism

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
Regular Contributor

Re: How to change Comment by API including Referenced Object mechanism

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.

 

 

MEGA

Re: How to change Comment by API including Referenced Object mechanism

Hello Dominique

 

If I understand

  • You have a tool that reprocesses the value of texts in Rich Text Format (example 'Comment') and changes the value of MEGA fields (ex: ~YmNPvEdx8vS4[IT Employee]) using API script
  • You state that the impact analysis links (Referenced Object) around the object are not updated automatically

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.

Jerome