Difference between revisions of "Java API Cheatsheet"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 165: Line 165:
|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatCurrency(java.lang.String,%20int) <tt>formatCurrency(String value, int precision)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatCurrency(java.lang.String,%20int) <tt>formatCurrency(String value, int precision)</tt>]
| Convert a value specified in U.S. English with no currency character and no grouping indicators (commas), and with a decimal point for fractional amounts.
| Convert a value specified in [[Database Format]] with no currency character and no grouping indicators (commas), and with a decimal point for fractional amounts.
| Return a String with the value formatted using the company's locale setting for currencies, with the number of decimal places specified for the <tt>precision</tt>.
| Return a String with the value formatted using the company's locale setting for currencies, with the number of decimal places specified for the <tt>precision</tt>. If the conversion fails, return the original string.


|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatNumber(java.lang.String,%20int) <tt>formatNumber(String value, int precision)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatNumber(java.lang.String,%20int) <tt>formatNumber(String value, int precision)</tt>]
| Convert a value specified in U.S. English with no grouping indicators (commas), with a decimal point for fractional amounts.
| Convert a value specified in [[Database Format]] with no grouping indicators (commas), with a decimal point for fractional amounts.
| Return a String with the value formatted using the user's locale, with the number of decimal places specified for the <tt>precision</tt>.
| Return a String with the value formatted using the user's locale, with the number of decimal places specified for the <tt>precision</tt>. If the conversion fails, return the original string.


|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatPercent(java.lang.String,%20int) <tt>formatPercent(String value, int precision)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#formatPercent(java.lang.String,%20int) <tt>formatPercent(String value, int precision)</tt>]
| Convert a value specified in U.S. English with no percent sign, no grouping indicators (commas), and with a decimal point for fractional amounts.
| Convert a value specified in [[Database Format]] with no percent sign, no grouping indicators (commas), and with a decimal point for fractional amounts.
| Return a String with the value formatted using the user's locale, with the number of decimal places specified for the <tt>precision</tt>.
| Return a String with the value formatted using the user's locale, with the number of decimal places specified for the <tt>precision</tt>. If the conversion fails, return the original string.


|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parseCurrency(java.lang.String) <tt>parseCurrency(String value)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parseCurrency(java.lang.String) <tt>parseCurrency(String value)</tt>]
| Parse a currency amount in the format specified by the company's locale setting for currencies.
| Parse a currency amount in the format specified by the company's locale setting for currencies.
| Return a String in U.S. English format. Throw an exception if parsing fails.
| Return a String in [[Database Format]] format. If parsing fails, return the original string.


|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parseNumber(java.lang.String) <tt>parseNumber(String value)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parseNumber(java.lang.String) <tt>parseNumber(String value)</tt>]
| Parse a numeric amount (with or without a fractional amount) in the format specified by the user's locale.
| Parse a numeric amount (with or without a fractional amount) in the format specified by the user's locale.
| Return a String in U.S. English format. Throw an exception if parsing fails.
| Return a String in [[Database Format]] format. If parsing fails, return the original string.


|-
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parsePercent(java.lang.String) <tt>parsePercent(String value)</tt>]
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#parsePercent(java.lang.String) <tt>parsePercent(String value)</tt>]
| Parse a percentage in the format specified by the user's locale.
| Parse a percentage in the format specified by the user's locale.
| Return a String in U.S. English format. Throw an exception if parsing fails.
| Return a String in [[Database Format]] format. If parsing fails, return the original string.


|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#validateCurrency(java.lang.String) <tt>validateCurrency(String value)</tt>]
| Verify that the currency amount is in the format specified by the company's locale setting for currencies.
| Return <tt>true</tt> if the data is in the expected format, otherwise <tt>false</tt>.
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#validateNumber(java.lang.String) <tt>validateNumber(String value)</tt>]
| Verify that the numeric amount (with or without a fractional amount) is in the format specified by the user's locale.
| Return <tt>true</tt> if the data is in the expected format, otherwise <tt>false</tt>.
|-
| [{{DOCHOST}}/javadocs/com/platform/api/Functions.html#validatePercent(java.lang.String) <tt>validatePercent(String value)</tt>]
| Verify that the percentage is in the format specified by the user's locale.
| Return <tt>true</tt> if the data is in the expected format, otherwise <tt>false</tt>.
|}
|}



Revision as of 02:34, 23 August 2013

These APIs are defined in the Functions class.

Record Handling

Syntax Description Return Category
addRecord(String objectName, Params params) Adds a new record of type objectId with values from params Result object Record Handling
updateRecord(String objectName, String recordId, Params params) Updates record of type objectId with values params. The Record is identified by recordId Result object Record Handling
changeOwnerShipInfo(String object_id, String record_id, String owner_id) Changes the owner of the designated record None Record Handling
deleteRecord(String objectName, String recordId) Deletes Record of type objectId where id is recordId Result object Record Handling
getRecord(String objectName, String fields, String recordId) Gets the record of type objectId identified by recordId. fields is a comma separated list of fields that you want to fetch Result object Record Handling
getRecordCount(String objectName, String criteria) Returns the number of records in the object int Record Handling
searchRecords(String objectName, String fields, String criteria [, Parameters params]) Search and retrieve the records for an object. fields is a comma-separated list of fields to fetch. criteria is a Filter Expression Result object Record Handling
searchRecords(String objectName, String fields, String criteria, String sortBy, String sortOrder, String sortBy2, String sortOrder2, int offset, int numberOfRows [, Parameters params]) Search and retrieve records for an object. fields is a comma-separated list of fields to fetch. criteria is a Filter Expression Result object Record Handling
execSQL(String query) Execute a SQL query Result object Record Handling
getRecord(String compositeObject, String fields, String recordId) Get a [{Composite Object]] record, with specified fields. Result object Composite Objects
getRecordCount(String compositeObject, String criteria) Gets a count of records in a Composite Object that match specified filtering criteria. int Composite Objects
searchRecords(String compositeObject, String fields, String criteria [, Parameters params]) Search and retrieve Composite Object records. fields is a comma-separated list of fields to fetch. criteria is a Filter Expression Result object Composite Objects
searchRecords(String compositeObject, String fields, String criteria, String sortBy, String sortOrder, String sortBy2, String sortOrder2, int offset, int numberOfRows [, Parameters params]) Search and retrieve Composite Object records. fields is a comma-separated list of fields to fetch. criteria is a Filter Expression Result object Composite Objects


