AgileApps Support Wiki Pre Release

Java API:Global Picklists

From AgileApps Support Wiki

These APIs let you add, update, delete, list, and query Global Picklists using the Java APIs.

These beans are used in the APIs:

Adding a Global Picklist

Create a new Global Picklist.

Syntax
  String addGlobalPicklist(GlobalPicklistBean bean) throws Exception
Parameters
Returns
A string containing the ID of the new global picklist.
Throws
Exception
Example
This example creates a new Global Picklist ('Order Status'), with two enumerated values - 'New' and 'Processed'.
import com.platform.beans.*;
import com.platform.beans.EnumerationDetailsBean.EnumerationItemBean;
...

try {
  GlobalPicklistBean bean = new GlobalPicklistBean();
  bean.setTitle ("Order Status");
  bean.setDescription ("Picklist to track the status of an Order");
  bean.setShowFirstValueAsDefault(true);    
  bean.setSortFlag(true);
  bean.setAllowSubscriberToModify(true);
  bean.setAllowSubscriberToDelete(false);
  bean.setAllowSubscriberToAdd(true);

  List<EnumerationItemBean> items = new ArrayList<EnumerationItemBean>();
  EnumerationItemBean item1 = new EnumerationItemBean();
  item1.setPicklistValue("1");
  item1.setPicklistLabel("New");
  item1.setTextColor("#FFFFFF");
  item1.setTextBgColor("#000000");
  item1.setShowOnlyImage(false);
  item1.setFlagIsOptgroup(false);
  items.add(item1);

  EnumerationItemBean item2 = new EnumerationItemBean();
  item2.setPicklistValue("2");
  item2.setPicklistLabel("Processed");
  item2.setTextColor("#FFFFFF");
  item2.setTextBgColor("#000000");
  item2.setShowOnlyImage(false);
  item2.setFlagIsOptgroup(false);    
  items.add(item2);

  bean.setEnumerationItems(items);
  String id = Functions.addGlobalPicklist(bean);  
}
catch (Exception e) {
  ...
}


Searching for Global Picklists

Search for Global Picklists that match specified criteria.

Syntax
  List searchGlobalPicklists(SearchContext searchContext) throws Exception
Parameters
  • searchContext - The object that specifies search criteria.
Returns
  • A List of search results.
Throws
Exception
Example
This example ....
try {
  SearchContext context = new SearchContext();
  // ...set criteria...
  List results = Functions.searchGlobalPicklists(context); 
}
catch (Exception e) {
  ...
}


Getting a Global Picklist

Retrieve details of a Global Picklist and it's Enumerated values.

Syntax
  GlobalPicklistBean getGlobalPicklist(String id) throws Exception
Parameters
id
The global picklist identifier
Returns
com.platform.beans.GlobalPicklistBean containing the global picklist specification
Throws
Exception
Example
This example lists the enumeration values for a global picklist.
try {
  String id = "wer567uty789";
  GlobalPicklistBean bean = Functions.getGlobalPicklist("wer567uty789");
  String title = bean.getTitle();
  List<EnumerationItemBean> items = bean.getEnumerationItems();
  for (EnumerationItemBean e : items )
  {
     Logger.info("Label : " + e.getPicklistLabel() 
              + " Value : " + e.getPicklistValue(), "Global Picklist");
  }
}
catch (Exception e) {
  ...
}


Updating a Global Picklist

Update the attributes of a Global Picklist or its enumerated items. (This API replaces the existing definition with a new one.)

Syntax
  String updateGlobalPicklist(GlobalPicklistBean bean, String id) throws Exception
Parameters
Returns
A string containing the id of the global picklist
Throws
Exception
Example
This example ....
try {
  String id = "rty345uty678";
  GlobalPicklistBean bean = Functions.getGlobalPicklist(id);
  bean.setSortFlag(false);
    //...make other changes...
  Functions.updateGlobalPicklist(bean, id);
}
catch (Exception e) {
  ...
}
Note: The API returns the ID as a string, but that value is typically ignored, since it had to be known in order to do an update in the first place.


Deleting a Global Picklist

Delete a Global Picklist.

Syntax
  void deleteGlobalPicklist(String id) throws exception
Parameters
  • id - The picklist identifier
Returns
void
Throws
Exception
Example
This example deletes a picklist with a known ID.
try {
  String id = "9610428a58bc4af3ab66032dae4fd0ae";
  Functions.deleteGlobalPicklist(id);
}
catch (Exception e) {
  ...
}