Java API:Global Picklists
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
- <syntaxhighlight lang="java" enclose="div">
String addGlobalPicklist(GlobalPicklistBean bean) throws Exception
</syntaxhighlight>
- Parameters
-
- com.platform.beans.GlobalPicklistBean - The object that defines the picklist.
- 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'.
- <syntaxhighlight lang="java" enclose="div">
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) {
...
} </syntaxhighlight>
Searching for Global Picklists
Search for Global Picklists that match specified criteria.
- Syntax
- <syntaxhighlight lang="java" enclose="div">
List searchGlobalPicklists(SearchContext searchContext) throws Exception
</syntaxhighlight>
- Parameters
-
- searchContext - The object that specifies search criteria.
- Returns
-
- A List of search results.
- Throws
- Exception
- Example
- This example ....
- <syntaxhighlight lang="java" enclose="div">
try {
SearchContext context = new SearchContext(); // ...set criteria... List results = Functions.searchGlobalPicklists(context);
} catch (Exception e) {
...
} </syntaxhighlight>
Getting a Global Picklist
Retrieve details of a Global Picklist and it's Enumerated values.
- Syntax
- <syntaxhighlight lang="java" enclose="div">
GlobalPicklistBean getGlobalPicklist(String id) throws Exception
</syntaxhighlight>
- 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.
- <syntaxhighlight lang="java" enclose="div">
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) {
...
} </syntaxhighlight>
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
- <syntaxhighlight lang="java" enclose="div">
String updateGlobalPicklist(GlobalPicklistBean bean, String id) throws Exception
</syntaxhighlight>
- Parameters
-
- com.platform.beans.GlobalPicklistBean - The object the specifies the global picklist
- id - The id of the global picklist to replace
- Returns
- A string containing the id of the global picklist
- Throws
- Exception
- Example
- This example ....
- <syntaxhighlight lang="java" enclose="div">
try {
String id = "rty345uty678"; GlobalPicklistBean bean = Functions.getGlobalPicklist(id); bean.setSortFlag(false); //...make other changes... Functions.updateGlobalPicklist(bean, id);
} catch (Exception e) {
...
} </syntaxhighlight>
- 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
- <syntaxhighlight lang="java" enclose="div">
void deleteGlobalPicklist(String id) throws exception
</syntaxhighlight>
- Parameters
-
- id - The picklist identifier
- Returns
- void
- Throws
- Exception
- Example
- This example deletes a picklist with a known ID.
- <syntaxhighlight lang="java" enclose="div">
try {
String id = "9610428a58bc4af3ab66032dae4fd0ae"; Functions.deleteGlobalPicklist(id);
} catch (Exception e) {
...
} </syntaxhighlight>