AgileApps Support Wiki Pre Release

Object Metadata

From AgileApps Support Wiki
Revision as of 00:22, 16 October 2014 by imported>Aeric (→‎getObjectMetaData)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
<syntaxhighlight lang="java" enclose="div">

Logger.info("Initiate Object Meta Data Retrieval", "Metadata"); CustomObjectMetaDataBean comdb = Functions.getObjectMetaData(String objectName) Logger.info(("Object Display Title : "+ comdb.getDisplayTitle(), "Metadata"); </syntaxhighlight>

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
<syntaxhighlight lang="java" enclose="div">

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");
   }

</syntaxhighlight>

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
<syntaxhighlight lang="java" enclose="div">

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"); </syntaxhighlight>

updateObjectMetaData

Description
Updates an object and returns the id of the updated object
Syntax
String Functions.updateObjectMetaData(CustomObjectMetaDataBean comdb)
Example
<syntaxhighlight lang="java" enclose="div">

CustomObjectMetaDataBean omdb = Functions.getObjectMetaData("API_OBJ"); omdb.setDisplayTitle("JAPIOBJ"); Functions.updateObjectMetaData(omdb); </syntaxhighlight>

deleteObjectMetaData

Description
Deletes an object
Syntax
Functions.deleteObjectMetaData(CustomObjectMetaDataBean comdb)
Example
<syntaxhighlight lang="java" enclose="div">

Functions.deleteObjectMetaData( Functions.getObjectMetaData("API_OBJ")); </syntaxhighlight>

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
<syntaxhighlight lang="java" enclose="div">

RecordLocatorBean rlb = Functions.getRecordLocator(String objectName); </syntaxhighlight>

Parameters
objectName - The object name or identifier.
Returns
RecordLocatorBean
Throws
Exception
Example
<syntaxhighlight lang="java" enclose="div">

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;

} </syntaxhighlight>

updateRecordLocator

Modify an object's Record Locator Settings:

Syntax
<syntaxhighlight lang="java" enclose="div">

String objectId = Functions.updateRecordLocator(RecordLocatorBean rlb); </syntaxhighlight>

Parameters
RecordLocatorBean - The object with the values to store.
Returns
A string containing the ID of the updated object
Throws
Exception
Example
<syntaxhighlight lang="java" enclose="div">

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;

} </syntaxhighlight>