cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Java API-Modifying Object properties

jrad
Contributor

 Hello community,

 

I need help to access and modify objects properties with Java API.  My MEGA project contains Org-Unit. I need to access the property value of an Org-Unit and modify its Meta Attribute Property value.  Following my code:

 

            /*Get the project identifier*/
            String strProjectField = mgRoot.getCollection("~qekPESs3iG30[Project]").get("P").megaField();
            
            /*Get collection of Org-Unit objects in the project*/
            MegaCollection mgcolOperations = mgRoot.getCollection("~qekPESs3iG30[Project]").get(strProjectField).getCollection("Org-unit");
           
                        
             /*Get object identifier*/
             String object1Field = mgcolOperations.get(1).megaField();
             
             /*Get collection of Property Value in the object*/
              MegaCollection mgcolOperations2 = mgcolOperations.get(object1Field).getCollection("~9ce3X4H4AHM0[Property Value]");
            
             /*Get Property Value*/
             MegaObject objVal = mgcolOperations2.get(1);
             
             /*Get attribute property value*/
             MegaAttribute att1 = objVal.getAttribute("Property Value");
             
             /*Modify property value*/
             att1.setValue("9");

 

Thank you for your help!

1 Reply

alros
Super Contributor

Our API codes use

 

MegaObject.setProp(propertyName, value)

MegaObject#getProp(propertyName)

 

to set / get a specific MetaAttribute of a MegaObject.