Email and Document Management

Syntax Description Return Category
sendEmail(String objectName, String id, String to, String cc, String subject, String body, String attachmentTemplateId, String attachmentIdList) Sends an Email Result object Email and Document Management
sendEmailUsingTemplate(String objectName, String recordId, String to, String cc, String subject, String bodyTemplateId, String attachmentTemplateId, String attachmentIdList) Sends an Email evaluating Template identified by bodyTemplateId as email body Result object Email and Document Management
generateDocument(String objectName, String recordId, String templateId, String format) Generates document of templateId evaluated with params in format. If format is "PDF" it generates the document in PDF format, otherwise HTML format. It relates this generated document to object of type objectId and record with id recordId Result object Email and Document Management



Transaction Management

Syntax Description Return Category
addSavePoint(String name) Adds a Save Point with name None Utility functions
doesSavePointExist(String name) checks whether the named save point exists or not Boolean Utility functions
getAllSavePoints() Returns All Save Points Set Utility functions
rollback() Roll backs all the inserts and updates None Utility functions
rollbackToSavePoint(String name) Rollback to specific save point with name None Utility functions
removeSavePoint(String name) removes save point with name from save point list None Utility functions


Localization Functions

Functions class (static methods):

Syntax Description Return
formatCurrency(String value, int precision) Convert a value specified in Database Format with no currency character and no grouping indicators (commas), and with a decimal point for fractional amounts. Return a String with the value formatted using the company's locale setting for currencies, with the number of decimal places specified for the precision. If the conversion fails, return the original string.
formatNumber(String value, int precision) Convert a value specified in Database Format with no grouping indicators (commas), with a decimal point for fractional amounts. Return a String with the value formatted using the user's locale, with the number of decimal places specified for the precision. If the conversion fails, return the original string.
formatPercent(String value, int precision) Convert a value specified in Database Format with no percent sign, no grouping indicators (commas), and with a decimal point for fractional amounts. Return a String with the value formatted using the user's locale, with the number of decimal places specified for the precision. If the conversion fails, return the original string.
parseCurrency(String value) Parse a currency amount in the format specified by the company's locale setting for currencies. Return a String in Database Format format. If parsing fails, return the original string.
parseNumber(String value) Parse a numeric amount (with or without a fractional amount) in the format specified by the user's locale. Return a String in Database Format format. If parsing fails, return the original string.
parsePercent(String value) Parse a percentage in the format specified by the user's locale. Return a String in Database Format format. If parsing fails, return the original string.
validateCurrency(String value) Verify that the currency amount is in the format specified by the company's locale setting for currencies. Return true if the data is in the expected format, otherwise false.
validateNumber(String value) Verify that the numeric amount (with or without a fractional amount) is in the format specified by the user's locale. Return true if the data is in the expected format, otherwise false.
validatePercent(String value) Verify that the percentage is in the format specified by the user's locale. Return true if the data is in the expected format, otherwise false.

Additional Utility Functions

Static Utility functions in the Functions class:

Syntax Description Return
Deprecated Use Logger class.
   (See Debug Log)
debug(Object obj)
Puts a debug statement into the debug log for Object obj. (obj can be a String) None
getEnv(String key) Gets the environment variable value for the key The value of the environment variable
getParametersInstance() Gets an instance of Parameters class Parameters object
setTargetPage(String url) Sets the target page None
showMessage(long millisecs) Displays message None
sleep(String message) Sleeps for the designated number of milliseconds. None
throwError(String message) Throws error with the message None


ServiceConfiguration class (static methods):

Syntax Return Type Description
getServiceName(); String Returns the Service Name (e.g. company name)
getServiceDomainURL(); String Returns the Service URL.


Metadata Management

Syntax Description Return Category
getObjectMetaData(String objectName) Retrieve metadata from a Custom Objects. CustomObjectMetaDataBean Customize
getObjectMetaDataMap() Return a map of all visible Custom Object object metadata records, indexed by object ID. Map: Object ID => CustomObjectMetaDataBean Customize
addObjectMetaData(CustomObjectMetaDataBean) Create a new object. String:Object ID Customize
updateObjectMetaData(CustomObjectMetaDataBean) Modify an object definition. String: Object ID Customize
deleteObjectMetaData(CustomObjectMetaDataBean) Deletes an object None Customize
getRecordLocator(String objectName) Get an object's Record Locator information. RecordLocatorBean Customize
updateRecordLocator(RecordLocatorBean) Modify an object's Record Locator Settings. String:Object ID Customize