Object Metadata

From AgileApps Support Wiki
Learn more: Java API:Customize

Object metadata is the data that describes an object--it's name, for example, and it's ID.

getObjectMetaData

Description
Retrieves metadata from Custom Objects; not available for System Objects
Syntax
CustomObjectMetaDataBean Functions.getObjectMetaData(String objectName)
       /* where objectName is the Custom Object name */
Example
Logger.info("Initiate Object Meta Data Retrieval", "Metadata");
CustomObjectMetaDataBean comdb = Functions.getObjectMetaData(String objectName) 
Logger.info(("Object Display Title : "+ comdb.getDisplayTitle(), "Metadata");

getObjectMetaDataMap

Description
Returns a map of all visible Custom Objects with object_id as the key and the corresponding object's metadata as a value
Syntax
Map Functions.getObjectMetaDataMap()
Example
Logger.info("Initiate Object Meta Data Retrieval", "Metadata");
Map  comdbCollection = Functions.getObjectMetaDataMap() 
for(Map.Entry e:comdbCollection.entrySet())
    {
    CustomObjectMetaDataBean bean = e.getValue();
    Logger.info("Object ID :" + e.getKey(), "Metadata");
    Logger.info(" Object Display Title:" + bean.getDisplayTitle(), "Metadata");
    }

addObjectMetaData

Description
Adds an object and returns the id of the newly created object
Syntax
String Functions.addObjectMetaData(CustomObjectMetaDataBean comdb)
Considerations
  • Object names:
  • Must start with an alphabetic character.
  • May contain only alphanumeric (a-z A-Z 0-9) and underscores (_).
  • May not contain spaces or other characters.
  • Must be 32 characters or less.
Example
Logger.info("Initiate Add object", "Metadata");
CustomObjectMetaDataBean omdb = new CustomObjectMetaDataBean ();
omdb.setDisplayTitle("JAVA API OBJECT");
omdb.setSingluarDisplayTitle("JAVA API OBJECT");
omdb.setBuiltIn(false);
omdb.setNameColumn("name");
omdb.setWebTab(false);
omdb.setObjectName("API_OBJ");
String new_object_id = Functions.addObjectMetaData(omdb);
Logger.info("Added an object:"+new_object_id, "Metadata");

updateObjectMetaData

Description
Updates an object and returns the id of the updated object
Syntax
String Functions.updateObjectMetaData(CustomObjectMetaDataBean comdb)
Example
CustomObjectMetaDataBean omdb = Functions.getObjectMetaData("API_OBJ");
omdb.setDisplayTitle("JAPIOBJ");
Functions.updateObjectMetaData(omdb);

deleteObjectMetaData

Description
Deletes an object
Syntax
Functions.deleteObjectMetaData(CustomObjectMetaDataBean comdb)
Example
Functions.deleteObjectMetaData( Functions.getObjectMetaData("API_OBJ"));

getRecordLocator

Get a record locator bean from the specified object, which contains the Key, Lookup, and Search settings,
where:

  • Key - The concatenation of fields that constitutes the Record_Locator#Search_Fields examined by the platform when searching for records.
  • Search - The concatenation of fields that constitutes the Lookup and Search Results fields that are displayed to the user during a search or Lookup.
  • Lookup - The concatenation of fields that constitutes the record identifier, displayed as the value of a Lookup field after a selection has been made.
Syntax
RecordLocatorBean rlb = Functions.getRecordLocator(String objectName);
Parameters
objectName - The object name or identifier.
Returns
RecordLocatorBean
Throws
Exception
Example
public Map testGetLookupRecordLocatorColumns() throws Exception
{
RecordLocatorBean rb =  Functions.getRecordLocator("Students");
    Map<String, String> m = new HashMap<String, String>();
    String lookupString = "";
    for(String s : rb.getLookupColumns())
    {
        lookupString = lookupString + s;
    }
    m.put("lookupColumnsRecordLocator",lookupString);
    return m;
}

updateRecordLocator

Modify an object's Record Locator Settings:

Syntax
String objectId = Functions.updateRecordLocator(RecordLocatorBean rlb);
Parameters
RecordLocatorBean - The object with the values to store.
Returns
A string containing the ID of the updated object
Throws
Exception
Example
public Map testUpdateSearchRecordLocator() throws Exception
{
 RecordLocatorBean rlb = Functions.getRecordLocator("Students");
     Map<String, String> m = new HashMap<String, String> ();
     List<String> looklist = new ArrayList<String>();
     looklist.add("emergency_phone");
     looklist.add("student_name");
     rlb.setSearchColumns(looklist);
     Functions.updateRecordLocator(rlb);

     String lookupString = "";
     for (String s: rlb.getLookupColumns())
     {
         lookupString = lookupString + s;
     }
     m.put("updatedSearchColumnsRecordLocator", lookupString);
     return m;
}