text
stringlengths
24
5.1k
on external object records generates an array of objects of type datasource.upsertresult. its methods create result records that indicate whether the upsert operation succeeded or failed. 2162apex reference guide upsertresult class in this section: upsertresult properties upsertresult methods upsertresult properties the following are properties for upsertresult. in this section: errormessage the error message that’s generated by a failed upsert operation. externalid the unique identifier of a row that represents an external object record to upsert. success indicates whether a delete operation succeeded or failed. errormessage the error message that’s generated by a failed upsert operation. signature public string errormessage {get; set;} property value type: string externalid the unique identifier of a row that represents an external object record to upsert. signature public string externalid {get; set;} property value type: string success indicates whether a delete operation succeeded or failed. signature public boolean success {get; set;} 2163apex reference guide upsertresult class property value type: boolean upsertresult methods the following are methods for upsertresult. in this section: equals(obj) maintains the integrity of lists of type upsertresult by determining the equality of external object records in a list. this method is dynamic and is based on the equals method in java. failure(externalid, errormessage) creates an upsert result that indicates the failure of a delete request for a given external id. hashcode() maintains the integrity of lists of type upsertresult by determining the uniqueness of the external object records in a list. success(externalid) creates a delete result that indicates the successful completion of an upsert request for a given external id. equals(obj) maintains the integrity of lists of type upsertresult by determining the equality of external object records in a list. this method is dynamic and is based on the equals method in java. signature public boolean equals(object obj) parameters obj type: object external object whose key is to be validated. return value type: boolean failure(externalid, errormessage) creates an upsert result that indicates the failure of a delete request for a given external id. signature public static datasource.upsertresult failure(string externalid, string errormessage) 2164apex reference guide datasource exceptions parameters externalid type: string the unique identifier of the external object record to upsert. errormessage type: string the reason the upsert operation failed. return value type: datasource.upsertresult status result for the upsert operation. hashcode() maintains the integrity of lists of type upsertresult by determining the uniqueness of the external object records in a list. signature public integer hashcode() return value type: integer success(externalid) creates a delete result that indicates the successful completion of an upsert request for a given external id. signature public static datasource.upsertresult success(string externalid) parameters externalid type: string the unique identifier of the external object record to upsert. return value type: datasource.upsertresult status result of the upsert operation for the external object record with the given external id. datasource exceptions the datasource namespace contains exception classes. 2165apex reference guide dataweave namespace (beta) all exception classes support built-in methods for returning the error message and exception type. see exception class and built-in exceptions. the datasource namespace contains these exceptions. exception description methods datasource.datasourceexception throw this exception to indicate that an to get the error message and write it error occurred while communicating with to debug log, use the string an external data source. getmessage(). datasource.oauthtokenexpiredexception throw this exception to indicate that an to get the error message and write it oauth token has expired. the system then to debug log, use the string attempts to refresh the token getmessage(). automatically and restart the query, search, or sync operation. dataweave namespace (beta) the dataweave namespace provides classes and methods to support the invocation of dataweave scripts from apex. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms
provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. dataweave class methods are supported only in scratch orgs that have the dataweaveinapex feature enabled. dataweave in apex doesn’t support packaging. dataweave is the mulesoft expression language for accessing, parsing, and transforming data that travels through a mule application. for detailed information, see dataweave language. these are the classes in the dataweave namespace. in this section: result class contains methods to retrieve data that was transformed using script class methods. script class contains the createscript() method to load dataweave scripts and the execute() method to obtain script output in a dataweave.result object. see also: dataweave in apex result class contains methods to retrieve data that was transformed using script class methods. 2166apex reference guide result class note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. namespace dataweave example see script class for an example to run a dataweave script from apex and retrieve the resulting script output. in this section: result methods result methods the following are methods for result. in this section: getvalue() returns the result of a dataweave script execution as an object. getvalueasstring() returns the result of a dataweave script execution as a string value. getvalue() returns the result of a dataweave script execution as an object. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. signature public object getvalue() return value type: object getvalueasstring() returns the result of a dataweave script execution as a string value. 2167apex reference guide script class note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. signature public string getvalueasstring() return value type: string script class contains the createscript() method to load dataweave scripts and the execute() method to obtain script output in a dataweave.result object. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. namespace dataweave this example runs a dataweave script from apex and retrieves the resulting script output. first deploy the script to the org as contactstojson.dwl. %dw 2.0 input records application/java output application/json --- { users: records map(record) -> { firstname: record.firstname, lastname: record.lastname } then, execute the script from apex. list<contact> data = [select firstname, lastname from contact where lastname limit 5]; map<string,
object> args = new map<string, object>{ 'records' => data }; dataweave.script script = dataweave.script.createscript('contactstojson'); dataweave.result result = script.execute(args); string jsonoutput = result.getvalueasstring(); in this section: script methods 2168apex reference guide script class script methods the following are methods for script. in this section: createscript(scriptname) loads a dataweave 2.0 script from the .dwl metadata file that is deployed in an org. the script can then be run using the script.execute method. createscript(namespace, scriptname) loads a dataweave 2.0 script from a specified namespace. the script can then be run using the script.execute method. execute(parameters) executes the dataweave script that is loaded using the createscript() method and returns the script output. tostring() returns the name of the script. createscript(scriptname) loads a dataweave 2.0 script from the .dwl metadata file that is deployed in an org. the script can then be run using the script.execute method. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. signature public static createscript(string scriptname) parameters scriptname type: string the name of the deployed metadata .dwl script (not including the file extension). return value type: dataweave.script dataweave script that is used as a parameter in the script.execute() method. createscript(namespace, scriptname) loads a dataweave 2.0 script from a specified namespace. the script can then be run using the script.execute method. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. 2169apex reference guide script class signature public static dataweave.script createscript(string namespace, string scriptname) parameters namespace type: string the namespace name for the deployed script. if the namespace name is null, the caller namespace is used. if the namespace name is empty, the org namespace is used. scriptname type: string the name of the deployed metadata .dwl script (not including the file extension). return value type: dataweave.script dataweave script that is used as a parameter in the script.execute() method. execute(parameters) executes the dataweave script that is loaded using the createscript() method and returns the script output. note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. signature public execute(map<string,object> parameters) parameters parameters type: map<string,object> input to the dataweave script. the keys correspond to the input directive names defined in the dataweave header. see input directive and dataweave header. return value type: dataweave.result the dataweave.result object contains the script output. tostring() returns the name of the script. 2170apex reference guide dom namespace note: this feature is a beta service. customer may opt to try such beta service in its sole discretion. any use of the beta service is subject to the applicable beta services terms provided at agreements and terms. you can provide feedback and suggestions for
the dataweave in apex feature in the trailblazer community. the beta release of dataweave in apex supports packaging of dataweave scripts within a namespace. however, you can only access scripts within a package, not across different namespaces. signature public string tostring() return value type: string dom namespace the dom namespace provides classes and methods for parsing and creating xml content. the following are the classes in the dom namespace. in this section: document class use the document class to process xml content. you can parse nested xml content that’s up to 50 nodes deep. xmlnode class use the xmlnode class to work with a node in an xml document. document class use the document class to process xml content. you can parse nested xml content that’s up to 50 nodes deep. namespace dom usage one common application is to use it to create the body of a request for httprequest or to parse a response accessed by httpresponse. in this section: document constructors document methods see also: reading and writing xml using the dom 2171apex reference guide document class document constructors the following are constructors for document. in this section: document() creates a new instance of the dom.document class. document() creates a new instance of the dom.document class. signature public document() document methods the following are methods for document. all are instance methods. in this section: createrootelement(name, namespace, prefix) creates the top-level root element for a document. getrootelement() returns the top-level root element node in the document. if this method returns null, the root element has not been created yet. load(xml) parse the xml representation of the document specified in the xml argument and load it into a document. toxmlstring() returns the xml representation of the document as a string. createrootelement(name, namespace, prefix) creates the top-level root element for a document. signature public dom.xmlnode createrootelement(string name, string namespace, string prefix) parameters name type: string namespace type: string prefix type: string 2172apex reference guide document class return value type: dom.xmlnode usage for more information about namespaces, see reading and writing xml using the dom. calling this method more than once on a document generates an error as a document can have only one root element. getrootelement() returns the top-level root element node in the document. if this method returns null, the root element has not been created yet. signature public dom.xmlnode getrootelement() return value type: dom.xmlnode load(xml) parse the xml representation of the document specified in the xml argument and load it into a document. signature public void load(string xml) parameters xml type: string return value type: void example dom.document doc = new dom.document(); doc.load(xml); toxmlstring() returns the xml representation of the document as a string. signature public string toxmlstring() 2173apex reference guide xmlnode class return value type: string xmlnode class use the xmlnode class to work with a node in an xml document. namespace dom xmlnode methods the following are methods for xmlnode. all are instance methods. in this section: addchildelement(name, namespace, prefix) creates a child element node for this node. addcommentnode(text) creates a child comment node for this node. addtextnode(text) creates a child text node for this node. getattribute(key, keynamespace) returns namespaceprefix:attributevalue for the given key and key namespace. getattributecount() returns the number of attributes for this node. getattributekeyat(index) returns the attribute key for the given index. index values start at 0. getattributekeynsat(index) returns the attribute key namespace for the given index. getattributevalue(key, keynamespace) returns the attribute value for the given key and key namespace. getattributevaluens(key, keynamespace) returns the attribute value namespace for the given key and key namespace. getchildelement(name, namespace) returns the child element node for the node with the given name and namespace. getchildelements() returns the child element nodes for this node
. this doesn't include child text or comment nodes. getchildren() returns the child nodes for this node. this includes all node types. getname() returns the element name. 2174apex reference guide xmlnode class getnamespace() returns the namespace of the element. getnamespacefor(prefix) returns the namespace of the element for the given prefix. getnodetype() returns the node type. getparent() returns the parent of this element. getprefixfor(namespace) returns the prefix of the given namespace. gettext() returns the text for this node. insertbefore(newchild, refchild) inserts a new child node before the specified node. removeattribute(key, keynamespace) removes the attribute with the given key and key namespace. returns true if successful, false otherwise. removechild(childnode) removes the given child node. setattribute(key, value) sets the key attribute value. setattributens(key, value, keynamespace, valuenamespace) sets the key attribute value. setnamespace(prefix, namespace) sets the namespace for the given prefix. addchildelement(name, namespace, prefix) creates a child element node for this node. signature public dom.xmlnode addchildelement(string name, string namespace, string prefix) parameters name type: string the name argument can't have a null value. namespace type: string prefix type: string 2175apex reference guide xmlnode class return value type: dom.xmlnode usage • if the namespace argument has a non-null value and the prefix argument is null, the namespace is set as the default namespace. • if the prefix argument is null, salesforce automatically assigns a prefix for the element. the format of the automatic prefix is nsi, where i is a number.if the prefix argument is '', the namespace is set as the default namespace. addcommentnode(text) creates a child comment node for this node. signature public dom.xmlnode addcommentnode(string text) parameters text type: string the text argument can't have a null value. return value type: dom.xmlnode addtextnode(text) creates a child text node for this node. signature public dom.xmlnode addtextnode(string text) parameters text type: string the text argument can't have a null value. return value type: dom.xmlnode getattribute(key, keynamespace) returns namespaceprefix:attributevalue for the given key and key namespace. 2176apex reference guide xmlnode class signature public string getattribute(string key, string keynamespace) parameters key type: string keynamespace type: string return value type: string example for example, for the <xyz a:b="c:d" /> element: • getattribute returns c:d • getattributevalue returns d getattributecount() returns the number of attributes for this node. signature public integer getattributecount() return value type: integer getattributekeyat(index) returns the attribute key for the given index. index values start at 0. signature public string getattributekeyat(integer index) parameters index type: integer return value type: string 2177apex reference guide xmlnode class getattributekeynsat(index) returns the attribute key namespace for the given index. signature public string getattributekeynsat(integer index) parameters index type: integer return value type: string getattributevalue(key, keynamespace) returns the attribute value for the given key and key namespace. signature public string getattributevalue(string key, string keynamespace) parameters key type: string keynamespace type: string return value type: string example for example, for the <xyz a:b="c:d" /> element: • getattribute returns c:d • getattributevalue returns d getattributevaluens(key, keynamespace) returns the attribute value namespace for the given key and key namespace. signature public string getattributevaluens(string key, string keynamespace) 2178apex reference guide xmlnode class parameters key type: string keynamespace type: string return value type: string getchildelement(
name, namespace) returns the child element node for the node with the given name and namespace. signature public dom.xmlnode getchildelement(string name, string namespace) parameters name type: string namespace type: string return value type: dom.xmlnode getchildelements() returns the child element nodes for this node. this doesn't include child text or comment nodes. signature public dom.xmlnode[] getchildelements() return value type: dom.xmlnode[] getchildren() returns the child nodes for this node. this includes all node types. signature public dom.xmlnode[] getchildren() 2179apex reference guide xmlnode class return value type: dom.xmlnode[] getname() returns the element name. signature public string getname() return value type: string getnamespace() returns the namespace of the element. signature public string getnamespace() return value type: string getnamespacefor(prefix) returns the namespace of the element for the given prefix. signature public string getnamespacefor(string prefix) parameters prefix type: string return value type: string getnodetype() returns the node type. 2180apex reference guide xmlnode class signature public dom.xmlnodetype getnodetype() return value type: dom.xmlnodetype getparent() returns the parent of this element. signature public dom.xmlnode getparent() return value type: dom.xmlnode getprefixfor(namespace) returns the prefix of the given namespace. signature public string getprefixfor(string namespace) parameters namespace type: string the namespace argument can't have a null value. return value type: string gettext() returns the text for this node. signature public string gettext() return value type: string 2181apex reference guide xmlnode class insertbefore(newchild, refchild) inserts a new child node before the specified node. signature public dom.xmlnode insertbefore(dom.xmlnode newchild, dom.xmlnode refchild) parameters newchild type: dom.xmlnode the node to insert. refchild type: dom.xmlnode the node before the new node. return value type: dom.xmlnode usage • if refchild is null, newchild is inserted at the end of the list. • if refchild doesn't exist, an exception is thrown. removeattribute(key, keynamespace) removes the attribute with the given key and key namespace. returns true if successful, false otherwise. signature public boolean removeattribute(string key, string keynamespace) parameters key type: string keynamespace type: string return value type: boolean removechild(childnode) removes the given child node. 2182
apex reference guide xmlnode class signature public boolean removechild(dom.xmlnode childnode) parameters childnode type: dom.xmlnode return value type: boolean setattribute(key, value) sets the key attribute value. signature public void setattribute(string key, string value) parameters key type: string value type: string return value type: void setattributens(key, value, keynamespace, valuenamespace) sets the key attribute value. signature public void setattributens(string key, string value, string keynamespace, string valuenamespace) parameters key type: string value type: string keynamespace type: string 2183apex reference guide eventbus namespace valuenamespace type: string return value type: void setnamespace(prefix, namespace) sets the namespace for the given prefix. signature public void setnamespace(string prefix, string namespace) parameters prefix type: string namespace type: string return value type: void eventbus namespace the eventbus namespace provides classes and methods for platform events and change data capture events. the following are the classes in the eventbus namespace. in this section: changeeventheader class contains header fields of change data capture events. eventpublishfailurecallback interface implement this interface to track platform event messages that failed to publish. the onfailure() method in this interface is called when the final result of the asynchronous publish operation becomes available. eventpublishsuccesscallback interface implement this interface to track platform event messages that were published successfully. the onsuccess() method in this interface is called when the final result of the asynchronous publish operation becomes available. failureresult interface contains the result of an apex publish callback when the event publishing failed. this interface is used as a parameter in the onfailure method of the eventpublishfailurecallback interface. 2184apex reference guide changeeventheader class successresult interface contains the result of an apex publish callback when the event publishing succeeded. this interface is used as a parameter in the onsuccess method of the eventpublishsuccesscallback interface. testbroker class contains methods that simulate the successful delivery or failed publishing of platform event or change event messages in an apex test. triggercontext class provides information about the platform event or change event trigger that’s currently executing, such as how many times the trigger was retried due to the eventbus.retryableexception. also, provides a method to resume trigger executions. see also: platform events developer guide changeeventheader class contains header fields of change data capture events. namespace eventbus in this section: changeeventheader properties see also: change data capture developer guide changeeventheader properties the following are properties for changeeventheader. in this section: changedfields a list of the fields that were changed in an update operation, including the lastmodifieddate system field. this field is empty for other operations, including record creation. this property is available in apex saved using api version 47.0 or later. changeorigin only populated for changes done by api apps or from lightning experience; empty otherwise. the salesforce api and the api client id that initiated the change, if set by the client. use this field to detect whether your app initiated the change to not process the change again and potentially avoid a deep cycle of changes. changetype the operation that caused the change. 2185apex reference guide changeeventheader class commitnumber the system change number (scn) of a committed transaction, which increases sequentially. this field is provided for diagnostic purposes. the field value is not guaranteed to be unique in salesforce—it is unique only in a single database instance. if your salesforce org migrates to another database instance, the commit number might not be unique or sequential. committimestamp the date and time when the change occurred, represented as the number of milliseconds since january 1, 1970 00:00:00 gmt. commituser the id of the user that ran the change operation. difffields contains the names of fields whose values are sent as a unified diff because they contain large text values. entityname the api name of the standard or custom object that the change pertains to. for example, account or myobject__c. nulledfields contains the names of fields whose values were changed to null in an update operation. use this field in apex change event messages to determine if a field was changed to null in an update
and isn’t an unchanged field. recordids one or more record ids for the changed records. typically, this field contains one record id. if in one transaction the same change occurred in multiple records of the same object type during one second, salesforce merges the change notifications. in this case, salesforce sends one change event for all affected records and the recordids field contains the ids for all records that have the same change. sequencenumber the sequence of the change within a transaction. the sequence number starts from 1. transactionkey a string that uniquely identifies each salesforce transaction. you can use this key to identify and group all changes that were made in the same transaction. changedfields a list of the fields that were changed in an update operation, including the lastmodifieddate system field. this field is empty for other operations, including record creation. this property is available in apex saved using api version 47.0 or later. signature public list<string> changedfields {get; set;} property value type: list<string> changeorigin only populated for changes done by api apps or from lightning experience; empty otherwise. the salesforce api and the api client id that initiated the change, if set by the client. use this field to detect whether your app initiated the change to not process the change again and potentially avoid a deep cycle of changes. 2186apex reference guide changeeventheader class signature public string changeorigin {get; set;} property value type: string the format of the changeorigin field value is: com/salesforce/api/<api_name>/<api_version>;client=<client_id> • <api_name> is the name of the salesforce api used to make the data change. it can take one of these values: soap, rest, bulkapi, xmlrpc, oldsoap, toolingsoap, toolingrest, apex, apexdebuggerrest. • <api_version> is the version of the api call that made the change and is in the format xx.x. • <client_id> is a string that contains the client id of the app that initiated the change. if the client id is not set in the api call, client=<client_id> is not appended to the changeorigin field. example: com/salesforce/api/soap/49.0;client=astro the client id is set in the call options header of an api call. for an example on how to set the call options header, see: • rest api: sforce-call-options header. (bulk api also uses the sforce-call-options header. ) • soap api: calloptions header. (apex api also uses the calloptions element.) changetype the operation that caused the change. signature public string changetype {get; set;} property value type: string can be one of the following values: • create • update • delete • undelete for gap events, the change type starts with the gap_ prefix. • gap_create • gap_update • gap_delete • gap_undelete for overflow events, the change type is gap_overflow. 2187apex reference guide changeeventheader class commitnumber the system change number (scn) of a committed transaction, which increases sequentially. this field is provided for diagnostic purposes. the field value is not guaranteed to be unique in salesforce—it is unique only in a single database instance. if your salesforce org migrates to another database instance, the commit number might not be unique or sequential. signature public long commitnumber {get; set;} property value type: long committimestamp the date and time when the change occurred, represented as the number of milliseconds since january 1, 1970 00:00:00 gmt. signature public long committimestamp {get; set;} property value type: long commituser the id of the user that ran the change operation. signature public string commituser {get; set;} property value type: string difffields contains the names of fields whose values are sent as a unified diff because they contain large text values. signature public list<string> difffields {get; set;} 2188apex reference guide changeeventheader class property value type: list<string> see also: change data capture developer guide: sending data differences for fields of updated records
entityname the api name of the standard or custom object that the change pertains to. for example, account or myobject__c. signature public string entityname {get; set;} property value type: string nulledfields contains the names of fields whose values were changed to null in an update operation. use this field in apex change event messages to determine if a field was changed to null in an update and isn’t an unchanged field. signature public list<string> nulledfields {get; set;} property value type: list<string> recordids one or more record ids for the changed records. typically, this field contains one record id. if in one transaction the same change occurred in multiple records of the same object type during one second, salesforce merges the change notifications. in this case, salesforce sends one change event for all affected records and the recordids field contains the ids for all records that have the same change. signature public list<string> recordids {get; set;} property value type: list<string> examples of operations with same changes are: • update of fielda to valuea in account records. • deletion of account records. • renaming or replacing a picklist value that results in updating the field value in all affected records. 2189apex reference guide eventpublishfailurecallback interface the recordids field can contain a wildcard value when a change event message is generated for custom field type conversions that cause data loss. in this case, the recordids value is the three-character prefix of the object, followed by the wildcard character *. for example, for accounts, the value is 001*. sequencenumber the sequence of the change within a transaction. the sequence number starts from 1. signature public integer sequencenumber {get; set;} property value type: integer a lead conversion is an example of a transaction that can have multiple changes. a lead conversion results in the following sequence of changes, all within the same transaction. 1. create an account 2. create a contact 3. create an opportunity 4. update a lead transactionkey a string that uniquely identifies each salesforce transaction. you can use this key to identify and group all changes that were made in the same transaction. signature public string transactionkey {get; set;} property value type: string eventpublishfailurecallback interface implement this interface to track platform event messages that failed to publish. the onfailure() method in this interface is called when the final result of the asynchronous publish operation becomes available. namespace eventbus usage for more information, see <link>get the result of asynchronous platform event publishing with apex publish callbacks<link/> in the platform events developer guide. 2190apex reference guide eventpublishsuccesscallback interface in this section: eventpublishfailurecallback methods eventpublishfailurecallback example implementation eventpublishfailurecallback methods the following are methods for eventpublishfailurecallback. in this section: onfailure(result) the system invokes this method when the final result of eventbus.publish is available and the publishing of the platform event message failed. onfailure(result) the system invokes this method when the final result of eventbus.publish is available and the publishing of the platform event message failed. signature public void onfailure(eventbus.failureresult result) parameters result type: eventbus.failureresult the final result of eventbus.publish. return value type: void eventpublishfailurecallback example implementation for an example implementation and a test class, see <link>get the result of asynchronous platform event publishing with apex publish callbacks<link/> in the platform events developer guide. eventpublishsuccesscallback interface implement this interface to track platform event messages that were published successfully. the onsuccess() method in this interface is called when the final result of the asynchronous publish operation becomes available. namespace eventbus 2191apex reference guide failureresult interface usage for more information, see <link>get the result of asynchronous platform event publishing with apex publish callbacks<link/> in the platform events developer guide. in this section: eventpublishsuccesscallback methods eventpublishsuccesscallback example implementation eventpublishsuccesscallback methods the following are methods for eventpublishsuccesscallback. in this section: onsuccess(result) the system invokes this method when the final result of eventbus.publish is available and the publishing of the platform event message succeeded. onsuccess(
result) the system invokes this method when the final result of eventbus.publish is available and the publishing of the platform event message succeeded. signature public void onsuccess(eventbus.successresult result) parameters result type: eventbus.successresult the final result of eventbus.publish. return value type: void eventpublishsuccesscallback example implementation for an example implementation and a test class, see <link>get the result of asynchronous platform event publishing with apex publish callbacks<link/> in the platform events developer guide. failureresult interface contains the result of an apex publish callback when the event publishing failed. this interface is used as a parameter in the onfailure method of the eventpublishfailurecallback interface. 2192apex reference guide successresult interface namespace eventbus in this section: failureresult methods failureresult methods the following are methods for failureresult. in this section: geteventuuids() returns a list of eventuuid field values of each platform event that is included in eventbus.eventpublishfailurecallback. geteventuuids() returns a list of eventuuid field values of each platform event that is included in eventbus.eventpublishfailurecallback. signature public list<string> geteventuuids() return value type: list<string> successresult interface contains the result of an apex publish callback when the event publishing succeeded. this interface is used as a parameter in the onsuccess method of the eventpublishsuccesscallback interface. namespace eventbus in this section: successresult methods successresult methods the following are methods for successresult. 2193apex reference guide testbroker class in this section: geteventuuids() returns a list of eventuuid field values of each platform event that is included in the eventbus.eventpublishsuccesscallback. geteventuuids() returns a list of eventuuid field values of each platform event that is included in the eventbus.eventpublishsuccesscallback. signature public list<string> geteventuuids() return value type: list<string> testbroker class contains methods that simulate the successful delivery or failed publishing of platform event or change event messages in an apex test. namespace eventbus in this section: testbroker methods testbroker methods the following are methods for testbroker. in this section: deliver() delivers platform event messages to the test event bus. use this method to deliver test event messages multiple times and verify that event subscribers have processed the test events each step of the way. fail() causes the publishing of platform event messages to fail in the test event bus. use this method to test apex publish callbacks. deliver() delivers platform event messages to the test event bus. use this method to deliver test event messages multiple times and verify that event subscribers have processed the test events each step of the way. 2194apex reference guide testbroker class signature public void deliver() return value type: void usage enclose test.geteventbus().deliver() within the test.starttest() and test.stoptest() statement block. test.starttest(); // create test events // ... // publish test events with eventbus.publish() // ... // deliver test events test.geteventbus().deliver(); // perform validation // ... test.stoptest(); see also: platform events developer guide fail() causes the publishing of platform event messages to fail in the test event bus. use this method to test apex publish callbacks. signature public void fail() return value type: void usage // create test events // ... // publish test events with eventbus.publish() // ... // fail publishing of test events test.geteventbus().fail(); // perform validation // ... for more information, see <link>get the result of asynchronous platform event publishing with apex publish callbacks<link/> in the platform events developer guide. 2195apex reference guide triggercontext class triggercontext class provides information about the platform event or change event trigger that’s currently executing, such as how many times the trigger was retried due to the eventbus.retryableexception. also, provides a method to resume trigger executions. namespace eventbus in this section: triggercontext properties triggercontext methods triggercontext properties the following are properties for triggercontext. in this section:
lasterror read-only. the error message that the last thrown eventbus.retryableexception contains. retries read-only. the number of times the trigger was retried due to throwing the eventbus.retryableexception. lasterror read-only. the error message that the last thrown eventbus.retryableexception contains. signature public string lasterror {get;} property value type: string usage the error message that this property returns is the message that was passed in when creating the eventbus.retryableexception exception, as follows. throw new eventbus.retryableexception( 'condition is not met, so retrying the trigger again.'); retries read-only. the number of times the trigger was retried due to throwing the eventbus.retryableexception. 2196apex reference guide triggercontext class signature public integer retries {get;} property value type: integer triggercontext methods the following are methods for triggercontext. in this section: currentcontext() returns an instance of the eventbus.triggercontext class containing information about the currently executing trigger. getresumecheckpoint() returns the replay id that was set by setresumecheckpoint(). the returned value is the replay id of the event message after which trigger processing resumes in a new trigger invocation. setresumecheckpoint(resumereplayid) sets a checkpoint in the event stream where the platform event trigger resumes execution in a new invocation. use this method to recover from limit and uncaught exceptions, or to control the number of events processed in one trigger execution. when calling this method, pass in the replay id of the last successfully processed event message. when the trigger stops execution before all events in trigger.new are processed, either because of an uncaught exception or intentionally, the trigger is invoked again. the new execution starts with the event message in the stream after the one with the checkpointed replay id. currentcontext() returns an instance of the eventbus.triggercontext class containing information about the currently executing trigger. signature public static eventbus.triggercontext currentcontext() return value type: eventbus.triggercontext information about the currently executing trigger. getresumecheckpoint() returns the replay id that was set by setresumecheckpoint(). the returned value is the replay id of the event message after which trigger processing resumes in a new trigger invocation. signature public string getresumecheckpoint() 2197apex reference guide externalservice namespace return value type: string setresumecheckpoint(resumereplayid) sets a checkpoint in the event stream where the platform event trigger resumes execution in a new invocation. use this method to recover from limit and uncaught exceptions, or to control the number of events processed in one trigger execution. when calling this method, pass in the replay id of the last successfully processed event message. when the trigger stops execution before all events in trigger.new are processed, either because of an uncaught exception or intentionally, the trigger is invoked again. the new execution starts with the event message in the stream after the one with the checkpointed replay id. signature public void setresumecheckpoint(string resumereplayid) parameters resumereplayid type: string the replay id of the last successfully processed platform event message, after which to resume processing in a new trigger execution context. return value type: void usage the method throws an eventbus.invalidreplayidexception if the supplied replay id is not valid—the replay id is not in the current trigger batch of events, in the trigger.new list. example this snippet shows how to call the method and pass in the replayid property of an event instance. eventbus.triggercontext.currentcontext().setresumecheckpoint(event.replayid); externalservice namespace the externalservice namespace provides dynamically generated apex service interfaces and apex classes for complex object data types. the externalservice namespace doesn't define a fixed set of classes. the namespace reflects openapi-compatible external service registrations with active operations for type-safe outbound calls. the object schema, in the api specification that is associated with the registered external service, maps to apex types. see also: salesforce help: invoke external service callouts using apex 2198apex reference guide flow namespace flow namespace the flow namespace provides a class for advanced visualforce controller access to flows. the following is the class in the flow namespace. in this section: interview class the flow.interview class provides advanced controller access to flows and the ability to start a flow.
interview class the flow.interview class provides advanced controller access to flows and the ability to start a flow. namespace flow usage soql and dml limits apply during flow execution. see per-transaction flow limits in the salesforce help. to create an interview object, you have two options. • create the object directly in your class by using: – no namespace: flow.interview.flowname – namespace: flow.interview.namespace.flowname • create the object dynamically by using createinterview() note: we recommend only using createinterview() if you need to reuse your method or class. using createinterview() has these drawbacks. • if you package a class that uses createinterview(), you have to add the associated flow manually. • if you delete a flow, salesforce doesn't check if it's referenced with createinterview(). examples: starting flow interviews the following examples are all sample controllers that start an interview for the flow from the build a discount calculator project on trailhead. each shows a different permutation, based on: • whether the interview is created statically, with flow.interview.myflow, or dynamically, with createinterview(). • whether the flow is managed or local. interview created statically for a local flow { map<string, object> inputs = new map<string, object>(); inputs.put('accountid', myaccount); inputs.put('opportunityid', myoppty); 2199apex reference guide interview class flow.interview.calculate_discounts myflow = new flow.interview.calculate_discounts(inputs); myflow.start(); } interview created dynamically for a local flow public void callflow(string flowname, map <string, object> inputs) { flow.interview myflow = flow.interview.createinterview(flowname, inputs); myflow.start(); } interview created statically for a managed flow { map<string, object> inputs = new map<string, object>(); inputs.put('accountid', myaccount); inputs.put('opportunityid', myoppty); flow.interview.mynamespace.calculate_discounts myflow = new flow.interview.mynamespace.calculate_discounts(inputs); myflow.start(); } interview created dynamically for a managed flow public void callflow(string namespace, string flowname, map <string, object> inputs) { flow.interview myflow = flow.interview.createinterview(namespace, flowname, inputs); myflow.start(); } example: getting variable values this sample uses the getvariablevalue method to obtain breadcrumb (navigation) information from a flow. if that flow contains subflow elements, and each of the referenced flows also contains a vabreadcrumb variable, you can provide users with breadcrumbs regardless of which flow the interview is running. public class samplecontroller { //instance of the flow public flow.interview.flow_template_gallery myflow {get; set;} public string getbreadcrumb() { string abreadcrumb; if (myflow==null) { return 'home';} else abreadcrumb = (string) myflow.getvariablevalue('vabreadcrumb'); return(abreadcrumb==null ? 'home': abreadcrumb); } } 2200apex reference guide interview class interview methods the following are instance methods for interview. createinterview(namespace, flowname, inputvariables) creates an interview for a namespaced flow. signature public static flow.interview createinterview(string namespace, string flowname, map<string,any> inputvariables) parameters namespace type: string the flow’s namespace. flowname type: string the flow’s api name. inputvariables type: map<string,object> initial values for the flow’s input variables. return value type: flow.interview usage use this method to dynamically create a flow.interview object for the start() method. how you get output variable values from an interview depends on the type of the apex variable where you're storing the interview. • if the variable is cast to a specific flow, you can use myflow.myvar to access a variable, where myvar is the name of the variable. system.debug('my output variable: ' + myflow.varname); • if the variable is of type flow.interview but not
cast to a specific flow, you must use getvariablevalue() to access the flow's variables. system.debug('my output variable: ' + myflow.getvariablevalue('varname')); if the flow doesn't exist in the current org, a typeexception is thrown. createinterview(flowname, inputvariables) creates an interview for a flow. 2201apex reference guide interview class signature public static flow.interview createinterview(string flowname, map<string,object> inputvariables) parameters flowname type: string the flow’s api name. inputvariables type: map<string,object> initial values for the flow’s input variables. return value type: flow.interview usage use this method to dynamically create a flow.interview object for the start() method. how you get output variable values from an interview depends on the type of the apex variable where you're storing the interview. • if the variable is cast to a specific flow, you can use myflow.myvar to access a variable, where myvar is the name of the variable. system.debug('my output variable: ' + myflow.varname); • if the variable is of type flow.interview but not cast to a specific flow, you must use getvariablevalue() to access the flow's variables. system.debug('my output variable: ' + myflow.getvariablevalue('varname')); if the flow doesn't exist in the current org, a typeexception is thrown. getvariablevalue(variablename) returns the value of the specified flow variable. the flow variable can be in the flow embedded in the visualforce page, or in a separate flow that is called by a subflow element. signature public object getvariablevalue(string variablename) parameters variablename type: string specifies the unique name of the flow variable. return value type: object 2202apex reference guide functions namespace usage the returned variable value comes from whichever flow the interview is running. if the specified variable can’t be found in that flow, the method returns null. this method checks for the existence of the variable at run time only, not at compile time. start() starts an instance (interview) for an autolaunched or user provisioning flow. signature public void start() return value type: void usage this method can be used only with flows that have one of these types. • autolaunched flow • user provisioning flow for details, see “flow types” in salesforce help. when a flow user invokes an autolaunched flow, the active flow version runs. if there’s no active version, the latest version runs. when a flow admin invokes a flow, the latest version always runs. functions namespace the functions namespace provides classes and methods used to invoke and manage salesforce functions. salesforce functions is your code, run on demand, in the salesforce functions trusted elastic compute cloud. upload your complex business logic code, written using your preferred languages and frameworks, and salesforce functions takes care of everything else necessary to invoke your code in a secure, multi-tenant aware, and self-scaling environment. for more details on salesforce functions, see salesforce functions. the following are the classes in the functions namespace. in this section: function class use the function class to access deployed salesforce functions, and invoke them synchronously or asynchronously. functioncallback interface represents the callback salesforce calls when an asynchronous, queued function invocation has completed. functionerrortype enum represents the error type of functioninvocationerror. functioninvocation interface use functioninvocation to get the status and results of a synchronous or asynchronous function invocation. 2203apex reference guide function class functioninvocationerror interface use functioninvocationerror to get detailed error information about a failed function invocation. functioninvocationstatus enum represents the status of a function invocation. functioninvokemock interface use the functioninvokemock interface to mock salesforce functions responses during testing. mockfunctioninvocationfactory class use the mockfunctioninvocationfactory methods to generate appropriate mock responses for testing salesforce functions. function class use the function class to access deployed salesforce functions, and invoke them synchronously or asynchronously. namespace functions usage the function class represents an instance of a deployed function you can invoke from your org. you can invoke functions synchronously, or asynchronously using asynchronous apex. if your function takes longer than 2 minutes to return
, the request will time out. to avoid timing out, consider using asynchronous invocation. invoking a function asynchronously doesn’t count against asynchronous apex limits, such as apex queueable limits. before synchronously invoking a function, commit any pending data operations in apex, otherwise you will get a calloutexception. for asynchronous invocations, the queued invocation won’t happen if the apex transaction is not committed. any data operations that happen in the function itself are not considered part of the apex transaction. functions cannot be invoked in an apex test. a “function invocations from apex tests are not supported” calloutexception is thrown if apex determines that a function is being invoked during a test. if you must run tests against code that invokes functions you’ll need to mock your function invocations during the tests. see functioninvocation example implementation for an example of a mocked functioninvocation that you can use in testing. example the following example synchronously invokes a deployed “accountfunction” function: functions.function accountfunction = functions.function.get('myproject.accountfunction'); functions.functioninvocation invocation = accountfunction.invoke('{ "accountname" : "acct", "contactname" : "mycontact", "opportunityname" : "oppty" }'); string jsonresponse = invocation.getresponse(); the following example asynchronously invokes a deployed “accountfunction” function, using the provided callback: functions.function accountfunction = functions.function.get('myproject.accountfunction'); accountfunction.invoke('{ "accountname" : "acct", "contactname" : "mycontact", "opportunityname" : "oppty" }', new mycallback()); public class mycallback 2204apex reference guide function class implements functions.functioncallback { public void handleresponse(functions.functioninvocation result) { // handle result of function invocation // ... } } in this section: function methods function methods the following are methods for function. in this section: get(functionname) returns the function instance for the named function and project. the function must be properly deployed and have appropriate permissions to work with the org running your apex code. get(namespace, functionname) returns the function instance for the named function, project, and namespace. the function must be properly deployed and have appropriate permissions to work with the org running your apex code. invoke(payload, callback) invokes the function asynchronously. invoke(payload) invokes the function synchronously. get(functionname) returns the function instance for the named function and project. the function must be properly deployed and have appropriate permissions to work with the org running your apex code. signature public static functions.function get(string functionname) parameters functionname type: string the name of the salesforce function and the functions project that the function is part of. the format of the parameter string is “project name.function name”. for example, to retrieve the generatepdf function in the onboarding function project, use onboarding.generatepdf. the function and project must be deployed to a compute environment connected to the org. 2205apex reference guide function class return value type: functions.function returns a function instance that you can invoke. usage the function.get() method can throw the following exceptions: • invalidparametervalueexception — the functionname parameter doesn’t have the correct project name.function name format. • nodatafoundexception — the project or function name provided in the functionname parameter couldn’t be found. make sure the project and function name are spelled correctly and that the project and function have been properly deployed. get(namespace, functionname) returns the function instance for the named function, project, and namespace. the function must be properly deployed and have appropriate permissions to work with the org running your apex code. signature public static functions.function get(string namespace, string functionname) parameters namespace type: string the name of the namespace that both the salesforce function and the functions project are part of. the org the function is in must be global to access across namespaces. default value is the same org where the method is being called. functionname type: string the name of the salesforce function and the functions project that the function is part of. the format of the parameter string is “project name.function name”. for example, to retrieve the generatepdf function in the
onboarding function project, use onboarding.generatepdf. the function and project must be deployed to a compute environment connected to the org. return value type: functions.function returns a function instance that you can invoke. usage the function.get() method can throw the following exceptions: • invalidparametervalueexception — the functionname parameter doesn’t have the correct project name.function name format. • nodatafoundexception — the project or function name provided in the functionname parameter couldn’t be found. make sure the project and function name are spelled correctly and that the project and function have been properly deployed. 2206apex reference guide function class • runtimeexception — the function is public yet references a function across namespaces. make sure to retrieve references across namespaces only in a global org. invoke(payload, callback) invokes the function asynchronously. signature public functions.functioninvocation invoke(string payload, functions.functioncallback callback) parameters payload type: string the payload data that gets passed to the function. specify your payload data in a json-format string. callback type: functions.functioncallback a functioncallback implementation that gets called when your function is invoked asynchronously. return value type: functions.functioninvocation returns a functioninvocation that contains information about the results of the invocation, such as the function response, or error results. usage the function.invoke(payload, callback) method can throw the following exceptions: • calloutexception — one of the following conditions causes this exception to be thrown: – salesforce functions isn’t enabled on the current org. for more details on enabling functions, see configure orgs for functions in the functions developer guide. – the function is being invoked in an apex test. functions can’t be invoked in tests. – the “functions” permission set is missing or has incorrect permissions for functioninvocationrequest. for more details on the correct permissions for functioninvocationrequest see function permissions in the functions developer guide. – the provided payload isn’t valid json. – the function hasn’t completed deployment to a compute environment or invocation request returns a 404 http error. • invalidparametervalueexception — the callback parameter is null or references a class that doesn’t implement functions.functioncallback. • nodatafoundexception — a reference for the function couldn’t be found in the current org. make sure the project and function have been properly deployed. 2207apex reference guide functioncallback interface invoke(payload) invokes the function synchronously. signature public functions.functioninvocation invoke(string payload) parameters payload type: string the payload data that gets passed to the function. specify your payload data in a json-format string. return value type: functions.functioninvocation returns a functioninvocation that contains information about the results of the invocation, such as the function response, or error results. usage the function.invoke(payload) method can throw the following exceptions: • calloutexception — one of the following conditions causes this exception to be thrown: – salesforce functions isn’t enabled on the current org. for more details on enabling functions, see configure orgs for functions in the functions developer guide. – the function is being invoked in an apex test. functions can’t be invoked in tests. – the provided payload isn’t valid json. – there are pending dml operations. – the function is being synchronously invoked from an apex trigger. – the function hasn’t completed deployment to a compute environment or invocation request returns a 404 http error. – the function request returns a 5xx http error. – the function invocation has exceeded the time limit for synchronous invocations. for details on the time limit and work-arounds, see limits in the functions developer guide. • nodatafoundexception — a reference for the function couldn’t be found in the current org. make sure the project and function have been properly deployed. functioncallback interface represents the callback salesforce calls when an asynchronous, queued function invocation has completed. namespace functions 2208apex reference guide functioncallback interface usage when invoking functions asynchronously via function.invoke(payload, callback), you provide your own class that implements functioncallback. in this section: functioncallback methods functioncallback example implementation functioncallback methods the following are methods for functioncallback. in this section: handleresponse(var1) called when an asynchronous function invocation has completed.
handleresponse(var1) called when an asynchronous function invocation has completed. signature public void handleresponse(functions.functioninvocation var1) parameters var1 type: functions.functioninvocation the result parameter contains json response information and error information. return value type: void functioncallback example implementation this is an example implementation of the functions.functioncallback interface. public class mycallback implements functions.functioncallback { public void handleresponse(functions.functioninvocation result) { // handle result of function invocation string jsonresponse = result.getresponse(); system.debug('got response ' + jsonresponse); jsonparser parser = json.createparser(jsonresponse); // process json using your own data class... 2209apex reference guide functionerrortype enum } } the following example uses this implementation when invoking a function asynchronously: myfunction.invoke('{ "accountname" : "acct", "contactname" : "mycontact", "opportunityname" : "oppty" }', new mycallback()); functionerrortype enum represents the error type of functioninvocationerror. enum values these are the values of the functions.functionerrortype enum. value description function_exception a known exception resulting from the function logic itself. examples include an exception thrown from the function code, or an exception thrown from a library or framework the function uses. runtime_exception a known exception resulting from the salesforce functions runtime. for example, a malformed payload passed to the function when invoked results in this error type. unexpected_function_exception an unknown exception. for example, a network or system-level issue within the salesforce functions infrastructure results in this error type. functioninvocation interface use functioninvocation to get the status and results of a synchronous or asynchronous function invocation. namespace functions usage the results of a function invocation are passed back via functioninvocation. use this instance to determine if the invocation was successful, and any results from the function invocation. you can also implement your own functioninvocation interface if you run apex tests with your function invocation code. your test code can create and use your own functioninvocation instance in place of using the results from a call to function.invoke(). in this section: functioninvocation methods functioninvocation example implementation 2210apex reference guide functioninvocation interface functioninvocation methods the following are methods for functioninvocation. in this section: geterror() returns error information for a function invocation. getinvocationid() returns the invocation id of the function invocation. getresponse() returns the response string of the function invocation. getstatus() returns the status of the function invocation. geterror() returns error information for a function invocation. signature public functions.functioninvocationerror geterror() return value type: functions.functioninvocationerror contains a functioninvocationerror instance that you can use to get information about any invocation errors. if the function was invoked successfully, the returned instance is null. getinvocationid() returns the invocation id of the function invocation. signature public string getinvocationid() return value type: string this id is available after a call to either the synchronous or asynchronous function.invoke() methods. for asynchronous invocations, this id can be used to check the status of the queued invocation. getresponse() returns the response string of the function invocation. 2211apex reference guide functioninvocation interface signature public string getresponse() return value type: string the response string is the raw request json response, which can be parsed using the jsonparser class. getstatus() returns the status of the function invocation. signature public functions.functioninvocationstatus getstatus() return value type: functions.functioninvocationstatus the result of the invocation, such as functioninvocationstatus.success or functioninvocationstatus.error. functioninvocation example implementation this is an example implementation of the functions.functioninvocation interface. public class myfunctioninvocationerror implements functions.functioninvocationerror { public string getmessage() { return 'mock error message for testing'; } public functions.functionerrortype gettype() { return functions.functionerrortype.function_exception; } } public class myfunctioninvocation implements functions.functioninvocation { public functions.functioninvocationstatus getstatus() { return functions.function
invocationstatus.error; } public string getresponse() { return 'mock response for testing'; } public string getinvocationid() { return 'mocktestid'; } public functions.functioninvocationerror geterror() { functions.functioninvocationerror testerror = new myfunctioninvocationerror(); return testerror; } } 2212apex reference guide functioninvocationerror interface the following example tests the implementation: functions.functioninvocation testinvocation = new myfunctioninvocation(); if (testinvocation.getstatus() == functions.functioninvocationstatus.error) { system.debug('error: ' + (testinvocation.geterror() != null ? testinvocation.geterror().getmessage() : 'unknown')); return; } functioninvocationerror interface use functioninvocationerror to get detailed error information about a failed function invocation. namespace functions usage functioninvocationerror contains various error information such as the error message at the time of the error. in this section: functioninvocationerror methods functioninvocationerror example implementation functioninvocationerror methods the following are methods for functioninvocationerror. in this section: getmessage() returns the error message from a function invocation error. gettype() returns the error type for functioninvocationerror. getmessage() returns the error message from a function invocation error. signature public string getmessage() return value type: string 2213apex reference guide functioninvocationstatus enum gettype() returns the error type for functioninvocationerror. signature public functions.functionerrortype gettype() return value type: functions.functionerrortype functioninvocationerror example implementation this is an example implementation of the functions.functioninvocationerror interface. public class myfunctioninvocationerror implements functions.functioninvocationerror { public string getmessage() { return 'mock error message for testing'; } public functions.functionerrortype gettype() { return functions.functionerrortype.function_exception; } } this example tests the implementation. functions.functioninvocationerror testerror = new myfunctioninvocationerror(); system.debug('error: ' + testerror.getmessage() + ' type: ' + testerror.gettype()); functioninvocationstatus enum represents the status of a function invocation. enum values the following are the values of the functions.functioninvocationstatus enum. value description error the invocation failed. check the functioninvocation and functioninvocationerror returned by the invoke call to debug the issue. pending the invocation is pending. if the function is being invoked asynchronously, the invocation is still in the asynch queue. success the invocation succeeded. use functioninvocation.getresponse() with the functioninvocation instance returned by the invoke call to get any response returned by the function. 2214apex reference guide functioninvokemock interface functioninvokemock interface use the functioninvokemock interface to mock salesforce functions responses during testing. namespace functions usage to mock salesforce functions testing, implement an appropriate mock response in the respond(functionname,payload) method of the functioninvokemock interface. during mock testing of a salesforce functions, apex runtime sends the response specified in the respond() method, rather than invoking the function itself. appropriate success and error messages can be configured with the createsuccessresponse(invocationid,message) and createerrorresponse(invocationid,functionserrortype,errormsg) methods in functions.mockfunctioninvocationfactory. in this section: functioninvokemock methods functioninvokemock example implementation functioninvokemock methods the following are methods for functioninvokemock. in this section: respond(functionname, payload) the mock response implemented in the functions.functioninvokemock interface. the response is sent by apex runtime when the test.setmock() method is called. respond(functionname, payload) the mock response implemented in the functions.functioninvokemock interface. the response is sent by apex runtime when the test.setmock() method is called. signature public functions.functioninvocation respond(string functionname, string payload) parameters functionname type: string the name of the salesforce function and the functions project that the function is part of. the format of the parameter string is “
project name.function name”. 2215apex reference guide functioninvokemock interface payload type: string the json-format payload data that is passed to the function. return value type: functioninvocation interface the result of the mock call to salesforce functions. appropriate responses can be generated by using the createsuccessresponse() and createerrorresponse() methods in the functions.mockfunctioninvocationfactory class. functioninvokemock example implementation this is sample implementation of the functions.functioninvokemock interface. @istest public class functionsinvokemockimpl implements functions.functioninvokemock { public functions.functioninvocation respond(string functionname, string payload) { // return mock success response string invocationid = '000000000000000'; string response = 'mockresponse'; return functions.mockfunctioninvocationfactory.createsuccessresponse(invocationid, response); } } this example shows the minimal setup required for testing synchronous and asynchronous functions and is simplified to include both function invocations and the functioncallback class. @istest public class functiontest { @istest static void testsyncfunctioncall() { // set mock class to respond to function invocations test.setmock( functions.functioninvokemock.class, new functionsinvokemockinner()); functions.function mockedfunction = functions.function.get('example.function'); test.starttest(); // synchronous function call functions.functioninvocation invokeresult = mockedfunction.invoke('{}'); test.stoptest(); // verify that the received response contains expected mock values system.assertequals(functions.functioninvocationstatus.success, invokeresult.getstatus()); system.assertequals('mockresponse', invokeresult.getresponse()); system.assertequals('000000000000000', invokeresult.getinvocationid()); } 2216apex reference guide functioninvokemock interface @istest static void testasyncfunctioncall() { // set mock class to respond to function invocations test.setmock( functions.functioninvokemock.class, new functionsinvokemockinner()); functions.function mockedfunction = functions.function.get('example.function2'); test.starttest(); //asynchronous function invocation with callback mockedfunction.invoke('{}', new democallback()); test.stoptest(); // include assertions here about the expected callback processing } public class democallback implements functions.functioncallback { public void handleresponse(functions.functioninvocation invokeresult) { // handle result of function invocation // the callback is included in the example here for convenience // it would normally be defined in the classes being tested // verify that the received response contains expected mock values system.assertequals(invokeresult.getstatus(), functions.functioninvocationstatus.error); functions.functioninvocationerror resulterror = invokeresult.geterror(); system.assertequals('bang', invokeresult.geterror().getmessage()); system.assertequals('000000000000000', invokeresult.getinvocationid()); } } public class functionsinvokemockinner implements functions.functioninvokemock { public functions.functioninvocation respond(string functionname, string payload) { // return mock success response string invocationid = '000000000000000'; if(functionname == 'example.function2') { return functions.mockfunctioninvocationfactory.createerrorresponse( invocationid, functions.functionerrortype.function_exception, 'bang'); } string response = 'mockresponse'; return functions.mockfunctioninvocationfactory.createsuccessresponse(invocationid, response); } } 2217apex reference guide mockfunctioninvocationfactory class } mockfunctioninvocationfactory class use the mockfunctioninvocationfactory methods to generate appropriate mock responses for testing salesforce functions. namespace functions usage to mock salesforce functions testing, implement an appropriate mock response in the respond(functionname,payload) method of the functioninvokemock interface. during mock testing of a salesforce functions, the apex runtime sends the response specified in the respond() method, rather than invoking the function itself. appropriate success and error messages can be configured with the createsuccessresponse(invocationid,message) and createerrorresponse(invocationid,functionserrortype,errormsg) methods. see functioninvokemock example implementation. in this
section: mockfunctioninvocationfactory methods mockfunctioninvocationfactory methods the following are methods for mockfunctioninvocationfactory. in this section: createerrorresponse(invocationid, functionserrortype, errmsg) generate a response for an error condition during mock testing of salesforce functions. createsuccessresponse(invocationid, response) generate a response for a successful mock test of salesforce functions. createerrorresponse(invocationid, functionserrortype, errmsg) generate a response for an error condition during mock testing of salesforce functions. signature public static functions.functioninvocation createerrorresponse(string invocationid, functions.functionerrortype functionserrortype, string errmsg) parameters invocationid type: string 2218apex reference guide invocable namespace the id associated with a call to either the synchronous or asynchronous function.invoke() method. functionserrortype type: functionerrortype enum the error type of functioninvocationerror. errmsg type: string the error message. return value type: functioninvocation interface createsuccessresponse(invocationid, response) generate a response for a successful mock test of salesforce functions. signature public static functions.functioninvocation createsuccessresponse(string invocationid, string response) parameters invocationid type: string the id associated with a call to either the synchronous or asynchronous function.invoke() method. response type: string the message indicating success. return value type: functioninvocation interface invocable namespace the invocable namespace provides classes for calling invocable actions from apex. these classes are in the invocable namespace. in this section: action class contains methods to create, update, and retrieve information about invocable actions. action.error class contains methods to retrieve errors returned by invocable actions. 2219apex reference guide action class action.result class contains methods to retrieve results from invocable actions called from apex code. action class contains methods to create, update, and retrieve information about invocable actions. namespace invocable in this section: action methods action methods these methods are for action. in this section: addinvocation() creates an empty invocation in preparation for calling an invocable action. after you create the invocation, you can add parameters to the invocation. clearinvocations() clears the existing invocations from the action. clone() creates a copy of the invocable.action. createcustomaction(type, namespace, name) creates a wrapper for a custom invocable action in a specified namespace. createcustomaction(type, name) creates a wrapper for a custom invocable action. createstandardaction(type) creates a wrapper for a standard invocable action. getname() gets the name of an invocable action. getnamespace() gets the namespace of a custom invocable action. gettype() gets the type of an invocable action. invoke() invokes an invocable action from apex code. isstandard() determines whether an invocable action is a standard invocable action. 2220apex reference guide action class setinvocationparameter(parametername, parametervalue) sets a value for an invocable action parameter. setinvocations(invocations) initializes the invocations for an action from a pre-existing list of invocations. addinvocation() creates an empty invocation in preparation for calling an invocable action. after you create the invocation, you can add parameters to the invocation. signature public invocable.action addinvocation() return value type: invocable.action on page 2220 clearinvocations() clears the existing invocations from the action. signature public invocable.action clearinvocations() return value type: invocable.action on page 2220 clone() creates a copy of the invocable.action. signature public object clone() return value type: object createcustomaction(type, namespace, name) creates a wrapper for a custom invocable action in a specified namespace. signature public static invocable.action createcustomaction(string type, string namespace, string name) 2221apex reference guide action class parameters type type: string type of invocable action. namespace
type: string namespace where the invocable action is located. name type: string name for the custom invocable action. return value type: invocable.action createcustomaction(type, name) creates a wrapper for a custom invocable action. signature public static invocable.action createcustomaction(string type, string name) parameters type type: string type of invocable action. name type: string name for the custom invocable action. return value type: invocable.action createstandardaction(type) creates a wrapper for a standard invocable action. signature public static invocable.action createstandardaction(string type) 2222apex reference guide action class parameters type type: string type of invocable action. return value type: invocable.action getname() gets the name of an invocable action. signature public string getname() return value type: string name of the invocable action. getnamespace() gets the namespace of a custom invocable action. signature public string getnamespace() return value type: string namespace of the custom invocable action. gettype() gets the type of an invocable action. signature public string gettype() return value type: string type of invocable action. 2223apex reference guide action class invoke() invokes an invocable action from apex code. signature public list<invocable.action.result> invoke() return value type: list<invocable.action.result> isstandard() determines whether an invocable action is a standard invocable action. signature public boolean isstandard() return value type: boolean this method returns true if the invocable action is a standard invocable action. setinvocationparameter(parametername, parametervalue) sets a value for an invocable action parameter. signature public invocable.action setinvocationparameter(string parametername, object parametervalue) parameters parametername type: string name of the invocable action parameter to set. parametervalue type: object value to set the invocable action parameter to. return value type: invocable.action on page 2220 setinvocations(invocations) initializes the invocations for an action from a pre-existing list of invocations. 2224apex reference guide action.error class signature public invocable.action setinvocations(list<map<string,any>> invocations) parameters invocations type: list on page 3123<map on page 3144<string on page 3343,any>> list of invocations for the invocable action. return value type: invocable.action on page 2220 action.error class contains methods to retrieve errors returned by invocable actions. namespace invocable in this section: action.error methods action.error methods these methods are for action.error. in this section: clone() creates a copy of the invocable.action.error. getcode() gets the error code returned by an invocable action. getmessage() gets the error message returned by an invocable action. clone() creates a copy of the invocable.action.error. signature public object clone() 2225apex reference guide action.result class return value type: object getcode() gets the error code returned by an invocable action. signature public string getcode() return value type: string getmessage() gets the error message returned by an invocable action. signature public string getmessage() return value type: string action.result class contains methods to retrieve results from invocable actions called from apex code. namespace invocable in this section: action.result methods action.result methods the methods are for action.result. in this section: clone() creates a copy of the invocable.action.result. getaction() gets the invocable action that was invoked and caused a result to be returned. 2226apex reference guide action.result class geterrors() gets a list of errors that were returned by an invocable action.
getinvocationparameters() gets a list of the parameter values set for an invocable action. this method returns a list that contains the input parameter values for each invocation of an action. each map in the list contains a key for the name of each input parameter. getoutputparameters() gets a list of the parameter values returned by an invocable action. this method returns a list that contains the result for each invocation of an action. each map in the list contains a key for the name of each output parameter. issuccess() determines if an invocable action ran without errors. clone() creates a copy of the invocable.action.result. signature public object clone() return value type: object getaction() gets the invocable action that was invoked and caused a result to be returned. signature public invocable.action getaction() return value type: invocable.action on page 2220 geterrors() gets a list of errors that were returned by an invocable action. signature public list on page 3343<invocable.action.error on page 2225> geterrors() return value type: list on page 3343<invocable.action.error on page 2225> 2227apex reference guide kbmanagement namespace getinvocationparameters() gets a list of the parameter values set for an invocable action. this method returns a list that contains the input parameter values for each invocation of an action. each map in the list contains a key for the name of each input parameter. signature public map<string,object> getinvocationparameters() return value type: map on page 3144<string on page 3343,object> getoutputparameters() gets a list of the parameter values returned by an invocable action. this method returns a list that contains the result for each invocation of an action. each map in the list contains a key for the name of each output parameter. signature public map<string,object> getoutputparameters() return value type: map on page 3144<string on page 3343,object> issuccess() determines if an invocable action ran without errors. signature public boolean issuccess() return value type: boolean this method returns true if the invocable action ran successfully. kbmanagement namespace the kbmanagement namespace provides a class for managing knowledge articles. the following is the class in the kbmanagement namespace. in this section: publishingservice class use the methods in the kbmanagement.publishingservice class to manage the lifecycle of an article and its translations. 2228apex reference guide publishingservice class publishingservice class use the methods in the kbmanagement.publishingservice class to manage the lifecycle of an article and its translations. namespace kbmanagement usage use the methods in the kbmanagement.publishingservice class to manage the following parts of the lifecycle of an article and its translations: • publishing • updating • retrieving • deleting • submitting for translation • setting a translation to complete or incomplete status • archiving • assigning review tasks for draft articles or translations note: date values are based on gmt. to use the methods in this class, you must enable salesforce knowledge. see salesforce knowledge implementation guide for more information on setting up salesforce knowledge. publishingservice methods the following are methods for publishingservice. all methods are static. in this section: archiveonlinearticle(articleid, scheduleddate) archives an online version of an article. if the specified scheduleddate is null, the article is archived immediately. otherwise, it archives the article on the scheduled date. assigndraftarticletask(articleid, assigneeid, instructions, duedate, sendemailnotification) assigns a review task related to a draft article. assigndrafttranslationtask(articleversionid, assigneeid, instructions, duedate, sendemailnotification) assigns a review task related to a draft translation. cancelscheduledarchivingofarticle(articleid) cancels the scheduled archiving of an online article. cancelscheduledpublicationofarticle(articleid) cancels the scheduled publication of a draft article. completetranslation(articleversionid) puts a translation in a completed state that is ready to publish. 2229apex reference guide publishingservice class deletearchivedarticle(articleid) deletes an archived article. deletearch
ivedarticleversion(articleid, versionnumber) deletes a specific archived version of a published article. deletedraftarticle(articleid) deletes a draft article. deletedrafttranslation(articleversionid) deletes a draft translation. editarchivedarticle(articleid) creates a draft article from the archived primary version and returns the new draft primary version id of the article. editonlinearticle(articleid, unpublish) creates a draft article from the online version and returns the new draft primary version id of the article. also, unpublishes the online article, if unpublish is set to true. editpublishedtranslation(articleid, language, unpublish) creates a draft version of the online translation for a specific language and returns the new draft primary version id of the article. also, unpublishes the article, if set to true. publisharticle(articleid, flagasnew) publishes an article. if flagasnew is set to true, the article is published as a major version. restoreoldversion(articleid, versionnumber) creates a draft article from an existing online article based on the specified archived version of the article and returns the article version id. scheduleforpublication(articleid, scheduleddate) schedules the article for publication as a major version. if the specified date is null, the article is published immediately. settranslationtoincomplete(articleversionid) sets a draft translation that is ready for publication back to “in progress” status. submitfortranslation(articleid, language, assigneeid, duedate) submits an article for translation to the specified language. also assigns the specified user and due date to the submittal and returns new id of the draft translation. archiveonlinearticle(articleid, scheduleddate) archives an online version of an article. if the specified scheduleddate is null, the article is archived immediately. otherwise, it archives the article on the scheduled date. signature public static void archiveonlinearticle(string articleid, datetime scheduleddate) parameters articleid type: string scheduleddate type: datetime 2230apex reference guide publishingservice class return value type: void example string articleid = 'insert article id'; datetime scheduleddate = datetime.newinstancegmt(2012, 12,1,13,30,0); kbmanagement.publishingservice.archiveonlinearticle(articleid, scheduleddate); assigndraftarticletask(articleid, assigneeid, instructions, duedate, sendemailnotification) assigns a review task related to a draft article. signature public static void assigndraftarticletask(string articleid, string assigneeid, string instructions, datetime duedate, boolean sendemailnotification) parameters articleid type: string assigneeid type: string instructions type: string duedate type: datetime sendemailnotification type: boolean return value type: void example string articleid = 'insert article id'; string assigneeid = ''; string instructions = 'please review this draft.'; datetime duedate = datetime.newinstancegmt(2012, 12, 1); kbmanagement.publishingservice.assigndraftarticletask(articleid, assigneeid, instructions, duedate, true); 2231apex reference guide publishingservice class assigndrafttranslationtask(articleversionid, assigneeid, instructions, duedate, sendemailnotification) assigns a review task related to a draft translation. signature public static void assigndrafttranslationtask(string articleversionid, string assigneeid, string instructions, datetime duedate, boolean sendemailnotification) parameters articleversionid type: string assigneeid type: string instructions type: string duedate type: datetime sendemailnotification type: boolean return value type: void example string articleid = 'insert article id'; string assigneeid = 'insert assignee id'; string instructions = 'please review this draft.'; datetime duedate = datetime.newinstancegmt(2012, 12, 1); kbmanagement.publishingservice.assigndrafttranslationtask(articleid, assigneeid, instructions, duedate, true); cancelscheduledarchivingofarticle(articleid) cancels the scheduled archiving of an online article. signature public static void cancelscheduledarchivingofarticle
(string articleid) parameters articleid type: string 2232
apex reference guide publishingservice class return value type: void example string articleid = 'insert article id'; kbmanagement.publishingservice.cancelscheduledarchivingofarticle (articleid); cancelscheduledpublicationofarticle(articleid) cancels the scheduled publication of a draft article. signature public static void cancelscheduledpublicationofarticle(string articleid) parameters articleid type: string return value type: void example string articleid = 'insert article id'; kbmanagement.publishingservice.cancelscheduledpublicationofarticle (articleid); completetranslation(articleversionid) puts a translation in a completed state that is ready to publish. signature public static void completetranslation(string articleversionid) parameters articleversionid type: string return value type: void 2233apex reference guide publishingservice class example string articleversionid = 'insert article id'; kbmanagement.publishingservice.completetranslation(articleversionid); deletearchivedarticle(articleid) deletes an archived article. signature public static void deletearchivedarticle(string articleid) parameters articleid type: string return value type: void example string articleid = 'insert article id'; kbmanagement.publishingservice.deletearchivedarticle(articleid); deletearchivedarticleversion(articleid, versionnumber) deletes a specific archived version of a published article. signature public static void deletearchivedarticleversion(string articleid, integer versionnumber) parameters articleid type: string versionnumber type: integer return value type: void 2234apex reference guide publishingservice class example string articleid = 'insert article id'; integer versionnumber = 1; kbmanagement.publishingservice.deletearchivedarticleversion(articleid, versionnumber); deletedraftarticle(articleid) deletes a draft article. signature public static void deletedraftarticle(string articleid) parameters articleid type: string return value type: void example string articleid = 'insert article id'; kbmanagement.publishingservice.deletedraftarticle(articleid); deletedrafttranslation(articleversionid) deletes a draft translation. signature public static void deletedrafttranslation(string articleversionid) parameters articleversionid type: string return value type: void example string articleversionid = 'insert article id'; kbmanagement.publishingservice.deletedrafttranslation (articleversionid); 2235apex reference guide publishingservice class editarchivedarticle(articleid) creates a draft article from the archived primary version and returns the new draft primary version id of the article. signature public static string editarchivedarticle(string articleid) parameters articleid type: string return value type: string example string articleid = 'insert article id'; string id = kbmanagement.publishingservice.editarchivedarticle(articleid); editonlinearticle(articleid, unpublish) creates a draft article from the online version and returns the new draft primary version id of the article. also, unpublishes the online article, if unpublish is set to true. signature public static string editonlinearticle(string articleid, boolean unpublish) parameters articleid type: string unpublish type: boolean return value type: string example string articleid = 'insert article id'; string id = kbmanagement.publishingservice.editonlinearticle (articleid, true); 2236apex reference guide publishingservice class editpublishedtranslation(articleid, language, unpublish) creates a draft version of the online translation for a specific language and returns the new draft primary version id of the article. also, unpublishes the article, if set to true. signature public static string editpublishedtranslation(string articleid, string language, boolean unpublish) parameters articleid type: string language type: string unpublish type: boolean return value type: string example string articleid = 'insert article id'; string language = 'fr'; string id = kbmanagement.publishingservice.editpublishedtranslation(articleid, language, true); publisharticle(articleid, flagasnew) publishes an article. if flagasnew is set to true, the article is published as a major version. signature
public static void publisharticle(string articleid, boolean flagasnew) parameters articleid type: string flagasnew type: boolean return value type: void 2237apex reference guide publishingservice class example string articleid = 'insert article id'; kbmanagement.publishingservice.publisharticle(articleid, true); restoreoldversion(articleid, versionnumber) creates a draft article from an existing online article based on the specified archived version of the article and returns the article version id. signature public static string restoreoldversion(string articleid, integer versionnumber) parameters articleid type: string versionnumber type: integer return value type: string example string articleid = 'insert article id'; string id = kbmanagement.publishingservice.restoreoldversion (articleid, 1); scheduleforpublication(articleid, scheduleddate) schedules the article for publication as a major version. if the specified date is null, the article is published immediately. signature public static void scheduleforpublication(string articleid, datetime scheduleddate) parameters articleid type: string scheduleddate type: datetime return value type: void 2238apex reference guide publishingservice class example string articleid = 'insert article id'; datetime scheduleddate = datetime.newinstancegmt(2012, 12,1,13,30,0); kbmanagement.publishingservice.scheduleforpublication(articleid, scheduleddate); settranslationtoincomplete(articleversionid) sets a draft translation that is ready for publication back to “in progress” status. signature public static void settranslationtoincomplete(string articleversionid) parameters articleversionid type: string return value type: void example string articleversionid = 'insert article id'; kbmanagement.publishingservice.settranslationtoincomplete(articleversionid); submitfortranslation(articleid, language, assigneeid, duedate) submits an article for translation to the specified language. also assigns the specified user and due date to the submittal and returns new id of the draft translation. signature public static string submitfortranslation(string articleid, string language, string assigneeid, datetime duedate) parameters articleid type: string language type: string assigneeid type: string duedate type: datetime 2239apex reference guide lxscheduler namespace return value type: string example string articleid = 'insert article id'; string language = 'fr'; string assigneeid = 'insert assignee id'; datetime duedate = datetime.newinstancegmt(2012, 12,1); string id = kbmanagement.publishingservice.submitfortranslation(articleid, language, assigneeid, duedate); lxscheduler namespace the lxscheduler namespace provides an interface and classes for integrating salesforce scheduler with external calendars. the following are the classes and the interface in the lxscheduler namespace. in this section: getappointmentcandidatesinput class contains information about the available service resources (appointment candidates) based on work type group and service territories. getappointmentcandidatesinputbuilder class contains methods to build an instance of the lxscheduler.getappointmentcandidatesinput class. getappointmentslotsinput class contains information about the available appointment time slots for a resource based on given work type group and territories. getappointmentslotsinputbuilder class contains methods to build an instance of the lxscheduler.getappointmentslotsinput class. schedulerresources class contains methods that holds the business logic to get resources availability. skillrequirement class contains information about the set the skills that are required to complete a particular task for a work type. skillrequirementbuilder class contains methods to build an instance of the lxscheduler.skillrequirement class. worktype class contains information about the type of work to be performed. worktypebuilder class contains methods to build an instance of the lxscheduler.worktype class. serviceresourceschedulehandler interface allows an implementing class to check external calendar events to find already booked time slots for the requested service resources. this interface is part of salesforce scheduler. serviceappointmentrequestinfo class represents the list of parameters that are passed to the serviceresourcesche
dulehandler interface. this class is implemented internally by apex. 2240apex reference guide getappointmentcandidatesinput class serviceresourceinfo class contains information about a service resource. serviceresourceschedule class use this class to pass results from your implemented apex class to the serviceresourceschedulehandler interface methods. unavailabletimeslot class use this class to pass the unavailable time slots to the lxscheduler.serviceresourceschedule class. see also: apex interface implementation limitations and error codes getappointmentcandidatesinput class contains information about the available service resources (appointment candidates) based on work type group and service territories. set up salesforce scheduler before making requests. this setup includes creating or configuring service resources, service territory members, work type groups, work types, work type group members, and service territory work types. see set up salesforce scheduler for more information. the appointment time slots are determined based on multiple factors, such as field values, scheduled appointments, absences, scheduler settings, and scheduling policies to determine available time slots. see how salesforce scheduler determines available time slots for more information. the following factors are considered for returning start time and end time of resources. resource availability determined using service territory member, service territory, work type, and account operating hours fields. resource unavailability determined by resource absences, existing appointments that the resource is assigned to. the resource must be marked as a required resource for the appointment with a status that isn’t in closed, canceled, or completed. appointment start time interval in the scheduling policy appointment start time interval field in the scheduling policy is used to determine when the appointment can start. this interval can be 5, 10, 15, 20, 30, or 60. by default, it’s set to 15. work type duration the end time is calculated as start time + duration of the work type. note: if asset scheduling is enabled, the response also includes asset-based candidates. namespace lxscheduler usage the constructor for this class can’t be called directly. create an instance of this class using the getappointmentcandidatesinputbuilder.build() method. this example shows how to get a list of available appointment candidates based on worktypegroupid: //build input for getappointmentcandidates api lxscheduler.getappointmentcandidatesinput input = new 2241apex reference guide getappointmentcandidatesinput class lxscheduler.getappointmentcandidatesinputbuilder() .setworktypegroupid('0vsrm0000000abc4am') .setterritoryids(new list<string>{'0hhrm0000000fxd0am'}) .setstarttime(system.now().format('yyyy-mm-dd\'t\'hh:mm:ssz','america/new_york')) .setendtime(system.now().adddays(5).format('yyyy-mm-dd\'t\'hh:mm:ssz','america/new_york')) .setaccountid('001rm0000053iqgyai') .setschedulingpolicyid('0vrrm00000000bx') .setapiversion(double.valueof('50.0')) .build(); string response = lxscheduler.schedulerresources.getappointmentcandidates(input); this example shows how to get a list of available appointment candidates based on worktype: //build worktype lxscheduler.worktype worktype = new lxscheduler.worktypebuilder() .setid('08qrm0000000g9ryau') .build(); lxscheduler.getappointmentcandidatesinput input = new lxscheduler.getappointmentcandidatesinputbuilder() .setworktype(worktype) .setterritoryids(new list<string>{'0hhrm0000000fxd0am'}) .setstarttime(system.now().format('yyyy-mm-dd\'t\'hh:mm:ssz','america/new_york')) .setendtime(system.now().adddays(5).format('yyyy-mm-dd\'t\'hh:mm:ssz','america/new_york')) .setaccountid('001rm0000053iqgyai') .setschedulingpolicyid('0vrrm00000000bx') .setapiversion(double.valueof('50.0')) .
build(); string response = lxscheduler.schedulerresources.getappointmentcandidates(input); this example shows how to get a list of available candidate appointments based on durationinminutes and without the worktypegroupid or worktype fields: //build skillrequirement lxscheduler.skillrequirement skillreq = new lxscheduler.skillrequirementbuilder() .setskillid('0c5rm0000004ezs0a2') .setskilllevel(90) .build(); //build worktype lxscheduler.worktype worktype = new lxscheduler.worktypebuilder() .setdurationinminutes(15) .setblocktimebeforeappointmentinminutes(5) .setblocktimeafterappointmentinminutes(5) .settimeframestartinminutes(10080) .settimeframeendinminutes(40320) .setoperatinghoursid('0ohrm0000000fmg4au') .setskillrequirements(new list<lxscheduler.skillrequirement>{skillreq}) .build(); 2242apex reference guide getappointmentcandidatesinputbuilder class lxscheduler.getappointmentcandidatesinput input = new lxscheduler.getappointmentcandidatesinputbuilder() .setworktype(worktype) .setterritoryids(new list<string>{'0hhrm0000000fxd0am'}) .setschedulingpolicyid('0vrrm00000000bx') .setapiversion(double.valueof('50.0')) .build(); string response = lxscheduler.schedulerresources.getappointmentcandidates(input); this example shows a sample response of a list of available candidates: [ { "starttime": "2021-02-16t16:15:00.000+0000", "endtime": "2021-02-16t16:16:00.000+0000", "resources": [ "0hnxx0000004c9bcau" ], "territoryid": "0hhxx0000004c92cae" }, { "starttime": "2021-02-16t16:30:00.000+0000", "endtime": "2021-02-16t16:31:00.000+0000", "resources": [ "0hnxx0000004c9bcau" ], "territoryid": "0hhxx0000004c92cae" }, ] getappointmentcandidatesinputbuilder class contains methods to build an instance of the lxscheduler.getappointmentcandidatesinput class. a builder object is obtained by invoking one of the getappointmentcandidatesinputbuilder methods defined by the getappointmentcandidatesinput class. namespace lxscheduler in this section: getappointmentcandidatesinputbuilder methods getappointmentcandidatesinputbuilder methods the following are methods for getappointmentcandidatesinputbuilder. 2243apex reference guide getappointmentcandidatesinputbuilder class in this section: build() returns an instance of the lxscheduler.getappointmentcandidatesinput object. setaccountid(accountid) sets the id of the associated account for which you want to create the appointments. setallowconcurrent(allowconcurrent) allows the scheduling of concurrent appointments. setapiversion(apiversion) sets the api version of the business logic for the getappointmentcandidates method. setcorrelationid(correlationid) sets the correlation id. setendtime(endtime) sets the scheduling end time. setengagementchanneltypeids(engagementchanneltypeids) sets an engagement channel type. setfilterbyresources(filterbyresources) enables filtering resources using a comma-separated list of service resource ids. setresourcelimitapptdistribution(resourcelimitapptdistribution) sets the number of service resources to show during appointment scheduling. setschedulingpolicyid(schedulingpolicyid) sets the id of the appointmentschedulingpolicy object. setstarttime(starttime) sets the scheduling start time to the specified time. setterritoryids(territoryids) sets the service territory ids. setworktype(worktype) sets the type of work to be
performed. setworktypegroupid(worktypegroupid) sets the id of the work type group. build() returns an instance of the lxscheduler.getappointmentcandidatesinput object. signature public lxscheduler.getappointmentcandidatesinput build() return value type: lxscheduler.getappointmentcandidatesinput 2244apex reference guide getappointmentcandidatesinputbuilder class setaccountid(accountid) sets the id of the associated account for which you want to create the appointments. signature public lxscheduler.getappointmentcandidatesinputbuilder setaccountid(string accountid) parameters accountid type: string return value type: lxscheduler.getappointmentcandidatesinputbuilder setallowconcurrent(allowconcurrent) allows the scheduling of concurrent appointments. signature public lxscheduler.getappointmentcandidatesinputbuilder setallowconcurrent(boolean allowconcurrent) parameters allowconcurrent type: boolean if true, allows scheduling of concurrent appointments in a time slot. the default is false. available in api version 47.0 and later. return value type: lxscheduler.getappointmentcandidatesinputbuilder setapiversion(apiversion) sets the api version of the business logic for the getappointmentcandidates method. signature public lxscheduler.getappointmentcandidatesinputbuilder setapiversion(double apiversion) parameters apiversion type: double 2245apex reference guide getappointmentcandidatesinputbuilder class usage the specified parameter must use the correct api version. for example, if api version is set to 45.0 and filterbyresources is set (which is available in api version 51.0 and later), then this field is ignored. if no api version or incorrect api version is passed in the request body, by default the latest version is used. note: the api is available since version 45.0. return value type: lxscheduler.getappointmentcandidatesinputbuilder setcorrelationid(correlationid) sets the correlation id. signature public lxscheduler.getappointmentcandidatesinputbuilder setcorrelationid(string correlationid) parameters correlationid type: string id to pass custom information to the serviceresourceschedulehandler apex interface. for example, you can use the correlation id to identify the app, website, or any other external system that calls this apex interface implementation. if you don’t pass a custom value, a randomly generated identifier is passed. available in api version 53.0 and later. return value type: lxscheduler.getappointmentcandidatesinputbuilder setendtime(endtime) sets the scheduling end time. signature public lxscheduler.getappointmentcandidatesinputbuilder setendtime(string endtime) parameters endtime type: string the latest time that a time slot can end (inclusive). note: if end time is not specified, it defaults to 31 days. 2246apex reference guide getappointmentcandidatesinputbuilder class usage the specified string should use the standard date format “['yyyy-mm-dd\’t\’hh:mm:ssz']” in the local time zone. defaults to the user’s time zone. return value type: lxscheduler.getappointmentcandidatesinputbuilder setengagementchanneltypeids(engagementchanneltypeids) sets an engagement channel type. signature public lxscheduler.getappointmentcandidatesinputbuilder setengagementchanneltypeids(list<string> engagementchanneltypeids) parameters engagementchanneltypeids type: list<string> the id of the engagement channel type record. the availability of service resources is filtered based on the engagement channel type selected. this field is available in api version 56.0 and later. note: this field supports only one engagement channel type id. return value type: lxscheduler.getappointmentcandidatesinputbuilder usage you can use engagement channel types only in these cases: • the schedule appointments using engagement channels setting is enabled in salesforce scheduler settings in your salesforce org. • shifts are defined in the scheduling policy. for more information on setting up shifts in scheduling policy, see define shift rules in scheduling policy. note:
engagement channel types are not supported with operating-hours rules in the scheduling policy. setfilterbyresources(filterbyresources) enables filtering resources using a comma-separated list of service resource ids. signature public lxscheduler.getappointmentcandidatesinputbuilder setfilterbyresources(list<string> filterbyresources) 2247apex reference guide getappointmentcandidatesinputbuilder class parameters filterbyresources type: list<string> gets only eligible resources that are both in the list and in the selected service territory sorted by the order in which the resource ids are passed. this field is available in api version 51.0 and later. return value type: lxscheduler.getappointmentcandidatesinputbuilder setresourcelimitapptdistribution(resourcelimitapptdistribution) sets the number of service resources to show during appointment scheduling. signature public lxscheduler.getappointmentcandidatesinputbuilder setresourcelimitapptdistribution(integer resourcelimitapptdistribution) parameters resourcelimitapptdistribution type: integer specify the maximum number of service resources that you want to show during appointment scheduling when appointment distribution is enabled. available in api version 53.0 and later. return value type: lxscheduler.getappointmentcandidatesinputbuilder setschedulingpolicyid(schedulingpolicyid) sets the id of the appointmentschedulingpolicy object. signature public lxscheduler.getappointmentcandidatesinputbuilder setschedulingpolicyid(string schedulingpolicyid) parameters schedulingpolicyid type: string the id of the appointmentschedulingpolicy object. if no scheduling policy is passed in the request body, the default configurations are used. return value type: lxscheduler.getappointmentcandidatesinputbuilder 2248apex reference guide getappointmentcandidatesinputbuilder class setstarttime(starttime) sets the scheduling start time to the specified time. signature public lxscheduler.getappointmentcandidatesinputbuilder setstarttime(string starttime) parameters starttime type: string the earliest time that a time slot can begin (inclusive). you can also use a time from the past. usage the specified string should use the standard date format “['yyyy-mm-dd\’t\’hh:mm:ssz']” in the local time zone. defaults to the user’s time zone. return value type: lxscheduler.getappointmentcandidatesinputbuilder setterritoryids(territoryids) sets the service territory ids. signature public lxscheduler.getappointmentcandidatesinputbuilder setterritoryids(list<string> territoryids) parameters territoryids type: list<string> list of service territory ids, where the work that is being requested is performed. this is a required field. return value type: lxscheduler.getappointmentcandidatesinputbuilder setworktype(worktype) sets the type of work to be performed. signature public lxscheduler.getappointmentcandidatesinputbuilder setworktype(lxscheduler.worktype worktype) 2249apex reference guide getappointmentslotsinput class parameters worktype type: lxscheduler.worktype this method takes input as an instance of the lxscheduler.worktype class. build the instance of the input class using the lxscheduler.worktypebuilder class. required if worktypegroupid is not given. if id of the worktype is given, the rest of worktype fields are optional. usage return value type: lxscheduler.getappointmentcandidatesinputbuilder setworktypegroupid(worktypegroupid) sets the id of the work type group. signature public lxscheduler.getappointmentcandidatesinputbuilder setworktypegroupid(string worktypegroupid) parameters worktypegroupid type: string the id of the work type group containing the work types that are being performed. required if worktype is not given. if worktype is given, then you must provide either id or durationinminutes, but not both. return value type: lxscheduler.getappointmentcandidatesinputbuilder getappointmentslotsinput class contains
information about the available appointment time slots for a resource based on given work type group and territories. the appointment time slots are determined based on your salesforce scheduler data model configurations. here are some prerequisites that you can consider while setting up data. • set up salesforce scheduler before making your requests. the setup includes creating or configuring service resources, service territory members, work type groups, work types, work type group members, and service territory work types. see manage business information in salesforce scheduler for more information. • configure a work type mapped for each territory in the request body via service territory work type. map the same work type to the work type group, via work type group member. the following factors affect how time slots are calculated and returned. • timezones that differ across operating hours are handled and results are always returned in utc. • the resource must be marked as a required resource on the assigned resource object. 2250apex reference guide getappointmentslotsinput class • the resource is considered unavailable if the status categories of the resource assigned to service appointments are other than canceled, cannot complete, and completed. • resource absences of all types are considered unavailable from start to end. • the following fields of work type records, if configured, are used to fine-tune time slot requirements. for more information, see create work types in salesforce scheduler. parameter description timeframe start time slots sooner than current time + timeframe start aren’t returned. timeframe end time slots later than current time + timeframe end aren’t returned. block time before appointment the time period before the appointment is considered as unavailable. block time after appointment the time period after the appointment is considered as unavailable. operating hours the overlap of all operating hours from the account, work type, service territory, and service territory member are considered while determining time slots. for more information, see set up operating hours in salesforce scheduler. • only the time slots within the period of 31 days from the start date are returned. • salesforce scheduler uses multiple factors, such as field values, scheduled appointments, absences, scheduler settings, and scheduling policies to determine available time slots, including the earliest and latest appointment slots. see how does salesforce scheduler determine available time slots. note: if asset scheduling is enabled, you can provide an asset-based service resource in requiredresourceids to retrieve available timeslots for the asset resource. namespace lxscheduler usage the constructor for this class can’t be called directly. create an instance of this class using the getappointmentslotsinputbuilder.build() method. this example shows how to get a list of available time slots based on worktypegroupid: //build input for getappointmentslots api lxscheduler.getappointmentslotsinput input = new lxscheduler.getappointmentslotsinputbuilder() .setworktypegroupid('0vsxx0000004c92gae') .setterritoryids(new list<string>{'0hhxx0000004c92cae'}) .setstarttime(system.now().format('yyyy-mm-dd\'t\'hh:mm:ssz')) .setendtime(system.now().adddays(1).format('yyyy-mm-dd\'t\'hh:mm:ssz')) .setaccountid('001xx000003gyk0aao') .setrequiredresourceids(new list<string>{'0hnxx0000004c92cae'}) .setschedulingpolicyid('0vrxx0000004cae') .setapiversion(double.valueof('48.0')) 2251apex reference guide getappointmentslotsinput class .build(); string response = lxscheduler.schedulerresources.getappointmentslots(input); this example shows how to get a list of available time slots based on worktype: //build worktype lxscheduler.worktype worktype = new lxscheduler.worktypebuilder() .setid('08qxx0000004c92aae') .build(); lxscheduler.getappointmentslotsinput input = new lxscheduler.getappointmentslotsinputbuilder() .setworktype(worktype) .setterritoryids(new list<string>{'0hhxx0000004c92cae'}) .setstarttime
(system.now().format('yyyy-mm-dd\'t\'hh:mm:ssz')) .setendtime(system.now().adddays(1).format('yyyy-mm-dd\'t\'hh:mm:ssz')) .setaccountid('001xx000003gyk0aao') .setrequiredresourceids(new list<string>{'0hnxx0000004c92cae'}) .setschedulingpolicyid('0vrxx0000004cae') .setapiversion(double.valueof('48.0')) .build(); string response = lxscheduler.schedulerresources.getappointmentslots(input); this example shows how to get a list of available time slots based on durationinminutes and without worktypegroupid or worktype fields: //build worktype lxscheduler.worktype worktype = new lxscheduler.worktypebuilder() .setdurationinminutes(60) .build(); lxscheduler.getappointmentslotsinput input = new lxscheduler.getappointmentslotsinputbuilder() .setworktype(worktype) .setterritoryids(new list<string>{'0hhxx0000004c92cae'}) .setrequiredresourceids(new list<string>{'0hnxx0000004c92cae'}) .setapiversion(double.valueof('48.0')) .build(); string response = lxscheduler.schedulerresources.getappointmentslots(input); this example shows a sample response of a list of available time slots: [ { "territoryid": "0hhxx0000004c92cae", "starttime": "2021-02-10t16:00:00.000+0000", "endtime": "2021-02-10t16:15:00.000+0000", "remainingappointments": 1 }, { "territoryid": "0hhxx0000004c92cae", "starttime": "2021-02-10t16:15:00.000+0000", "endtime": "2021-02-10t16:30:00.000+0000", 2252apex reference guide getappointmentslotsinputbuilder class "remainingappointments": 1 }, ] getappointmentslotsinputbuilder class contains methods to build an instance of the lxscheduler.getappointmentslotsinput class. a builder object is obtained by invoking one of the getappointmentslotsinputbuilder methods defined by the getappointmentslotsinput class. namespace lxscheduler in this section: getappointmentslotsinputbuilder methods getappointmentslotsinputbuilder methods the following are methods for getappointmentslotsinputbuilder. in this section: build() returns an instance of the lxscheduler.getappointmentslotsinput object. setaccountid(accountid) sets the id of the associated account for which you want to create appointments. setallowconcurrentscheduling(allowconcurrentscheduling) allows the scheduling of concurrent appointments. setapiversion(apiversion) sets the api version of the business logic for the getappointmentslots method. setcorrelationid(correlationid) sets the correlation id. setendtime(endtime) sets the scheduling end time. setengagementchanneltypeids(engagementchanneltypeids) sets an engagement channel type. setprimaryresourceid(primaryresourceid) sets the id of the primary resource. setrequiredresourceids(requiredresourceids) sets the resource ids. setschedulingpolicyid(schedulingpolicyid) sets the id of the appointmentschedulingpolicy object. 2253apex reference guide getappointmentslotsinputbuilder class setstarttime(starttime) sets the scheduling start time. setterritoryids(territoryids) sets the ids of service territories. setworktype(worktype) sets the type of work to be performed. setworktypegroupid(worktypegroupid) sets the id of the work type group. build() returns an instance of the lxscheduler.getappointmentslotsinput object.
signature public lxscheduler.getappointmentslotsinput build() return value type: lxscheduler.getappointmentslotsinput setaccountid(accountid) sets the id of the associated account for which you want to create appointments. signature public lxscheduler.getappointmentslotsinputbuilder setaccountid(string accountid) parameters accountid type: string the id of the associated account. return value type: lxscheduler.getappointmentslotsinputbuilder setallowconcurrentscheduling(allowconcurrentscheduling) allows the scheduling of concurrent appointments. signature public lxscheduler.getappointmentslotsinputbuilder setallowconcurrentscheduling(boolean allowconcurrentscheduling) 2254apex reference guide getappointmentslotsinputbuilder class parameters allowconcurrentscheduling type: boolean if true, allows scheduling of concurrent appointments in a time slot. if false, concurrent appointments are not allowed. the default is false. available in api version 47.0 and later. return value type: lxscheduler.getappointmentslotsinputbuilder setapiversion(apiversion) sets the api version of the business logic for the getappointmentslots method. signature public lxscheduler.getappointmentslotsinputbuilder setapiversion(double apiversion) parameters apiversion type: double usage the specified parameter must use the correct api version. for example, if api version is set to 45.0 and primaryresourceid is set (which is available in api version 48.0 and later), then this field is ignored. if no api version or incorrect api version is passed in the request body, by default the latest version is used. note: the api is available since version 45.0. return value type: lxscheduler.getappointmentslotsinputbuilder setcorrelationid(correlationid) sets the correlation id. signature public lxscheduler.getappointmentslotsinputbuilder setcorrelationid(string correlationid) parameters correlationid type: string 2255apex reference guide getappointmentslotsinputbuilder class id to pass custom information to the serviceresourceschedulehandler apex interface. for example, you can use the correlation id to identify the app, website, or any other external system that calls this apex interface implementation. if you don’t pass a custom value, a randomly generated identifier is passed. available in api version 53.0 and later. return value type: lxscheduler.getappointmentslotsinputbuilder setendtime(endtime) sets the scheduling end time. signature public lxscheduler.getappointmentslotsinputbuilder setendtime(string endtime) parameters endtime type: string the latest time that a time slot can end (inclusive). if end time is not specified, it defaults to 31 days. usage the specified string should use the standard date format “['yyyy-mm-dd\’t\’hh:mm:ssz']” in the local time zone. defaults to the user’s time zone. return value type: lxscheduler.getappointmentslotsinputbuilder setengagementchanneltypeids(engagementchanneltypeids) sets an engagement channel type. signature public lxscheduler.getappointmentslotsinputbuilder setengagementchanneltypeids(list<string> engagementchanneltypeids) parameters engagementchanneltypeids type: list<string> the id of the engagement channel type record. the availability of time slots is filtered based on the engagement channel type selected. this field is available in api version 56.0 and later. note: this field supports only one engagement channel type id. 2256apex reference guide getappointmentslotsinputbuilder class return value type: lxscheduler.getappointmentslotsinputbuilder usage you can use engagement channel types only in these cases: • the schedule appointments using engagement channels setting is enabled in salesforce scheduler settings in your salesforce org. • shifts are defined in the scheduling policy. for more information on setting up shifts in scheduling policy, see define shift rules in scheduling policy. note: engagement channel types are not supported with operating-hours rules in the scheduling policy. setprimaryresourceid(
primaryresourceid) sets the id of the primary resource. signature public lxscheduler.getappointmentslotsinputbuilder setprimaryresourceid(string primaryresourceid) parameters primaryresourceid type: string the id of the primary resource in multi-resource scheduling. required only when multi-resource scheduling is enabled. available in api version 48.0 and later. return value type: lxscheduler.getappointmentslotsinputbuilder setrequiredresourceids(requiredresourceids) sets the resource ids. signature public lxscheduler.getappointmentslotsinputbuilder setrequiredresourceids(list<string> requiredresourceids) parameters requiredresourceids type: list<string> list of resource ids that must be available during the time slot. this is a required field. 2257apex reference guide getappointmentslotsinputbuilder class return value type: lxscheduler.getappointmentslotsinputbuilder setschedulingpolicyid(schedulingpolicyid) sets the id of the appointmentschedulingpolicy object. signature public lxscheduler.getappointmentslotsinputbuilder setschedulingpolicyid(string schedulingpolicyid) parameters schedulingpolicyid type: string if no scheduling policy is passed in the request body, the default configurations are used. return value type: lxscheduler.getappointmentslotsinputbuilder setstarttime(starttime) sets the scheduling start time. signature public lxscheduler.getappointmentslotsinputbuilder setstarttime(string starttime) parameters starttime type: string the earliest time that a time slot can begin (inclusive). defaults to the current time of the request, if empty. usage the specified string should use the standard date format “['yyyy-mm-dd\’t\’hh:mm:ssz']” in the local time zone. defaults to the user’s time zone. return value type: lxscheduler.getappointmentslotsinputbuilder setterritoryids(territoryids) sets the ids of service territories. 2258apex reference guide getappointmentslotsinputbuilder class signature public lxscheduler.getappointmentslotsinputbuilder setterritoryids(list<string> territoryids) parameters territoryids type: list<string> list of ids of service territories, where the work that is being requested is performed. this is a required field. return value type: lxscheduler.getappointmentslotsinputbuilder setworktype(worktype) sets the type of work to be performed. signature public lxscheduler.getappointmentslotsinputbuilder setworktype(lxscheduler.worktype worktype) parameters worktype type: lxscheduler.worktype this method takes input as an instance of the lxscheduler.worktype class. build the instance of the input class using the lxscheduler.worktypebuilder class. required if worktypegroupid is not given. return value type: lxscheduler.getappointmentslotsinputbuilder setworktypegroupid(worktypegroupid) sets the id of the work type group. signature public lxscheduler.getappointmentslotsinputbuilder setworktypegroupid(string worktypegroupid) parameters worktypegroupid type: string the id of the work type group containing the work types that are being performed. 2259apex reference guide schedulerresources class return value type: lxscheduler.getappointmentslotsinputbuilder schedulerresources class contains methods that holds the business logic to get resources availability. namespace lxscheduler implementation considerations apex implementation of the methods in the schedulerresources class should adhere to apex governor limits. it includes synchronous heap size limit, synchronous cpu time limit, and synchronous concurrent transactions for long running transactions. to avoid governor limits, you must tune the input by reducing the time frame, limiting number of service resources, or limiting number or territories at a time. this will reduce the overall transaction time and response size of the implementation. for more information on standard apex governer limits, see salesforce developer limits and allocations quick reference
. example to get list of available service resources (appointment candidates): string response = lxscheduler.schedulerresources.getappointmentcandidates(input); to get a list of available appointment time slots for a resource: string response = lxscheduler.schedulerresources.getappointmentslots(input); in this section: schedulerresources methods schedulerresources methods the following are methods for schedulerresources. in this section: getappointmentcandidates(getappointmentcandidatesinput) returns a list of service resources based on work type group or work type and service territories. getappointmentslots(getappointmentslotsinput) returns a list of available appointment time slots for a resource based on given work type group or work type and service territories. setappointmentcandidatesmock(expectedresponse) sets a mock object when running tests for the getappointmentcandidates method. 2260apex reference guide schedulerresources class setappointmentslotsmock(expectedresponse) sets a mock object when running tests for the getappointmentslots method. getappointmentcandidates(getappointmentcandidatesinput) returns a list of service resources based on work type group or work type and service territories. set up salesforce scheduler before making requests. this setup includes creating or configuring service resources, service territory members, work type groups, work types, work type group members, and service territory work types. see set up salesforce scheduler for more information. the appointment time slots are determined based on multiple factors, such as field values, scheduled appointments, absences, scheduler settings, and scheduling policies to determine available time slots. see how salesforce scheduler determines available time slots for more information. the following factors are considered for returning start time and end time of resources. resource availability determined using service territory member, service territory, work type, and account operating hours fields. resource unavailability determined by resource absences, existing appointments that the resource is assigned to. the resource must be marked as a required resource for the appointment with a status that isn’t in closed, canceled, or completed. appointment start time interval in the scheduling policy appointment start time interval field in the scheduling policy is used to determine when the appointment can start. this interval can be 5, 10, 15, 20, 30, or 60. by default, it’s set to 15. work type duration the end time is calculated as start time + duration of the work type. note: if asset scheduling is enabled, the response also includes asset-based candidates. signature public static string getappointmentcandidates(lxscheduler.getappointmentcandidatesinput getappointmentcandidatesinput) parameters getappointmentcandidatesinput type: lxscheduler.getappointmentcandidatesinput this method takes input as an instance of the lxscheduler.getappointmentcandidatesinput class. build the instance of the input class using the lxscheduler.getappointmentcandidatesinputbuilder class. return value type: string getappointmentslots(getappointmentslotsinput) returns a list of available appointment time slots for a resource based on given work type group or work type and service territories. the appointment time slots are determined based on your salesforce scheduler data model configurations. here are some prerequisites that you can consider while setting up data. 2261apex reference guide schedulerresources class • set up salesforce scheduler before making your requests. the setup includes creating or configuring service resources, service territory members, work type groups, work types, work type group members, and service territory work types. see manage business information in salesforce scheduler for more information. • configure a work type mapped for each territory in the request body via service territory work type. map the same work type to the work type group, via work type group member. the following factors affect how time slots are calculated and returned. • timezones that differ across operating hours are handled and results are always returned in utc. • the resource must be marked as a required resource on the assigned resource object. • the resource is considered unavailable if the status categories of the resource assigned to service appointments are other than canceled, cannot complete, and completed. • resource absences of all types are considered unavailable from start to end. • the following fields of work type records, if configured, are used to fine-tune time slot requirements. for more information, see create work types in salesforce scheduler. parameter
description timeframe start time slots sooner than current time + timeframe start aren’t returned. timeframe end time slots later than current time + timeframe end aren’t returned. block time before appointment the time period before the appointment is considered as unavailable. block time after appointment the time period after the appointment is considered as unavailable. operating hours the overlap of all operating hours from the account, work type, service territory, and service territory member are considered while determining time slots. for more information, see set up operating hours in salesforce scheduler. • only the time slots within the period of 31 days from the start date are returned. • salesforce scheduler uses multiple factors, such as field values, scheduled appointments, absences, scheduler settings, and scheduling policies to determine available time slots, including the earliest and latest appointment slots. see how does salesforce scheduler determine available time slots. note: if asset scheduling is enabled, you can provide an asset-based service resource in requiredresourceids to retrieve available timeslots for the asset resource. signature public static string getappointmentslots(lxscheduler.getappointmentslotsinput getappointmentslotsinput) parameters getappointmentslotsinput type: lxscheduler.getappointmentslotsinput this method takes input as an instance of the lxscheduler.getappointmentslotsinput class. build the instance of the input class using the lxscheduler.getappointmentslotsinputbuilder class. 2262apex reference guide schedulerresources class return value type: string setappointmentcandidatesmock(expectedresponse) sets a mock object when running tests for the getappointmentcandidates method. this constructor is intended for test usage and throws an exception if used outside of the apex test context. signature public static void setappointmentcandidatesmock(string expectedresponse) parameters expectedresponse type: string return value type: void this example shows a sample implementation of the getappointmentcandidates class: public class appointmentcandidateservice { //instance members for parsing public string starttime; public string endtime; public list<string> resources; public string territoryid; public static list<appointmentcandidateservice> getappointmentcandidates(){ //build input for getappointmentcandidates api lxscheduler.getappointmentcandidatesinput input = new lxscheduler.getappointmentcandidatesinputbuilder() .setworktypegroupid('0vsrm0000000agt4a2') .setterritoryids(new list<string>{'0hhrm0000000g8w0au'}) .setstarttime(system.now().format('yyyy-mm-dd\'t\'hh:mm:ssz','america/los_angeles')) .setendtime(system.now().adddays(2).format('yyyy-mm-dd\'t\'hh:mm:ssz','america/los_angeles')) .setschedulingpolicyid('0vrrm00000000d0') .setapiversion(double.valueof('50.0')) .build(); list<appointmentcandidateservice> vlist = parse(lxscheduler.schedulerresources.getappointmentcandidates(input)); return vlist; } private static list<appointmentcandidateservice> parse(string json) { return (list<appointmentcandidateservice>) system.json.deserialize(json, list<appointmentcandidateservice>.class); } } 2263apex reference guide schedulerresources class this example shows how to set a sample mock using the setappointmentcandidatesmock method: @istest private class getappointmentcandidatestest { static testmethod void getappcandidatestest() { string expectedresponse = '[' + ' {' + ' \"starttime\": \"2021-03-18t16:00:00.000+0000\",' + ' \"endtime\": \"2021-03-18t17:00:00.000+0000\",' + ' \"resources\": [' + ' \"0hnrm0000000fxv0ae\"' + ' ],' + ' \"territoryid\": \"0hhrm0000000g8w0au\"' + ' },' + ' {' + ' \"starttime\": \"2021-03-18t
19:00:00.000+0000\",' + ' \"endtime\": \"2021-03-18t20:00:00.000+0000\",' + ' \"resources\": [' + ' \"0hnrm0000000fxv0ae\"' + ' ],' + ' \"territoryid\": \"0hhrm0000000g8w0au\"' + ' }' + ']'; lxscheduler.schedulerresources.setappointmentcandidatesmock(expectedresponse); test.starttest(); list<appointmentcandidateservice> candidatelist = appointmentcandidateservice.getappointmentcandidates(); system.assertequals(2, candidatelist.size(), 'should return only 2 records!'); test.stoptest(); } } setappointmentslotsmock(expectedresponse) sets a mock object when running tests for the getappointmentslots method. this constructor is intended for test usage and throws an exception if used outside of the apex test context. signature public static void setappointmentslotsmock(string expectedresponse) parameters expectedresponse type: string 2264apex reference guide skillrequirement class return value type: void skillrequirement class contains information about the set the skills that are required to complete a particular task for a work type. namespace lxscheduler usage the constructor for this class can’t be called directly. create an instance of this class using the skillrequirementbuilder.build() method. skillrequirementbuilder class contains methods to build an instance of the lxscheduler.skillrequirement class. a builder object is obtained by invoking one of the skillrequirementbuilder methods defined by the skillrequirement class. namespace lxscheduler in this section: skillrequirementbuilder methods skillrequirementbuilder methods the following are methods for skillrequirementbuilder. in this section: build() returns an instance of the lxscheduler.skillrequirement object. setskillid(skillid) sets the skill that is required to complete a particular task for a work type. this is a required field. setskilllevel(skilllevel) sets the level of the skill that is required to complete a particular task for a work type build() returns an instance of the lxscheduler.skillrequirement object. 2265apex reference guide worktype class signature public lxscheduler.skillrequirement build() return value type: lxscheduler.skillrequirement setskillid(skillid) sets the skill that is required to complete a particular task for a work type. this is a required field. signature public lxscheduler.skillrequirementbuilder setskillid(string skillid) parameters skillid type: string return value type: lxscheduler.skillrequirementbuilder setskilllevel(skilllevel) sets the level of the skill that is required to complete a particular task for a work type signature public lxscheduler.skillrequirementbuilder setskilllevel(double skilllevel) parameters skilllevel type: double the skill levels can range from zero to 99.99. depending on your business needs, you might want the skill level to reflect years of experience, certification levels, or license classes. return value type: lxscheduler.skillrequirementbuilder worktype class contains information about the type of work to be performed. 2266apex reference guide worktypebuilder class namespace lxscheduler usage the constructor for this class can’t be called directly. create an instance of this class using the worktypebuilder.build() method. worktypebuilder class contains methods to build an instance of the lxscheduler.worktype class. a builder object is obtained by invoking one of the worktypebuilder methods defined by the worktype class. namespace lxscheduler in this section: worktypebuilder methods worktypebuilder methods the following are methods for worktypebuilder. in this section: build() returns an instance of the lxscheduler.worktype object. setblocktimeafterappointmentinminutes(blocktimeafterappointmentinminutes) sets the time period, in minutes. setblocktimebeforeappointmentinminutes(blocktimebeforeappointmentinminutes) sets the time period, in minutes. setdurationinminutes(durationin
minutes) sets the event length. setid(id) sets the id of the work type to the specified id. setoperatinghoursid(operatinghoursid) sets the overlap of operating hours. setskillrequirements(skillrequirements) sets the skills that are required to complete a particular task for a work type. settimeframeendinminutes(timeframeendinminutes) sets the end of the timeframe. settimeframestartinminutes(timeframestartinminutes) sets the beginning of the timeframe. 2267apex reference guide worktypebuilder class build() returns an instance of the lxscheduler.worktype object. signature public lxscheduler.worktype build() return value type: lxscheduler.worktype setblocktimeafterappointmentinminutes(blocktimeafterappointmentinminutes) sets the time period, in minutes. signature public lxscheduler.worktypebuilder setblocktimeafterappointmentinminutes(integer blocktimeafterappointmentinminutes) parameters blocktimeafterappointmentinminutes type: integer the time period after the appointment is considered unavailable. return value type: lxscheduler.worktypebuilder setblocktimebeforeappointmentinminutes(blocktimebeforeappointmentinminutes) sets the time period, in minutes. signature public lxscheduler.worktypebuilder setblocktimebeforeappointmentinminutes(integer blocktimebeforeappointmentinminutes) parameters blocktimebeforeappointmentinminutes type: integer the time period before the appointment is considered as unavailable. return value type: lxscheduler.worktypebuilder 2268apex reference guide worktypebuilder class setdurationinminutes(durationinminutes) sets the event length. signature public lxscheduler.worktypebuilder setdurationinminutes(integer durationinminutes) parameters durationinminutes type: integer contains the event length, in minutes. required if id is not given. return value type: lxscheduler.worktypebuilder setid(id) sets the id of the work type to the specified id. signature public lxscheduler.worktypebuilder setid(string id) parameters id type: string the id of the work type. required if durationinminutes is not given. return value type: lxscheduler.worktypebuilder setoperatinghoursid(operatinghoursid) sets the overlap of operating hours. signature public lxscheduler.worktypebuilder setoperatinghoursid(string operatinghoursid) parameters operatinghoursid type: string the overlap of all operating hours from the account, work type, service territory, and service territory member are considered while determining time slots. 2269apex reference guide worktypebuilder class return value type: lxscheduler.worktypebuilder setskillrequirements(skillrequirements) sets the skills that are required to complete a particular task for a work type. signature public lxscheduler.worktypebuilder setskillrequirements(list<lxscheduler.skillrequirement> skillrequirements) parameters skillrequirements type: list<lxscheduler.skillrequirement> this method takes input as an instance of the lxscheduler.skillrequirement class. build the instance of the input class using the lxscheduler.skillrequirementbuilder class. return value type: lxscheduler.worktypebuilder settimeframeendinminutes(timeframeendinminutes) sets the end of the timeframe. signature public lxscheduler.worktypebuilder settimeframeendinminutes(integer timeframeendinminutes) parameters timeframeendinminutes type: integer return value type: lxscheduler.worktypebuilder settimeframestartinminutes(timeframestartinminutes) sets the beginning of the timeframe. signature public lxscheduler.worktypebuilder settimeframestartinminutes(integer timeframestartinminutes) 2270apex reference guide serviceresourceschedulehandler interface parameters timeframestartinminutes type: integer return value type: lxscheduler.worktypebuilder serviceresourceschedulehandler interface allows an implementing class
to check external calendar events to find already booked time slots for the requested service resources. this interface is part of salesforce scheduler. namespace lxscheduler usage the lxscheduler.serviceresourceschedulehandler interface is called by salesforce scheduler apis. to implement this interface, you must first declare a class with the implements keyword as follows: public class serviceresourceschedulehandlerimpl implements lxscheduler.serviceresourceschedulehandler{} next, your class must provide an implementation for the following method: public static list<lxscheduler.serviceresourceschedule> getunavailabletimeslots(lxscheduler.serviceappointmentrequestinfo requestinfo){ //your code here } the implemented method must be declared as global or public. in this section: serviceresourceschedulehandler methods serviceresourceschedulehandler example implementation serviceresourceschedulehandler methods the following are methods for serviceresourceschedulehandler. in this section: getunavailabletimeslots(var1) passes the required information to get unavailable time slots from an external system. the implementation of this method returns the lxscheduler.serviceresourceschedule class. 2271apex reference guide serviceresourceschedulehandler interface getunavailabletimeslots(var1) passes the required information to get unavailable time slots from an external system. the implementation of this method returns the lxscheduler.serviceresourceschedule class. signature public list<lxscheduler.serviceresourceschedule> getunavailabletimeslots(lxscheduler.serviceappointmentrequestinfo var1) parameters var1 type: lxscheduler.serviceappointmentrequestinfo represents the list of parameters that are passed to the serviceresourceschedulehandler interface. return value type: list<lxscheduler.serviceresourceschedule> serviceresourceschedulehandler example implementation this is an example implementation of the lxscheduler.serviceresourceschedulehandler interface. /** * implement interface lxscheduler.serviceresourceschedulehandler * this class is called when fetching service resources and time slots through salesforce scheduler api.*/ public class serviceresourceschedulehandlerimpl implements lxscheduler.serviceresourceschedulehandler{ // the main interface method. public static list<lxscheduler.serviceresourceschedule> getunavailabletimeslots(lxscheduler.serviceappointmentrequestinfo requestinfo){ //request info values. list<lxscheduler.serviceresourceinfo> serviceresources=requestinfo.getserviceresources(); datetime startdate=requestinfo.getstartdate(); datetime enddate=requestinfo.getenddate(); list<lxscheduler.serviceresourceschedule> resourceunavailability = new list<lxscheduler.serviceresourceschedule>(); set<lxscheduler.unavailabletimeslot> unavailabilityintervals = new set<lxscheduler.unavailabletimeslot>(); //this is a dummy response. implement your own business logic to connect to your internal or external systems. for (integer i = 0; i < 5; i++) { //set the unavailability intervals of a service resource. unavailabilityintervals.add(new lxscheduler.unavailabletimeslot(startdate.addminutes(15*i),startdate.addminutes(15*(i+1)))); 2272apex reference guide serviceresourceschedulehandler interface } for (lxscheduler.serviceresourceinfo serviceresource:serviceresources) { //set the unavailability of service resource. resourceunavailability.add(new lxscheduler.serviceresourceschedule(serviceresource.getserviceresourceid(),unavailabilityintervals)); } return resourceunavailability; } } this example shows how to set a sample test mock using the lxscheduler.serviceresourceschedulehandler interface. @istest private class serviceresourceschedulehandlerimpltest { static testmethod void getunavailabletimeslotstest() { //initializing the test execution with mock values. change it according to the implementation. //in case of non-test execution, the lxscheduler.serviceappointmentrequestinfo instance will automatically initialize. //mock values for lxscheduler.serviceresourceinfo string userid = '005d2000000i1n6iak'; string username = '[email protected]'; string email
= '[email protected]'; string serviceresourceid = '0hnd20000004c9bkae'; list<string> territoryids = new list<string>(); string resourcetype = 't'; lxscheduler.serviceresourceinfo serviceresinfo = new lxscheduler.serviceresourceinfo(userid, username, email, serviceresourceid, territoryids, resourcetype); //mock values for lxscheduler.serviceappointmentrequestinfo datetime startdate = system.now(); datetime enddate = system.now(); list<lxscheduler.serviceresourceinfo> serviceresources = new list<lxscheduler.serviceresourceinfo>(); serviceresources.add(serviceresinfo); string schedulingpolicyid = '0vrd20000004c9s'; string worktypegroupid = '0vsd20000004c93oae'; string accountid = '001d2000002pkxwiai'; string primaryresourceid = '0hnd20000004c9bkae'; string worktypeid = '08qd20000004c9xiau'; string correlationid = 'some_id'; lxscheduler.serviceappointmentrequestinfo mockrequestinfo = new lxscheduler.serviceappointmentrequestinfo(startdate, enddate, serviceresources, schedulingpolicyid, worktypegroupid, accountid, 2273apex reference guide serviceappointmentrequestinfo class primaryresourceid, worktypeid, correlationid); serviceresourceschedulehandlerimpl.getunavailabletimeslots(mockrequestinfo); } } serviceappointmentrequestinfo class represents the list of parameters that are passed to the serviceresourceschedulehandler interface. this class is implemented internally by apex. namespace lxscheduler in this section: serviceappointmentrequestinfo constructors serviceappointmentrequestinfo methods serviceappointmentrequestinfo constructors the following are constructors for serviceappointmentrequestinfo. in this section: serviceappointmentrequestinfo(startdate, enddate, serviceresources, schedulingpolicyid, worktypegroupid, accountid, primaryresourceid, worktypeid, correlationid) creates a new instance of the lxscheduler.serviceappointmentrequestinfo class using the specified start date, end date, service resources, scheduling policy, work type group, accound id, primary resource, work type, and correlation. serviceappointmentrequestinfo(startdate, enddate, serviceresources, schedulingpolicyid, worktypegroupid, accountid, primaryresourceid, worktypeid, correlationid) creates a new instance of the lxscheduler.serviceappointmentrequestinfo class using the specified start date, end date, service resources, scheduling policy, work type group, accound id, primary resource, work type, and correlation. signature public serviceappointmentrequestinfo(datetime startdate, datetime enddate, list<lxscheduler.serviceresourceinfo> serviceresources, string schedulingpolicyid, string worktypegroupid, string accountid, string primaryresourceid, string worktypeid, string correlationid) 2274apex reference guide serviceappointmentrequestinfo class parameters startdate type: datetime the start date and time for which unavailable time slots are requested. enddate type: datetime the end date and time for which unavailable time slots are requested. serviceresources type: list<lxscheduler.serviceresourceinfo> the list of requested service resources for the unavailable time slots. schedulingpolicyid type: string the id of the scheduling policy . worktypegroupid type: string the work type group id. accountid type: string the account id of an existing user. primaryresourceid type: string the id of the primary service resource. worktypeid type: string the work type id. correlationid type: string a unique identifier for a service appointment request. serviceappointmentrequestinfo methods the following are methods for serviceappointmentrequestinfo. in this section: getaccountid() returns the account id of the customer if the api request contains one. getcorrelationid() returns a unique identifier for a request. getenddate() returns the end date and time for which unavailable time slots are requested. 2275apex reference guide serviceappointmentrequestinfo class getprimaryresourceid()
returns the id of the primary service resource. getschedulingpolicyid() returns the id of the scheduling policy that the api request contains. getserviceresources() returns the list of requested service resources for the unavailable time slots. getstartdate() returns the start date and time for which unavailable time slots are requested. getworktypegroupid() returns the work type group id if the api request contains one. getworktypeid() returns the work type id if the api request contains one. getaccountid() returns the account id of the customer if the api request contains one. signature public string getaccountid() return value type: string getcorrelationid() returns a unique identifier for a request. signature public string getcorrelationid() return value type: string getenddate() returns the end date and time for which unavailable time slots are requested. signature public datetime getenddate() return value type: datetime 2276apex reference guide serviceappointmentrequestinfo class getprimaryresourceid() returns the id of the primary service resource. signature public string getprimaryresourceid() return value type: string getschedulingpolicyid() returns the id of the scheduling policy that the api request contains. signature public string getschedulingpolicyid() return value type: string getserviceresources() returns the list of requested service resources for the unavailable time slots. signature public list<lxscheduler.serviceresourceinfo> getserviceresources() return value type: list<lxscheduler.serviceresourceinfo> getstartdate() returns the start date and time for which unavailable time slots are requested. signature public datetime getstartdate() return value type: datetime getworktypegroupid() returns the work type group id if the api request contains one. 2277apex reference guide serviceresourceinfo class signature public string getworktypegroupid() return value type: string getworktypeid() returns the work type id if the api request contains one. signature public string getworktypeid() return value type: string serviceresourceinfo class contains information about a service resource. namespace lxscheduler in this section: serviceresourceinfo constructors serviceresourceinfo methods serviceresourceinfo constructors the following are constructors for serviceresourceinfo. in this section: serviceresourceinfo(userid, username, email, serviceresourceid, territoryids, resourcetype) creates a new instance of the lxscheduler.serviceresourceinfo class using the specified service resource details. serviceresourceinfo(userid, username, email, serviceresourceid, territoryids, resourcetype) creates a new instance of the lxscheduler.serviceresourceinfo class using the specified service resource details. 2278apex reference guide serviceresourceinfo class signature public serviceresourceinfo(string userid, string username, string email, string serviceresourceid, list<string> territoryids, string resourcetype) parameters userid type: string the user id of the service resource. username type: string the user name of the service resource. email type: string the email id of the service resource. serviceresourceid type: string the id of the service resource. territoryids type: list<string> a list of requested service territories for the service resource. resourcetype type: string the type of the service resource such as technician or asset. serviceresourceinfo methods the following are methods for serviceresourceinfo. in this section: getemail() returns the email id of the service resource. getresourcetype() returns the type of the service resource such as technician or asset. getserviceresourceid() returns the id of the service resource. getterritoryids() returns a list of requested service territories for the service resource. getuserid() returns the user id of the service resource. getusername() returns the user name of the service resource. 2279apex reference guide serviceresourceinfo class getemail() returns the email id of the service resource. signature public string getemail() return value type: string getresourcetype() returns the type of the service resource such as technician or asset. signature public string getresourcetype() return value type: string getserviceresourceid() returns the id of the service resource.
signature public string getserviceresourceid() return value type: string getterritoryids() returns a list of requested service territories for the service resource. signature public list<string> getterritoryids() return value type: list<string> getuserid() returns the user id of the service resource. 2280apex reference guide serviceresourceschedule class signature public string getuserid() return value type: string getusername() returns the user name of the service resource. signature public string getusername() return value type: string serviceresourceschedule class use this class to pass results from your implemented apex class to the serviceresourceschedulehandler interface methods. namespace lxscheduler in this section: serviceresourceschedule constructors serviceresourceschedule properties serviceresourceschedule constructors the following are constructors for serviceresourceschedule. in this section: serviceresourceschedule(serviceresourceid, unavailabletimeslots) creates a new instance of lxscheduler.serviceresourceschedule class. serviceresourceschedule(serviceresourceid, unavailabletimeslots) creates a new instance of lxscheduler.serviceresourceschedule class. signature public serviceresourceschedule(string serviceresourceid, set<lxscheduler.unavailabletimeslot> unavailabletimeslots) 2281apex reference guide unavailabletimeslot class parameters serviceresourceid type: string record id of the service resource. unavailabletimeslots type: set<lxscheduler.unavailabletimeslot> an instance of lxscheduler.unavailabletimeslot class. serviceresourceschedule properties the following are properties for serviceresourceschedule. in this section: serviceresourceid record id of the service resource. unavailabletimeslots an instance of lxscheduler.unavailabletimeslot class. serviceresourceid record id of the service resource. signature public string serviceresourceid {get; set;} property value type: string unavailabletimeslots an instance of lxscheduler.unavailabletimeslot class. signature public set<lxscheduler.unavailabletimeslot> unavailabletimeslots {get; set;} property value type: set<lxscheduler.unavailabletimeslot> unavailabletimeslot class use this class to pass the unavailable time slots to the lxscheduler.serviceresourceschedule class. 2282
apex reference guide unavailabletimeslot class namespace lxscheduler in this section: unavailabletimeslot constructors unavailabletimeslot properties unavailabletimeslot constructors the following are constructors for unavailabletimeslot. in this section: unavailabletimeslot(timemin, timemax) creates an instance of lxscheduler.unavailabletimeslot class. unavailabletimeslot(timemin, timemax) creates an instance of lxscheduler.unavailabletimeslot class. signature public unavailabletimeslot(datetime timemin, datetime timemax) parameters timemin type: datetime start time of an unavailable time slot. timemax type: datetime end time of an unavailable time slot. unavailabletimeslot properties the following are properties for unavailabletimeslot. in this section: timemax end time of an unavailable time slot. timemin start time of an unavailable time slot. 2283apex reference guide messaging namespace timemax end time of an unavailable time slot. signature public datetime timemax {get; set;} property value type: datetime timemin start time of an unavailable time slot. signature public datetime timemin {get; set;} property value type: datetime messaging namespace the messaging namespace provides classes and methods for salesforce outbound and inbound email functionality. the following are the classes in the messaging namespace. in this section: attachmentretrievaloption enum provides options for including attachment metadata only, attachment metadata and content, or excluding attachments. email class (base email methods) contains base email methods common to both single and mass email. emailfileattachment class emailfileattachment is used in singleemailmessage to specify attachments passed in as part of the request, as opposed to existing documents in salesforce. inboundemail class represents an inbound email object. inboundemail.authenticationresult class contains the authentication type and response for inbound emails. inboundemail.authenticationresultfield class contains field data from the authentication result response for inbound emails. inboundemail.binaryattachment class an inboundemail object stores binary attachments in an inboundemail.binaryattachment object. 2284apex reference guide attachmentretrievaloption enum inboundemail.textattachment class an inboundemail object stores text attachments in an inboundemail.textattachment object. inboundemailresult class the inboundemailresult object is used to return the result of the email service. if this object is null, the result is assumed to be successful. inboundenvelope class the inboundenvelope object stores the envelope information associated with the inbound email, and has the following fields. massemailmessage class contains methods for sending mass email. inboundemail.header class an inboundemail object stores rfc 2822 email header information in an inboundemail.header object with the following properties. pushnotification class pushnotification is used to configure push notifications and send them from an apex trigger. pushnotificationpayload class contains methods to create the notification message payload for an apple device. customnotification class customnotification is used to create, configure, and send custom notifications from apex code. renderemailtemplatebodyresult class contains the results for rendering email templates. renderemailtemplateerror class represents an error that the renderemailtemplatebodyresult object can contain. sendemailerror class represents an error that the sendemailresult object may contain. sendemailresult class contains the result of sending an email message. singleemailmessage methods contains methods for sending single email messages. attachmentretrievaloption enum provides options for including attachment metadata only, attachment metadata and content, or excluding attachments. namespace messaging usage use these enum values with the renderstoredemailtemplate(templateid, whoid, whatid, attachmentretrievaloption) method. enum values the following are the values of the messaging.attachmentretrievaloption enum. 2285apex reference guide email class (base email methods) value description metadata_only includes only the file name, content type, and the object id in the fileattachments property of messaging.singleemailmessage. note: when the template is rendered from a visualforce template (and not from a static file attached to the template), the object id is not available. metadata_
with_body includes the attachment content, in addition to the file name, content type, and the object id in the fileattachments property of messaging.singleemailmessage. none doesn’t include any attachments in messaging.singleemailmessage. email class (base email methods) contains base email methods common to both single and mass email. namespace messaging usage note: if templates are not being used, all email content must be in plain text, html, or both.visualforce email templates cannot be used for mass email. email methods the following are methods for email. all are instance methods. in this section: setbccsender(bcc) indicates whether the email sender receives a copy of the email that is sent. for a mass mail, the sender is only copied on the first email sent. setreplyto(replyaddress) optional. the email address that receives the message when a recipient replies. settemplateid(templateid) the id of the template to be merged to create this email. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. setsaveasactivity(saveasactivity) optional. the default value is true, meaning the email is saved as an activity. this argument only applies if the recipient list is based on targetobjectid or targetobjectids. if html email tracking is enabled for the organization, you will be able to track open rates. 2286apex reference guide email class (base email methods) setsenderdisplayname(displayname) optional. the name that appears on the from line of the email. this cannot be set if the object associated with a setorgwideemailaddressid for a singleemailmessage has defined its displayname field. setusesignature(usesignature) indicates whether the email includes an email signature if the user has one configured. the default is true, meaning if the user has a signature it is included in the email unless you specify false. setbccsender(bcc) indicates whether the email sender receives a copy of the email that is sent. for a mass mail, the sender is only copied on the first email sent. signature public void setbccsender(boolean bcc) parameters bcc type: boolean return value type: void usage note: if the bcc compliance option is set at the organization level, the user cannot add bcc addresses on standard messages. the following error code is returned: bcc_not_allowed_if_bcc_ compliance_enabled. contact your salesforce representative for information on bcc compliance. setreplyto(replyaddress) optional. the email address that receives the message when a recipient replies. signature public void setreplyto(string replyaddress) parameters replyaddress type: string return value type: void 2287apex reference guide email class (base email methods) settemplateid(templateid) the id of the template to be merged to create this email. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. signature public void settemplateid(id templateid) parameters templateid type: id return value type: void usage note: sethtmlbody and setplaintextbody apply only to single email methods, not to mass email methods. setsaveasactivity(saveasactivity) optional. the default value is true, meaning the email is saved as an activity. this argument only applies if the recipient list is based on targetobjectid or targetobjectids. if html email tracking is enabled for the organization, you will be able to track open rates. signature public void setsaveasactivity(boolean saveasactivity) parameters saveasactivity type: boolean return value type: void setsenderdisplayname(displayname) optional. the name that appears on the from line of the email. this cannot be set if the object associated with a setorgwideemailaddressid for a singleemailmessage has defined its displayname field. signature public void setsenderdisplayname(string displayname) 2288apex reference guide emailfileattachment class parameters displayname type: string return value type: void setusesignature(usesignature) indicates whether the email includes an email signature if the user has one configured.
the default is true, meaning if the user has a signature it is included in the email unless you specify false. signature public void setusesignature(boolean usesignature) parameters usesignature type: boolean return value type: void emailfileattachment class emailfileattachment is used in singleemailmessage to specify attachments passed in as part of the request, as opposed to existing documents in salesforce. namespace messaging in this section: emailfileattachment constructors emailfileattachment properties emailfileattachment constructors the following are constructors for emailfileattachment. in this section: emailfileattachment() creates a new instance of the messaging.emailfileattachment class. 2289apex reference guide emailfileattachment class emailfileattachment() creates a new instance of the messaging.emailfileattachment class. signature public emailfileattachment() emailfileattachment properties the following are properties for emailfileattachment. in this section: body gets or sets the attachment itself. contenttype gets or sets the attachment's content-type. filename gets or sets the name of the file to attach. id read-only. gets the attachment id. inline specifies a content-disposition of inline (true) or attachment (false). body gets or sets the attachment itself. signature public blob body {get; set;} property value type: blob contenttype gets or sets the attachment's content-type. signature public string contenttype {get; set;} property value type: string 2290apex reference guide inboundemail class filename gets or sets the name of the file to attach. signature public string filename {get; set;} property value type: string id read-only. gets the attachment id. signature public id id {get;} property value type: id inline specifies a content-disposition of inline (true) or attachment (false). signature public boolean inline {get; set;} property value type: boolean inboundemail class represents an inbound email object. namespace messaging in this section: inboundemail constructors inboundemail properties 2291apex reference guide inboundemail class inboundemail constructors the following are constructors for inboundemail. in this section: inboundemail() creates a new instance of the messaging.inboundemail class. inboundemail() creates a new instance of the messaging.inboundemail class. signature public inboundemail() inboundemail properties the following are properties for inboundemail. in this section: authenticationresults a list of authentication results received with the email, if any. binaryattachments a list of binary attachments received with the email, if any. ccaddresses a list of carbon copy (cc) addresses, if any. fromaddress the email address that appears in the from field. fromname the name that appears in the from field, if any. headers a list of the rfc 2822 headers in the email. htmlbody the html version of the email, if specified by the sender. htmlbodyistruncated indicates whether the html body text is truncated (true) or not (false.) inreplyto the in-reply-to field of the incoming email. identifies the email or emails to which this one is a reply (parent emails). contains the parent email or emails' message-ids. messageid the message-id—the incoming email's unique identifier. 2292apex reference guide inboundemail class plaintextbody the plain text version of the email, if specified by the sender. plaintextbodyistruncated indicates whether the plain body text is truncated (true) or not (false.) references the references field of the incoming email. identifies an email thread. contains a list of the parent emails' references and message ids, and possibly the in-reply-to fields. replyto the email address that appears in the reply-to header. subject the subject line of the email, if any. textattachments a list of text attachments received with the email, if any. toaddresses the email address that appears in the to field. authenticationresults a list of authentication results received with the email, if any. signature public inboundemail.authenticationresult
[] authenticationresults {get; set;} property value type: inboundemail.authenticationresult[] usage examples of authentication results include dkim, dmarc, and spf. binaryattachments a list of binary attachments received with the email, if any. signature public inboundemail.binaryattachment[] binaryattachments {get; set;} property value type: inboundemail.binaryattachment[] usage examples of binary attachments include image, audio, application, and video files. 2293apex reference guide inboundemail class ccaddresses a list of carbon copy (cc) addresses, if any. signature public string[] ccaddresses {get; set;} property value type: string[] fromaddress the email address that appears in the from field. signature public string fromaddress {get; set;} property value type: string fromname the name that appears in the from field, if any. signature public string fromname {get; set;} property value type: string headers a list of the rfc 2822 headers in the email. signature public inboundemail.header[] headers {get; set;} property value type: inboundemail.header[] usage the list of the rfc 2822 headers includes: 2294apex reference guide inboundemail class • recieved from • custom headers • message-id • date htmlbody the html version of the email, if specified by the sender. signature public string htmlbody {get; set;} property value type: string htmlbodyistruncated indicates whether the html body text is truncated (true) or not (false.) signature public boolean htmlbodyistruncated {get; set;} property value type: boolean inreplyto the in-reply-to field of the incoming email. identifies the email or emails to which this one is a reply (parent emails). contains the parent email or emails' message-ids. signature public string inreplyto {get; set;} property value type: string messageid the message-id—the incoming email's unique identifier. signature public string messageid {get; set;} 2295apex reference guide inboundemail class property value type: string plaintextbody the plain text version of the email, if specified by the sender. signature public string plaintextbody {get; set;} property value type: string plaintextbodyistruncated indicates whether the plain body text is truncated (true) or not (false.) signature public boolean plaintextbodyistruncated {get; set;} property value type: boolean references the references field of the incoming email. identifies an email thread. contains a list of the parent emails' references and message ids, and possibly the in-reply-to fields. signature public string[] references {get; set;} property value type: string[] replyto the email address that appears in the reply-to header. signature public string replyto {get; set;} 2296apex reference guide inboundemail class property value type: string usage if there is no reply-to header, this field is identical to the fromaddress field. subject the subject line of the email, if any. signature public string subject {get; set;} property value type: string textattachments a list of text attachments received with the email, if any. signature public inboundemail.textattachment[] textattachments {get; set;} property value type: inboundemail.textattachment[] usage the text attachments can be any of the following: • attachments with a multipurpose internet mail extension (mime) type of text • attachments with a mime type of application/octet-stream and a file name that ends with either a .vcf or .vcs extension. these are saved as text/x-vcard and text/calendar mime types, respectively. toaddresses the email address that appears in the to field. signature public string[] toaddresses {get; set;} property value type: string[] 2297apex reference guide inboundemail.authenticationresult class inboundemail.authenticationresult class contains the authentication type and response for inbound emails. namespace messaging in this section: inboundemail.authenticationresult constructors inboundemail
.authenticationresult properties inboundemail.authenticationresult constructors the following are constructors for inboundemail.authenticationresult. in this section: inboundemail.authenticationresult() creates a new instance of the messaging.inboundemail.authenticationresult class. inboundemail.authenticationresult() creates a new instance of the messaging.inboundemail.authenticationresult class. signature public inboundemail.authenticationresult() inboundemail.authenticationresult properties the following are properties for inboundemail.authenticationresult. in this section: authenticationresultfields additional information in authentication result headers. examples include: name: smtp.mailfrom and value: example.com. method the authentication method used for the security check. possible values include dkim, dmarc, or spf. result the result of the authentication check. when the email service is configured to verify the legitimacy of the sending server before processing a message, possible values include pass or fail. otherwise, the value returned is none. authenticationresultfields additional information in authentication result headers. examples include: name: smtp.mailfrom and value: example.com. 2298apex reference guide inboundemail.authenticationresultfield class signature public inboundemail.authenticationresultfield[] authenticationresultfields {get; set;} property value type: inboundemail.authenticationresultfield[] method the authentication method used for the security check. possible values include dkim, dmarc, or spf. signature public string method {get; set;} property value type: string result the result of the authentication check. when the email service is configured to verify the legitimacy of the sending server before processing a message, possible values include pass or fail. otherwise, the value returned is none. signature public string result {get; set;} property value type: string inboundemail.authenticationresultfield class contains field data from the authentication result response for inbound emails. namespace messaging in this section: inboundemail.authenticationresultfield constructors inboundemail.authenticationresultfield properties inboundemail.authenticationresultfield constructors the following are constructors for inboundemail.authenticationresultfield. 2299apex reference guide inboundemail.authenticationresultfield class in this section: inboundemail.authenticationresultfield() creates a new instance of the messaging.inboundemail.authenticationresultfield class. inboundemail.authenticationresultfield() creates a new instance of the messaging.inboundemail.authenticationresultfield class. signature public inboundemail.authenticationresultfield() inboundemail.authenticationresultfield properties the following are properties for inboundemail.authenticationresultfield. in this section: name the authentication result field name. for example: smtp.mailfrom. value the authentication result field value. for example: example.com. name the authentication result field name. for example: smtp.mailfrom. signature public string name {get; set;} property value type: string value the authentication result field value. for example: example.com. signature public string value {get; set;} property value type: string 2300apex reference guide inboundemail.binaryattachment class inboundemail.binaryattachment class an inboundemail object stores binary attachments in an inboundemail.binaryattachment object. namespace messaging usage examples of binary attachments include image, audio, application, and video files. in this section: inboundemail.binaryattachment constructors inboundemail.binaryattachment properties inboundemail.binaryattachment constructors the following are constructors for inboundemail.binaryattachment. in this section: inboundemail.binaryattachment() creates a new instance of the messaging.inboundemail.binaryattachment class. inboundemail.binaryattachment() creates a new instance of the messaging.inboundemail.binaryattachment class. signature public inboundemail.binaryattachment() inboundemail.binaryattachment properties the following are properties for inboundemail.binaryattachment. in this section: body the body of the attachment. filename the name of the attached file. headers any header values associated with the attachment. examples of header names include content-type
, content-transfer-encoding, and content-id. 2301apex reference guide inboundemail.binaryattachment class mimetypesubtype the primary and sub mime-type. body the body of the attachment. signature public blob body {get; set;} property value type: blob filename the name of the attached file. signature public string filename {get; set;} property value type: string headers any header values associated with the attachment. examples of header names include content-type, content-transfer-encoding, and content-id. signature public list<messaging.inboundemail.header> headers {get; set;} property value type: list<messaging.inboundemail.header> mimetypesubtype the primary and sub mime-type. signature public string mimetypesubtype {get; set;} property value type: string 2302apex reference guide inboundemail.textattachment class inboundemail.textattachment class an inboundemail object stores text attachments in an inboundemail.textattachment object. namespace messaging usage the text attachments can be any of the following: • attachments with a multipurpose internet mail extension (mime) type of text • attachments with a mime type of application/octet-stream and a file name that ends with either a .vcf or .vcs extension. these are saved as text/x-vcard and text/calendar mime types, respectively. in this section: inboundemail.textattachment constructors inboundemail.textattachment properties inboundemail.textattachment constructors the following are constructors for inboundemail.textattachment. in this section: inboundemail.textattachment() creates a new instance of the messaging.inboundemail.textattachment class. inboundemail.textattachment() creates a new instance of the messaging.inboundemail.textattachment class. signature public inboundemail.textattachment() inboundemail.textattachment properties the following are properties for inboundemail.textattachment. in this section: body the body of the attachment. bodyistruncated indicates whether the attachment body text is truncated (true) or not (false.) 2303apex reference guide inboundemail.textattachment class charset the original character set of the body field. the body is re-encoded as utf-8 as input to the apex method. filename the name of the attached file. headers any header values associated with the attachment. examples of header names include content-type, content-transfer-encoding, and content-id. mimetypesubtype the primary and sub mime-type. body the body of the attachment. signature public string body {get; set;} property value type: string bodyistruncated indicates whether the attachment body text is truncated (true) or not (false.) signature public boolean bodyistruncated {get; set;} property value type: boolean charset the original character set of the body field. the body is re-encoded as utf-8 as input to the apex method. signature public string charset {get; set;} property value type: string filename the name of the attached file. 2304apex reference guide inboundemailresult class signature public string filename {get; set;} property value type: string headers any header values associated with the attachment. examples of header names include content-type, content-transfer-encoding, and content-id. signature public list<messaging.inboundemail.header> headers {get; set;} property value type: list<messaging.inboundemail.header> mimetypesubtype the primary and sub mime-type. signature public string mimetypesubtype {get; set;} property value type: string inboundemailresult class the inboundemailresult object is used to return the result of the email service. if this object is null, the result is assumed to be successful. namespace messaging inboundemailresult properties the following are properties for inboundemailresult. in this section: message a message that salesforce returns in the body of a reply email. this field can be populated
with text irrespective of the value returned by the success field. 2305apex reference guide inboundenvelope class success a value that indicates whether the email was successfully processed. message a message that salesforce returns in the body of a reply email. this field can be populated with text irrespective of the value returned by the success field. signature public string message {get; set;} property value type: string success a value that indicates whether the email was successfully processed. signature public boolean success {get; set;} property value type: boolean usage if false, salesforce rejects the inbound email and sends a reply email to the original sender containing the message specified in the message field. inboundenvelope class the inboundenvelope object stores the envelope information associated with the inbound email, and has the following fields. namespace messaging inboundenvelope properties the following are properties for inboundenvelope. in this section: fromaddress the name that appears in the from field of the envelope, if any. 2306apex reference guide massemailmessage class toaddress the name that appears in the to field of the envelope, if any. fromaddress the name that appears in the from field of the envelope, if any. signature public string fromaddress {get; set;} property value type: string toaddress the name that appears in the to field of the envelope, if any. signature public string toaddress {get; set;} property value type: string massemailmessage class contains methods for sending mass email. namespace messaging usage massemailmessage extends email and inherits all of its methods. all base email (email class) methods are also available to the massemailmessage objects. in this section: massemailmessage constructors massemailmessage methods see also: email class (base email methods) 2307apex reference guide massemailmessage class massemailmessage constructors the following are constructors for massemailmessage. in this section: massemailmessage() creates a new instance of the messaging.massemailmessage class. massemailmessage() creates a new instance of the messaging.massemailmessage class. signature public massemailmessage() massemailmessage methods the following are methods for massemailmessage. all are instance methods. all base email (email class) methods are also available to the massemailmessage objects. these methods are described in email class (base email methods). in this section: setdescription(description) the description of the email. settargetobjectids(targetobjectids) a list of ids of the contacts, leads, or users to which the email will be sent. the ids you specify set the context and ensure that merge fields in the template contain the correct data. the objects must be of the same type (all contacts, all leads, or all users). setwhatids(whatids) optional. if you specify a list of contacts for the targetobjectids field, you can specify a list of whatids as well. this helps to further ensure that merge fields in the template contain the correct data. setdescription(description) the description of the email. signature public void setdescription(string description) parameters description type: string return value type: void 2308apex reference guide massemailmessage class settargetobjectids(targetobjectids) a list of ids of the contacts, leads, or users to which the email will be sent. the ids you specify set the context and ensure that merge fields in the template contain the correct data. the objects must be of the same type (all contacts, all leads, or all users). signature public void settargetobjectids(id[] targetobjectids) parameters targetobjectids type: id[] return value type: void usage you can list multiple ids per email. if you specify a value for the targetobjectids field, optionally specify a whatid as well to set the email context to a user, contact, or lead. this ensures that merge fields in the template contain the correct data. each id counts against the sending organization's daily mass email limit. do not specify the ids of records that have the email opt out option selected. all emails must have a recipient value in at least one of the following fields: • toaddresses • ccaddresses • bccaddresses • targetobjectid setwhatids(whatids) optional. if you specify a list of contacts
for the targetobjectids field, you can specify a list of whatids as well. this helps to further ensure that merge fields in the template contain the correct data. signature public void setwhatids(id[] whatids) parameters whatids type: id[] return value type: void 2309apex reference guide inboundemail.header class usage the values must be one of the following types: • contract • case • opportunity • product note: if you specify whatids, specify one for each targetobjectid; otherwise, you will receive an invalid_id_field error. inboundemail.header class an inboundemail object stores rfc 2822 email header information in an inboundemail.header object with the following properties. namespace messaging inboundemail.header properties the following are properties for inboundemail.header. in this section: name the name of the header parameter, such as date or message-id. value the value of the header. name the name of the header parameter, such as date or message-id. signature public string name {get; set;} property value type: string value the value of the header. signature public string value {get; set;} 2310apex reference guide pushnotification class property value type: string pushnotification class pushnotification is used to configure push notifications and send them from an apex trigger. namespace messaging example this sample apex trigger sends push notifications to the connected app named test_app, which corresponds to a mobile app on ios mobile clients. the trigger fires after cases have been updated and sends the push notification to two users: the case owner and the user who last modified the case. trigger casealert on case (after update) { for(case cs : trigger.new) { // instantiating a notification messaging.pushnotification msg = new messaging.pushnotification(); // assembling the necessary payload parameters for apple. // apple params are: // (<alert text>,<alert sound>,<badge count>, // <free-form data>) // this example doesn't use badge count or free-form data. // the number of notifications that haven't been acted // upon by the intended recipient is best calculated // at the time of the push. this timing helps // ensure accuracy across multiple target devices. map<string, object> payload = messaging.pushnotificationpayload.apple( 'case ' + cs.casenumber + ' status changed to: ' + cs.status, '', null, null); // adding the assembled payload to the notification msg.setpayload(payload); // getting recipient users string userid1 = cs.ownerid; string userid2 = cs.lastmodifiedbyid; // adding recipient users to list set<string> users = new set<string>(); users.add(userid1); users.add(userid2); // sending the notification to the specified app and users. 2311apex reference guide pushnotification class // here we specify the api name of the connected app. msg.send('test_app', users); } } in this section: pushnotification constructors pushnotification methods pushnotification constructors the following are the constructors for pushnotification. in this section: pushnotification() creates a new instance of the messaging.pushnotification class. pushnotification(payload) creates a new instance of the messaging.pushnotification class using the specified payload parameters as key-value pairs. when you use this constructor, you don’t need to call setpayload to set the payload. pushnotification() creates a new instance of the messaging.pushnotification class. signature public pushnotification() pushnotification(payload) creates a new instance of the messaging.pushnotification class using the specified payload parameters as key-value pairs. when you use this constructor, you don’t need to call setpayload to set the payload. signature public pushnotification(map<string,object> payload) parameters payload type:map<string, object> the payload, expressed as a map of key-value pairs. pushnotification methods the following are the methods for pushnotification. all are global methods. 2312apex reference guide pushnotification class in this section: send(
application, users) sends a push notification message to the specified users. setpayload(payload) sets the payload of the push notification message. setttl(ttl) reserved for future use. send(application, users) sends a push notification message to the specified users. signature public void send(string application, set<string> users) parameters application type: string the connected app api name. this corresponds to the mobile client app the notification should be sent to. users type: set a set of user ids that correspond to the users the notification should be sent to. example see the push notification example. setpayload(payload) sets the payload of the push notification message. signature public void setpayload(map<string,object> payload) parameters payload type: map<string, object> the payload, expressed as a map of key-value pairs. payload parameters can be different for each mobile os vendor. for more information on apple’s payload parameters, search for “apple push notification service” at https://developer.apple.com/library/mac/documentation/. to create the payload for an apple device, see the pushnotificationpayload class. 2313apex reference guide pushnotificationpayload class example see the push notification example. setttl(ttl) reserved for future use. signature public void setttl(integer ttl) parameters ttl type: integer reserved for future use. pushnotificationpayload class contains methods to create the notification message payload for an apple device. namespace messaging usage apple has specific requirements for the notification payload. and this class has helper methods to create the payload. for more information on apple’s payload parameters, search for “apple push notification service” at https://developer.apple.com/library/mac/documentation/. example see the push notification example. in this section: pushnotificationpayload methods pushnotificationpayload methods the following are the methods for pushnotificationpayload. all are global static methods. in this section: apple(alert, sound, badgecount, userdata) helper method that creates a valid apple payload from the specified arguments. apple(alertbody, actionlockey, lockey, locargs, launchimage, sound, badgecount, userdata) helper method that creates a valid apple payload from the specified arguments. 2314apex reference guide pushnotificationpayload class apple(alert, sound, badgecount, userdata) helper method that creates a valid apple payload from the specified arguments. signature public static map<string,object> apple(string alert, string sound, integer badgecount, map<string,object> userdata) parameters alert type: string notification message to be sent to the mobile client. sound type: string name of a sound file to be played as an alert. this sound file should be in the mobile application bundle. badgecount type: integer number to display as the badge of the application icon. userdata type: map<string, object> map of key-value pairs that contains any additional data used to provide context for the notification. for example, it can contain ids of the records that caused the notification to be sent. the mobile client app can use these ids to display these records. return value type:map<string, object> returns a formatted payload that includes all of the specified arguments. usage to generate a valid payload, you must provide a value for at least one of the following parameters: alert, sound, badgecount. example see the push notification example. apple(alertbody, actionlockey, lockey, locargs, launchimage, sound, badgecount, userdata) helper method that creates a valid apple payload from the specified arguments. signature public static map<string,object> apple(string alertbody, string actionlockey, string lockey, string[] locargs, string launchimage, string sound, integer badgecount, map<string,object> userdata) 2315apex reference guide customnotification class parameters alertbody type: string text of the alert message. actionlockey type: string if a value is specified for the actionlockey argument, an alert with two buttons is displayed. the value is a key to get a localized string in a localizable.strings file to use for the right button’s title. lockey type: string key
to an alert-message string in a localizable.strings file for the current localization. locargs type: list<string> variable string values to appear in place of the format specifiers in lockey. launchimage type: string file name of an image file in the application bundle. sound type: string name of a sound file to be played as an alert. this sound file should be in the mobile application bundle. badgecount type: integer number to display as the badge of the application icon. userdata type: map<string, object> map of key-value pairs that contains any additional data used to provide context for the notification. for example, it can contain ids of the records that caused the notification to be sent. the mobile client app can use these ids to display these records. return value type: map<string, object> returns a formatted payload that includes all of the specified arguments. usage to generate a valid payload, you must provide a value for at least one of the following parameters: alert, sound, badgecount. customnotification class customnotification is used to create, configure, and send custom notifications from apex code. 2316apex reference guide customnotification class namespace messaging usage customnotification allows two approaches to creating and configuring a custom notification. • create an instance with the default constructor, and then set notification attributes using the various setter methods. • create an instance and configure notification parameters at the same time using the parameterized constructor. once the custom notification is configured, call send() to send the notification. notification target the notification target is used by the receiving client application to navigate to an appropriate record or page when a user responds to a notification. for example, when a user is notified that a record was updated, responding to the notification can open the relevant record. you must specify a target for a notification. the target can be specified using either the targetid or the targetpageref attribute. neither attribute is required, but if both are omitted, send() throws an exception. if there’s no natural target for a notification, set the targetid to a dummy value, such as 000000000000000aaa. a dummy value prevents the exception, and also prevents automatic navigation when responding to the notification in the client app. you can set both targetid and targetpageref in the same notification. the client app that receives the notification determines which target, if any, to use when responding to the notification. important: before winter ’21 you could set only a target record (targetid) for a notification. most client applications expect to find a targetid in the notification payload. if you can’t update a client app to handle notifications that include only a targetpageref, set the targetid to a dummy value. execution context and notification permissions by default apex code executes in system mode, and doesn’t require user permissions to send notifications with customnotification. however, if your apex code runs in a user context—for example, by executing anonymous apex in the developer console—the send custom notifications user permission is checked, and send() fails if you don’t have the required permission. example this example apex class provides a static method for sending a custom notification to a recipient list. call this method from a trigger, flow, or wherever you want to send a custom notification from apex. public without sharing class customnotificationfromapex { public static void notifyusers(set<string> recipientsids, string targetid) { // get the id for our custom notification type customnotificationtype notificationtype = [select id, developername from customnotificationtype where developername='custom_notification']; // create a new custom notification messaging.customnotification notification = new messaging.customnotification(); // set the contents for the notification 2317apex reference guide customnotification class notification.settitle('apex custom notification'); notification.setbody('the notifications are coming from inside the apex!'); // set the notification type and target notification.setnotificationtypeid(notificationtype.id); notification.settargetid(targetid); // actually send the notification try { notification.send(recipientsids); } catch (exception e) { system.debug('problem sending notification: ' + e.getmessage()); } } } note: this example uses a hard-coded string, custom_notification, as the developername (also known as the api name) of a custom notification type. use your custom notification types in your own code. customnot
ification.send() can throw an exception, which is handled minimally in this example. add more substantial error handling to code you plan to use in production. in this section: customnotification constructors customnotification methods see also: salesforce help: send custom notifications actions developer guide: custom notification actions metadata api developer guide: customnotificationtype customnotification constructors the following are constructors for customnotification. in this section: customnotification() creates a new instance of the messaging.customnotification class. customnotification(typeid, sender, title, body, targetid, targetpageref) creates an instance of the messaging.customnotification class using the specified parameters. when you use this constructor, you don’t need to call the various setter methods to define the custom notification attributes. customnotification() creates a new instance of the messaging.customnotification class. 2318apex reference guide customnotification class signature public customnotification() customnotification(typeid, sender, title, body, targetid, targetpageref) creates an instance of the messaging.customnotification class using the specified parameters. when you use this constructor, you don’t need to call the various setter methods to define the custom notification attributes. signature public customnotification(string typeid, string sender, string title, string body, string targetid, string targetpageref) parameters typeid type: string the id of the custom notification type being used for the notification. sender type: string the user id of the sender of the notification. title type: string the title of the notification. maximum characters: 250. body type: string the body of the notification. maximum characters: 750. targetid type: string the record id for the target record of the notification. you must specify either a targetid or a targetpageref. see custom notification usage. targetpageref type: string the pagereference for the navigation target of the notification. to see how to specify the target using json, see pagereference types. you must specify either a targetid or a targetpagere. see custom notification usage. usage a client may see a truncated notification title or body depending on the delivery channel or app, and how the connect api notification parameters are configured. for more information on the trimmessages query parameter, see notification . customnotification methods the following are methods for customnotification. 2319apex reference guide customnotification class in this section: send(users) sends a custom notification to the specified users. setnotificationtypeid(id) sets the type of the custom notification. settitle(title) sets the title of the custom notification. setbody(body) sets the body of the custom notification. setsenderid(id) sets the sender of the custom notification. settargetid(targetid) sets the target record of the custom notification. settargetpageref(pageref) sets the target page of the custom notification. send(users) sends a custom notification to the specified users. signature public void send(set<string> users) parameters users type: set<string> required. a set of recipient ids. each recipient id corresponds to a recipient or recipient type that the notification should be sent to. valid recipient or recipient type values are: • userid — the notification is sent to this user, if this user is active. • accountid — the notification is sent to all active users who are members of this account’s account team. note: this recipient type is valid if account teams are enabled for your org. • opportunityid — the notification is sent to all active users who are members of this opportunity’s opportunity team. note: this recipient type is valid if team selling is enabled for your org. • groupid — the notification is sent to all active users who are members of this group. • queueid — the notification is sent to all active users who are members of this queue. values can be combined in a set, up to the maximum of 500 values. return value type: void 2320apex reference guide customnotification class example see the custom notification example. setnotificationtypeid(id) sets the type of the custom notification. signature public void setnotificationtypeid(string id) parameters id type: string the id of the custom notification type being
used for the notification. a notification type is required to send a custom notification. see custom notification usage. return value type: void example see the custom notification example. settitle(title) sets the title of the custom notification. signature public void settitle(string title) parameters title type: string the title of the notification, as it will be seen by recipients. maximum characters: 250. a title is required to send a custom notification. see custom notification usage. return value type: void example see the custom notification example. 2321apex reference guide customnotification class setbody(body) sets the body of the custom notification. signature public void setbody(string body) parameters body type: string the body of the notification, as it will be seen by recipients. maximum characters: 750. a body is required to send a custom notification. see custom notification usage. return value type: void example see the custom notification example. setsenderid(id) sets the sender of the custom notification. signature public void setsenderid(string id) parameters id type: string the user id of the sender of the notification. setting a sender is optional. see custom notification usage. return value type: void example see the custom notification example. settargetid(targetid) sets the target record of the custom notification. 2322apex reference guide renderemailtemplatebodyresult class signature public void settargetid(string targetid) parameters targetid type: string the record id for the target record of the notification. either a targetid or a targetpageref is required to send a custom notification. see custom notification usage. return value type: void example see the custom notification example. settargetpageref(pageref) sets the target page of the custom notification. signature public void settargetpageref(string pageref) parameters pageref type: string the pagereference for the navigation target of the notification. either a targetid or a targetpageref is required to send a custom notification. see custom notification usage. return value type: void example see the custom notification example. renderemailtemplatebodyresult class contains the results for rendering email templates. namespace messaging 2323apex reference guide renderemailtemplatebodyresult class in this section: renderemailtemplatebodyresult methods renderemailtemplatebodyresult methods the following are methods for renderemailtemplatebodyresult. in this section: geterrors() if an error occurred during the renderemailtemplate method, a renderemailtemplateerror object is returned. getmergedbody() returns the rendered body text with merge field references replaced with the corresponding record data. getsuccess() indicates whether the operation was successful. geterrors() if an error occurred during the renderemailtemplate method, a renderemailtemplateerror object is returned. signature public list<messaging.renderemailtemplateerror> geterrors() return value type: list<messaging.renderemailtemplateerror> getmergedbody() returns the rendered body text with merge field references replaced with the corresponding record data. signature public string getmergedbody() return value type: string getsuccess() indicates whether the operation was successful. signature public boolean getsuccess() 2324apex reference guide renderemailtemplateerror class return value type: boolean renderemailtemplateerror class represents an error that the renderemailtemplatebodyresult object can contain. namespace messaging in this section: renderemailtemplateerror methods renderemailtemplateerror methods the following are methods for renderemailtemplateerror. in this section: getfieldname() returns the name of the merge field in the error. getmessage() returns a message describing the error. getoffset() returns the offset within the supplied body text where the error was discovered. if the offset cannot be determined, -1 is returned. getstatuscode() returns a salesforce api status code. getfieldname() returns the name of the merge field in the error. signature public string getfieldname() return value type: string getmessage() returns a message describing the error. 2325apex reference guide sendemailerror class signature public string getmessage() return value type: string getoffset() returns the offset within the supplied body text where the error was discovered. if the offset cannot be determined, -1 is returned. signature
public integer getoffset() return value type: integer getstatuscode() returns a salesforce api status code. signature public system.statuscode getstatuscode() return value type: system.statuscode sendemailerror class represents an error that the sendemailresult object may contain. namespace messaging sendemailerror methods the following are methods for sendemailerror. all are instance methods. in this section: getfields() a list of one or more field names. identifies which fields in the object, if any, affected the error condition. getmessage() the text of the error message. 2326apex reference guide sendemailerror class getstatuscode() returns a code that characterizes the error. gettargetobjectid() the id of the target record for which the error occurred. getfields() a list of one or more field names. identifies which fields in the object, if any, affected the error condition. signature public string[] getfields() return value type: string[] getmessage() the text of the error message. signature public string getmessage() return value type: string getstatuscode() returns a code that characterizes the error. signature public system.statuscode getstatuscode() return value type: system.statuscode usage the full list of status codes is available in the wsdl file for your organization. for more information about accessing the wsdl file for your organization, see downloading salesforce wsdls and client authentication certificates in the salesforce online help. gettargetobjectid() the id of the target record for which the error occurred. 2327apex reference guide sendemailresult class signature public string gettargetobjectid() return value type: string sendemailresult class contains the result of sending an email message. namespace messaging sendemailresult methods the following are methods for sendemailresult. all are instance methods. in this section: geterrors() if an error occurred during the sendemail method, a sendemailerror object is returned. issuccess() indicates whether the email was successfully submitted for delivery (true) or not (false). even if issuccess is true, it does not mean the intended recipients received the email, as there could have been a problem with the email address or it could have bounced or been blocked by a spam blocker. geterrors() if an error occurred during the sendemail method, a sendemailerror object is returned. signature public sendemailerror[] geterrors() return value type: messaging.sendemailerror[] issuccess() indicates whether the email was successfully submitted for delivery (true) or not (false). even if issuccess is true, it does not mean the intended recipients received the email, as there could have been a problem with the email address or it could have bounced or been blocked by a spam blocker. signature public boolean issuccess() 2328apex reference guide singleemailmessage methods return value type: boolean singleemailmessage methods contains methods for sending single email messages. namespace messaging usage singleemailmessage extends email and inherits all of its methods. all base email (email class) methods are also available to the singleemailmessage objects. emails sent via singleemailmessage count against the sending organization's daily single email limit. email properties are readable and writable. each property has corresponding setter and getter methods. for example, the toaddresses() property is equivalent to the settoaddresses() and gettoaddresses() methods. only the setter methods are documented. however, the gettemplatename() method doesn’t have an equivalent setter method; use settemplateid() to specify a template name. in this section: singleemailmessage constructors singleemailmessage methods see also: email class (base email methods) singleemailmessage constructors the following are constructors for singleemailmessage. in this section: singleemailmessage() creates a new instance of the messaging.singleemailmessage class. singleemailmessage() creates a new instance of the messaging.singleemailmessage class. signature public singleemailmessage() 2329apex reference guide singleemailmessage methods singleemailmessage methods the following are methods for singleemailmessage. all are instance methods. all base email (email class) methods are also available to the singleemailmessage objects. these methods are described in email class (base email methods). in this section:
gettemplatename() the name of the template used to create the email. setbccaddresses(bccaddresses) optional. a list of blind carbon copy (bcc) addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. setccaddresses(ccaddresses) optional. a list of carbon copy (cc) addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. setcharset(characterset) optional. the character set for the email. if this value is null, the user's default value is used. setdocumentattachments(documentids) (deprecated. use setentityattachments() instead.) optional. a list containing the id of each document object you want to attach to the email. setentityattachments(ids) optional. array of ids of document, contentversion, or attachment items to attach to the email. setfileattachments(filenames) optional. a list containing the file names of the binary and text files you want to attach to the email. sethtmlbody(htmlbody) optional. the html version of the email, specified by the sender. the value is encoded according to the specification associated with the organization. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. setinreplyto(parentmessageids) sets the optional in-reply-to field of the outgoing email. this field identifies the email or emails to which this email is a reply (parent emails). setoptoutpolicy(emailoptoutpolicy) optional. if you added recipients by id instead of email address and the email opt out option is set, this method determines the behavior of the sendemail() call. if you add recipients by their email addresses, the opt-out settings for those recipients aren’t checked and those recipients always receive the email. setplaintextbody(plaintextbody) optional. the text version of the email, specified by the sender. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. setorgwideemailaddressid(emailaddressid) optional. the id of the organization-wide email address associated with the outgoing email. if you’re using apex to send emails from the guest user, set the sender to the verified org-wide email address or the emails are blocked. the object's displayname field cannot be set if the setsenderdisplayname field is already set. 2330apex reference guide singleemailmessage methods setreferences(references) optional. the references field of the outgoing email. identifies an email thread. contains the parent emails' references and message ids, and possibly the in-reply-to fields. setsubject(subject) optional. the email subject line. if you are using an email template, the subject line of the template overrides this value. settargetobjectid(targetobjectid) required if using a template, optional otherwise. the id of the contact, lead, or user to which the email will be sent. the id you specify sets the context and ensures that merge fields in the template contain the correct data. settemplateid(templateid) required if using a template, optional otherwise. the id of the template used to create the email. settoaddresses(toaddresses) optional. a list of email addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. settreatbodiesastemplate(treatastemplate) optional. if set to true, the subject, plain text, and html text bodies of the email are treated as template data. the merge fields are resolved
using the renderemailtemplate method. default is false. settreattargetobjectasrecipient(treatasrecipient) optional. if set to true, the targetobjectid (a contact, lead, or user) is the recipient of the email. if set to false, the targetobjectid is supplied as the whoid field for template rendering but isn’t a recipient of the email. the default is true. setwhatid(whatid) if you specify a contact for the targetobjectid field, you can specify an optional whatid as well. this helps to further ensure that merge fields in the template contain the correct data. gettemplatename() the name of the template used to create the email. signature public string gettemplatename() return value type: string usage there is no equivalent setter method for gettemplatename(). if the email didn’t use a template, gettemplatename() returns nothing. if you use settemplateid(), and then call gettemplatename(), the template name associated to the template id is returned. 2331apex reference guide singleemailmessage methods setbccaddresses(bccaddresses) optional. a list of blind carbon copy (bcc) addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. signature public void setbccaddresses(string[] bccaddresses) parameters bccaddresses type: string[] return value type: void usage all emails must have a recipient value in at least one of the following fields: • toaddresses • ccaddresses • bccaddresses • targetobjectid if the bcc compliance option is set at the organization level, the user cannot add bcc addresses on standard messages. the following error code is returned: bcc_not_allowed_if_bcc_ compliance_enabled. contact your salesforce representative for information on bcc compliance. setccaddresses(ccaddresses) optional. a list of carbon copy (cc) addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. signature public void setccaddresses(string[] ccaddresses) parameters ccaddresses type: string[] return value type: void 2332
apex reference guide singleemailmessage methods usage all emails must have a recipient value in at least one of the following fields: • toaddresses • ccaddresses • bccaddresses • targetobjectid setcharset(characterset) optional. the character set for the email. if this value is null, the user's default value is used. signature public void setcharset(string characterset) parameters characterset type: string return value type: void setdocumentattachments(documentids) (deprecated. use setentityattachments() instead.) optional. a list containing the id of each document object you want to attach to the email. signature public void setdocumentattachments(id[] documentids) parameters documentids type: id[] return value type: void usage you can attach multiple documents as long as the total size of all attachments does not exceed 10 mb. setentityattachments(ids) optional. array of ids of document, contentversion, or attachment items to attach to the email. 2333apex reference guide singleemailmessage methods signature public void setentityattachments(list<string> ids) parameters ids type: list<string> return value type: void setfileattachments(filenames) optional. a list containing the file names of the binary and text files you want to attach to the email. signature public void setfileattachments(emailfileattachment[] filenames) parameters filenames type: messaging.emailfileattachment[] return value type: void usage you can attach multiple files as long as the total size of all attachments does not exceed 10 mb. sethtmlbody(htmlbody) optional. the html version of the email, specified by the sender. the value is encoded according to the specification associated with the organization. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. signature public void sethtmlbody(string htmlbody) parameters htmlbody type: string 2334apex reference guide singleemailmessage methods return value type: void setinreplyto(parentmessageids) sets the optional in-reply-to field of the outgoing email. this field identifies the email or emails to which this email is a reply (parent emails). signature public void setinreplyto(string parentmessageids) parameters parentmessageids type: string contains one or more parent email message ids. return value type: void setoptoutpolicy(emailoptoutpolicy) optional. if you added recipients by id instead of email address and the email opt out option is set, this method determines the behavior of the sendemail() call. if you add recipients by their email addresses, the opt-out settings for those recipients aren’t checked and those recipients always receive the email. signature public void setoptoutpolicy(string emailoptoutpolicy) parameters emailoptoutpolicy type: string possible values of the emailoptoutpolicy parameter are: • send (default)—the email is sent to all recipients. the recipients’ email opt out setting is ignored. the setting enforce email privacy settings is ignored. • filter—no email is sent to recipients that have the email opt out option set. emails are sent to the other recipients. the setting enforce email privacy settings is ignored. • reject—if any of the recipients have the email opt out option set, sendemail() throws an error and no email is sent. the setting enforce email privacy settings is respected, as are the selections in the data privacy record based on the individual object. if any of the recipients have don’t market, don’t process, or forget this individual selected, sendemail() throws an error and no email is sent. 2335apex reference guide singleemailmessage methods return value type: void example this example shows how to send an email with the opt-out setting enforced. recipients are specified by their ids. the filter option causes the email to be sent only to recipients that haven’t opted out from email. this example uses dot notation of the email properties, which is equivalent to using the set methods. messaging.singleemailmessage message = new messaging.singleemailmessage(); // set recipients to two contact ids. // replace ids with valid record ids in your org. message.toaddresses = new
string[] { '003d000000qdexs', '003d000000qdfw5' }; message.optoutpolicy = 'filter'; message.subject = 'opt out test message'; message.plaintextbody = 'this is the message body.'; messaging.singleemailmessage[] messages = new list<messaging.singleemailmessage> {message}; messaging.sendemailresult[] results = messaging.sendemail(messages); if (results[0].success) { system.debug('the email was sent successfully.'); } else { system.debug('the email failed to send: ' + results[0].errors[0].message); } setplaintextbody(plaintextbody) optional. the text version of the email, specified by the sender. specify a value for settemplateid, sethtmlbody, or setplaintextbody. or, you can define both sethtmlbody and setplaintextbody. signature public void setplaintextbody(string plaintextbody) parameters plaintextbody type: string return value type: void setorgwideemailaddressid(emailaddressid) optional. the id of the organization-wide email address associated with the outgoing email. if you’re using apex to send emails from the guest user, set the sender to the verified org-wide email address or the emails are blocked. the object's displayname field cannot be set if the setsenderdisplayname field is already set. 2336apex reference guide singleemailmessage methods signature public void setorgwideemailaddressid(id emailaddressid) parameters emailaddressid type: id usage after you create an org-wide email address, you’re sent a confirmation email to verify it. copy the id from the url and use the setorgwideemailaddressid(id) method on your instance of messaging.singleemailmessage. to avoid hard-coding an id, after creating your org-wide email address, you can query them. orgwideemailaddress[] owea = [select id from orgwideemailaddress where address = 'donotreply@<somedomain>.com']; messaging.singleemailmessage mail = new messaging.singleemailmessage(); if ( owea.size() > 0 ) { mail.setorgwideemailaddressid(owea.get(0).id); } return value type: void setreferences(references) optional. the references field of the outgoing email. identifies an email thread. contains the parent emails' references and message ids, and possibly the in-reply-to fields. signature public void setreferences(string references) parameters references type: string return value type: void setsubject(subject) optional. the email subject line. if you are using an email template, the subject line of the template overrides this value. signature public void setsubject(string subject) 2337apex reference guide singleemailmessage methods parameters subject type: string return value type: void settargetobjectid(targetobjectid) required if using a template, optional otherwise. the id of the contact, lead, or user to which the email will be sent. the id you specify sets the context and ensures that merge fields in the template contain the correct data. signature public void settargetobjectid(id targetobjectid) parameters targetobjectid type: id return value type: void usage do not specify the ids of records that have the email opt out option selected. all emails must have a recipient value in at least one of the following fields: • toaddresses • ccaddresses • bccaddresses • targetobjectid settemplateid(templateid) required if using a template, optional otherwise. the id of the template used to create the email. signature public void settemplateid(id templateid) parameters templateid type: id 2338apex reference guide singleemailmessage methods return value type: void settoaddresses(toaddresses) optional. a list of email addresses or object ids of the contacts, leads, and users you’re sending the email to. the maximum size for this field is 4,000 bytes. the maximum total of toaddresses, ccaddresses, and bccaddresses per email is 150. all recipients in these three fields count against the limit for email sent using apex or the api. signature public void settoaddresses(string[] toaddresses)
parameters toaddresses type: string[] return value type: void usage all emails must have a recipient value in at least one of the following fields: • toaddresses • ccaddresses • bccaddresses • targetobjectid settreatbodiesastemplate(treatastemplate) optional. if set to true, the subject, plain text, and html text bodies of the email are treated as template data. the merge fields are resolved using the renderemailtemplate method. default is false. signature public void settreatbodiesastemplate(boolean treatastemplate) parameters treatastemplate type: boolean return value type: void 2339apex reference guide singleemailmessage methods settreattargetobjectasrecipient(treatasrecipient) optional. if set to true, the targetobjectid (a contact, lead, or user) is the recipient of the email. if set to false, the targetobjectid is supplied as the whoid field for template rendering but isn’t a recipient of the email. the default is true. signature public void settreattargetobjectasrecipient(boolean treatasrecipient) parameters treatasrecipient type: boolean return value type: void usage note: you can set to, cc, and bcc addresses using the email messaging methods regardless of whether a template is used for the email or the target object is a recipient. setwhatid(whatid) if you specify a contact for the targetobjectid field, you can specify an optional whatid as well. this helps to further ensure that merge fields in the template contain the correct data. signature public void setwhatid(id whatid) parameters whatid type: id return value type: void usage the value must be one of the following types: • account • asset • campaign • case • contract 2340apex reference guide metadata namespace • opportunity • order • product • solution • custom metadata namespace the metadata namespace provides classes and methods for working with custom metadata in salesforce salesforce uses metadata types and components to represent org configuration and customization. metadata is used for org settings that admins control or configuration information applied by installed apps and packages. use the classes in the metadata namespace to access metadata from within apex code. metadata access in apex is available for apex classes using api version 40.0 and later. for more information, see metadata. the following are the classes in the metadata namespace. in this section: analyticscloudcomponentlayoutitem class represents the settings for a wave analytics dashboard on a standard or custom page. consolecomponent class represents a custom console component on a section of a page layout. container class represents a location and style in which to display more than one custom console component in the sidebars of the console. customconsolecomponents class represents custom console components (visualforce pages, lookup fields, or related lists) on a page layout. custommetadata class represents records of custom metadata types. custommetadatavalue class represents custom metadata values for a custom metadata component. deploycallback interface an interface for metadata deployment callback classes. deploycallbackcontext class represents context information for a deployment job. deploycontainer class represents a container for custom metadata components to be deployed. deploydetails class contains detailed information on deployed components. deploymessage class represents result information for the deployment of a metadata component. 2341apex reference guide metadata namespace deployproblemtype enum describes the problem type for an unsuccessful component deploy. deployresult class represents the results of a metadata deployment. deploystatus enum the result status of a deployment. feeditemtypeenum enum the type of feed item in a feed-based page layout. feedlayout class represents the values that define the feed view of a feed-based page layout. feed-based layouts are available on account, case, contact, lead, opportunity, custom, and external objects. they include a feed view and a detail view. feedlayoutcomponent class represents a component in the feed view of a feed-based page layout. feedlayoutcomponenttype enum indicates the type of feed layout component. feedlayoutfilter class represents a feed filter option in the feed view of a feed-based page layout. a filter can have only standardfilter or feeditemtype set. feedlayoutfilterposition enum describes where the feed filters list is included in the layout. feedlayoutfiltertype
enum the type of feed layout filter. layout class represents the metadata associated with a page layout. layoutcolumn class represents the items in a column within a layout section. layoutheader enum represents tagging types used for metadata.layout.headers layoutitem class represents the valid values that define a layout item. layoutsection class represents a section of a page layout, such as the custom links section. layoutsectionstyle enum describes the possible styles for a layout section. metadata class an abstract base class that represents a custom metadata component. metadatatype enum represents the custom metadata components available in apex. metadatavalue class an abstract base class that represents a custom metadata component field. 2342apex reference guide metadata namespace minilayout class represents a mini view of a record in the console tab, hover details, and event overlays. operations class represents a class to execute metadata operations, such as retrieving or deploying custom metadata. platformactionlist class represents the list of actions, and their order, that display in the salesforce mobile action bar for the layout. platformactionlistcontextenum enum describes the different contexts of action lists. platformactionlistitem class represents an action in the platform action list for a layout. platformactiontypeenum enum the type of action for a platformactionlistitem. primarytabcomponents class represents custom console components on primary tabs in the salesforce console. quickactionlist class represents the list of actions associated with the page layout. quickactionlistitem class represents an action in the quickactionlist. relatedcontent class represents the mobile cards section of the page layout. relatedcontentitem class represents an individual item in the relatedcontent list. relatedlist class represents related list custom components on the sidebars of the salesforce console. relatedlistitem class represents an item in the related list in a page layout. reportchartcomponentlayoutitem class represents the settings for a report chart on a standard or custom page. reportchartcomponentsize enum describes the size of the displayed report chart component. sidebarcomponent class represents a specific custom console component to display in a container that hosts multiple components in one of the sidebars of the salesforce console. sortorder enum describes the sort order of a related list. statuscode enum describes the status code for an unsuccessful component deploy. subtabcomponents class represents custom console components on subtabs in the salesforce console. summarylayoutstyleenum enum describes the highlights panel style for a summarylayout. 2343apex reference guide analyticscloudcomponentlayoutitem class summarylayout class controls the appearance of the highlights panel, which summarizes key fields in a grid at the top of a page layout, when case feed is enabled. summarylayoutitem class controls the appearance of an individual field and its column and row position within the highlights panel grid, when case feed is enabled. you can have two fields per each grid in a highlights panel. uibehavior enum describes the behavior for a layout item on a layout page. analyticscloudcomponentlayoutitem class represents the settings for a wave analytics dashboard on a standard or custom page. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “analyticscloudcomponentlayoutitem” in the metadata api developer guide. in this section: analyticscloudcomponentlayoutitem properties analyticscloudcomponentlayoutitem methods analyticscloudcomponentlayoutitem properties the following are properties for analyticscloudcomponentlayoutitem. in this section: assettype specifies the type of wave analytics asset. devname unique development name of the dashboard to add. error an error string that is populated only when an error occurred in the underlying dashboard. filter dashboard filters for mapping data fields in the dashboard to the object’s fields. height specifies the height of the dashboard, in pixels. hideonerror controls whether users see a dashboard that has an error. 2344apex reference guide analyticscloudcomponentlayoutitem class showheader if true, includes the dashboard’s header bar. if false, the dashboard appears without a header bar. showsharing if set to true, and the dashboard is shareable the dashboard shows the share icon. if set to false, the dashboard doesn’t show the share icon. showtitle if true, includes the dashboard’s title above the dashboard. if false,
the dashboard appears without a title. width specifies the width of the dashboard, in pixels or percentage. assettype specifies the type of wave analytics asset. signature public string assettype {get; set;} property value type: string devname unique development name of the dashboard to add. signature public string devname {get; set;} property value type: string error an error string that is populated only when an error occurred in the underlying dashboard. signature public string error {get; set;} property value type: string filter dashboard filters for mapping data fields in the dashboard to the object’s fields. 2345apex reference guide analyticscloudcomponentlayoutitem class signature public string filter {get; set;} property value type: string height specifies the height of the dashboard, in pixels. signature public integer height {get; set;} property value type: integer hideonerror controls whether users see a dashboard that has an error. signature public boolean hideonerror {get; set;} property value type: boolean showheader if true, includes the dashboard’s header bar. if false, the dashboard appears without a header bar. signature public boolean showheader {get; set;} property value type: boolean showsharing if set to true, and the dashboard is shareable the dashboard shows the share icon. if set to false, the dashboard doesn’t show the share icon. 2346apex reference guide analyticscloudcomponentlayoutitem class signature public boolean showsharing {get; set;} property value type: boolean showtitle if true, includes the dashboard’s title above the dashboard. if false, the dashboard appears without a title. signature public boolean showtitle {get; set;} property value type: boolean width specifies the width of the dashboard, in pixels or percentage. signature public string width {get; set;} property value type: string analyticscloudcomponentlayoutitem methods the following are methods for analyticscloudcomponentlayoutitem. in this section: clone() makes a duplicate copy of the metadata.analyticscloudcomponentlayoutitem. clone() makes a duplicate copy of the metadata.analyticscloudcomponentlayoutitem. signature public object clone() 2347apex reference guide consolecomponent class return value type: object consolecomponent class represents a custom console component on a section of a page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “consolecomponent” in the metadata api developer guide. in this section: consolecomponent properties consolecomponent methods consolecomponent properties the following are properties for consolecomponent. in this section: height the height of the custom console component in pixels. location the location of the custom console component on the page layout. valid values are right, left, top, and bottom. visualforcepage the unique name of the custom console component. width the width of the custom console component in pixels. height the height of the custom console component in pixels. signature public integer height {get; set;} property value type: integer 2348apex reference guide consolecomponent class location the location of the custom console component on the page layout. valid values are right, left, top, and bottom. signature public string location {get; set;} property value type: string visualforcepage the unique name of the custom console component. signature public string visualforcepage {get; set;} property value type: string width the width of the custom console component in pixels. signature public integer width {get; set;} property value type: integer consolecomponent methods the following are methods for consolecomponent. in this section: clone() makes a duplicate copy of the metadata.consolecomponent. clone() makes a duplicate copy of the metadata.consolecomponent. 2349apex reference guide container class signature public object clone() return value type: object container class represents a location and style in which to display more than one custom console component in the sidebars of the console. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “container” in the metadata api developer guide. in this section: container properties container methods container properties the following are properties
for container. in this section: height the height of the component’s container. the unit property determines the unit of measurement, in pixels or percent. iscontainerautosizeenabled if set to true, stacked console components in the sidebars autosize vertically. region the location of the component’s container (right, left, bottom, top). sidebarcomponents represents a specific custom console component to display in the components’ container. style the style of the container in which to display multiple components (stack, tab, accordion). unit the unit of measurement, in pixels or percent, for the height or width of the components’ container. width the width of the component’s container. the unit property determines the unit of measurement, in pixels or percent. 2350apex reference guide container class height the height of the component’s container. the unit property determines the unit of measurement, in pixels or percent. signature public integer height {get; set;} property value type: integer iscontainerautosizeenabled if set to true, stacked console components in the sidebars autosize vertically. signature public boolean iscontainerautosizeenabled {get; set;} property value type: boolean region the location of the component’s container (right, left, bottom, top). signature public string region {get; set;} property value type: string sidebarcomponents represents a specific custom console component to display in the components’ container. signature public list<metadata.sidebarcomponent> sidebarcomponents {get; set;} property value type: list<metadata.sidebarcomponent> style the style of the container in which to display multiple components (stack, tab, accordion). 2351apex reference guide container class signature public string style {get; set;} property value type: string unit the unit of measurement, in pixels or percent, for the height or width of the components’ container. signature public string unit {get; set;} property value type: string width the width of the component’s container. the unit property determines the unit of measurement, in pixels or percent. signature public integer width {get; set;} property value type: integer container methods the following are methods for container. in this section: clone() makes a duplicate copy of the metadata.container. clone() makes a duplicate copy of the metadata.container. signature public object clone() 2352apex reference guide customconsolecomponents class return value type: object customconsolecomponents class represents custom console components (visualforce pages, lookup fields, or related lists) on a page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “customconsolecomponents” in the metadata api developer guide. in this section: customconsolecomponents properties customconsolecomponents methods customconsolecomponents properties the following are properties for customconsolecomponents. in this section: primarytabcomponents represents custom console components on primary tabs in the salesforce console. subtabcomponents represents custom console components on subtabs in the salesforce console. primarytabcomponents represents custom console components on primary tabs in the salesforce console. signature public metadata.primarytabcomponents primarytabcomponents {get; set;} property value type: metadata.primarytabcomponents subtabcomponents represents custom console components on subtabs in the salesforce console. 2353apex reference guide custommetadata class signature public metadata.subtabcomponents subtabcomponents {get; set;} property value type: metadata.subtabcomponents customconsolecomponents methods the following are methods for customconsolecomponents. in this section: clone() makes a duplicate copy of the metadata.customconsolecomponents. clone() makes a duplicate copy of the metadata.customconsolecomponents. signature public object clone() return value type: object custommetadata class represents records of custom metadata types. warning: protected custom metadata types behave like public custom metadata types when they are outside of a managed package. public custom metadata types are readable for all profiles, including the guest user. do not store secrets, personally identifying information, or any private data in these records. use protected custom metadata types only in managed packages. outside of a
managed package, use named credentials or encrypted custom fields to store secrets like oauth tokens, passwords, and other confidential material. namespace metadata usage use metadata.custommetadata to represent records of custom metadata types in apex. for more information, see custom metadata types in the metadata api developer guide. 2354apex reference guide custommetadata class example // set up custom metadata to be created in the subscriber org. metadata.custommetadata custommetadata = new metadata.custommetadata(); custommetadata.fullname = 'isvnamespace__metadatatypename.metadatarecordname'; metadata.custommetadatavalue customfield = new metadata.custommetadatavalue(); customfield.field = 'customfield__c'; customfield.value = 'new value'; custommetadata.values.add(customfield); note: when you assign namespaces to records, provide full, qualified record names to the app. if both the type and the record are in namespace, use something like: custommetadata.fullname = 'namespace__metadatatypename.namespace__metadatarecordname' in this section: custommetadata properties custommetadata methods custommetadata properties the following are properties for custommetadata. in this section: description the description of the custom metadata. label the label of the custom metadata record. protected_x property that describes whether the custom metadata record is a protected component. values a list of custom metadata values, such as custom fields, for the custom metadata record. description the description of the custom metadata. signature public string description {get; set;} property value type: string 2355apex reference guide custommetadata class label the label of the custom metadata record. signature public string label {get; set;} property value type: string protected_x property that describes whether the custom metadata record is a protected component. signature public boolean protected_x {get; set;} property value type: boolean values a list of custom metadata values, such as custom fields, for the custom metadata record. signature public list<metadata.custommetadatavalue> values {get; set;} property value type: list<metadata.custommetadatavalue> custommetadata methods the following are methods for custommetadata. in this section: clone() makes a duplicate copy of the metadata.custommetadata. clone() makes a duplicate copy of the metadata.custommetadata. 2356apex reference guide custommetadatavalue class signature public object clone() return value type: object custommetadatavalue class represents custom metadata values for a custom metadata component. namespace metadata usage use metadata.custommetadatavalue to access values for custom fields of custom metadata records. supported apex primitive types are: • boolean • date • datetime • decimal • double • integer • long • string example // set a custom field value for a custom metadata record metadata.custommetadatavalue customfield = new metadata.custommetadatavalue(); customfield.field = 'customfield1__c'; customfield.value = 'new value'; custommetadata.values.add(customfield); in this section: custommetadatavalue properties custommetadatavalue methods custommetadatavalue properties the following are properties for custommetadatavalue. 2357apex reference guide custommetadatavalue class in this section: field the field name for the custom metadata value. value the field value for the custom metadata value. field the field name for the custom metadata value. signature public string field {get; set;} property value type: string value the field value for the custom metadata value. signature public object value {get; set;} property value type: object supported apex primitive types are: • boolean • date • datetime • decimal • double • integer • long • string when setting the value for relationship fields, use the qualified api name of the related metadata, not the id. for more information, see primitive data types. custommetadatavalue methods the following are methods for custommetadatavalue. 2358apex reference guide deploycallback interface in this section: clone() makes a duplicate copy of the metadata.custommetadatavalue. clone() makes a duplicate copy of the metadata.custommetadatavalue
. signature public object clone() return value type: object deploycallback interface an interface for metadata deployment callback classes. namespace metadata usage you must provide a callback class for the asynchronous deployment of custom metadata through apex. this class must implement the metadata.deploycallback interface. salesforce calls your deploycallback.handleresult() method asynchronously once the queued deployment completes. because the callback is called as asynchronous apex after deployment, there may be a brief period where the deploy has completed, but your callback has not been called yet. in this section: deploycallback methods deploycallback example implementation deploycallback methods the following are methods for deploycallback. in this section: handleresult(var1, var2) method that is called when the asynchronous deployment of custom metadata completes. 2359apex reference guide deploycallbackcontext class handleresult(var1, var2) method that is called when the asynchronous deployment of custom metadata completes. signature public void handleresult(metadata.deployresult var1, metadata.deploycallbackcontext var2) parameters var1 type: metadata.deployresult the results of the asynchronous deployment. var2 type: metadata.deploycallbackcontext the context for the queued asynchronous deployment job. return value type: void deploycallback example implementation this is an example implementation of the metadata.deploycallback interface. public class mycallback implements metadata.deploycallback { public void handleresult(metadata.deployresult result, metadata.deploycallbackcontext context) { if (result.status == metadata.deploystatus.succeeded) { // deployment was successful } else { // deployment was not successful } } } the following example uses this implementation for a deployment. // setup callback and deploy mycallback callback = new mycallback(); metadata.operations.enqueuedeployment(mdcontainer, callback); deploycallbackcontext class represents context information for a deployment job. namespace metadata 2360apex reference guide deploycallbackcontext class usage after an asynchronous metadata deployment finishes, salesforce provides an instance ofmetadata.deploycallbackcontext in an asynchronous call to your implementation of handleresult() in your metadata.deploycallback class. example public void handleresult(metadata.deployresult result, metadata.deploycallbackcontext context) { // check the callback job id for the deployment id jobid = context.getcallbackjobid(); // ...process the results... } in this section: deploycallbackcontext methods deploycallbackcontext methods the following are methods for deploycallbackcontext. in this section: clone() makes a duplicate copy of the metadata.deploycallbackcontext. getcallbackjobid() gets the asynchronous apex job id for the callback job. clone() makes a duplicate copy of the metadata.deploycallbackcontext. signature public object clone() return value type: object getcallbackjobid() gets the asynchronous apex job id for the callback job. signature public id getcallbackjobid() 2361apex reference guide deploycontainer class return value type: id deploycontainer class represents a container for custom metadata components to be deployed. namespace metadata usage use metadata.deploycontainer to manage custom metadata components for deployment. a container must have one or more components before being deployed. example // use deploycontainer for deployment metadata.deploycontainer mdcontainer = new metadata.deploycontainer(); mdcontainer.addmetadata(custommetadata); ... // enqueue deploy metadata.operations.enqueuedeployment(mdcontainer, callback); in this section: deploycontainer methods deploycontainer methods the following are methods for deploycontainer. in this section: addmetadata(md) add a custom metadata component to the container. clone() makes a duplicate copy of the metadata.deploycontainer. getmetadata() retrieves a list of custom metadata components from the container. removemetadata(md) removes a metadata component from the container. removemetadatabyfullname(fullname) removes a metadata component from the container using the component’s full name. 2362apex reference guide deploycontainer class addmetadata(md) add a custom metadata component to the container. signature public void addmetadata(metadata.metadata md) parameters md type: metadata.metadata a custom metadata component class that derives from metadata.metadata. avoid adding components
to a metadata.deploycontainerthat have the same metadata.metadata.fullname because it causes deployment errors. return value type: void clone() makes a duplicate copy of the metadata.deploycontainer. signature public object clone() return value type: object getmetadata() retrieves a list of custom metadata components from the container. signature public list<metadata.metadata> getmetadata() return value type: list<metadata.metadata> removemetadata(md) removes a metadata component from the container. signature public boolean removemetadata(metadata.metadata md) 2363apex reference guide deploydetails class parameters md type: metadata.metadata metadata component to remove. return value type: boolean returns true if the container changed as a result of the call. removemetadatabyfullname(fullname) removes a metadata component from the container using the component’s full name. signature public boolean removemetadatabyfullname(string fullname) parameters fullname type: string full name of the component to remove. return value type: boolean returns true if the container changed as a result of the call. deploydetails class contains detailed information on deployed components. namespace metadata usage use this class to obtain a list of the successfully and unsuccessfully deployed components after a completed deployment by salesforce in your metadata.deploycallback results. in this section: deploydetails properties deploydetails methods 2364apex reference guide deploydetails class deploydetails properties the following are properties for deploydetails. in this section: componentfailures contains a list of information about components that failed to deploy. componentsuccesses contains a list of information about components that deployed successfully. componentfailures contains a list of information about components that failed to deploy. signature public list<metadata.deploymessage> componentfailures {get; set;} property value type: list<metadata.deploymessage> componentsuccesses contains a list of information about components that deployed successfully. signature public list<metadata.deploymessage> componentsuccesses {get; set;} property value type: list<metadata.deploymessage> deploydetails methods the following are methods for deploydetails. in this section: clone() makes a duplicate copy of the metadata.deploydetails. clone() makes a duplicate copy of the metadata.deploydetails. 2365apex reference guide deploymessage class signature public object clone() return value type: object deploymessage class represents result information for the deployment of a metadata component. namespace metadata usage use deploymessage to access detailed information about component deployments. salesforce provides a list of deploymessages for a completed deployment via the deploydetails and deployresults instances sent in the deploycallback.handleresult() callback. in this section: deploymessage properties deploymessage methods deploymessage properties the following are properties for deploymessage. in this section: changed determines whether the component was changed after deployment. if true, the component was changed as a result of the deployment. if false, the deployed component was the same as the corresponding component already in the org. columnnumber each component is represented by a text file. if an error occurs during deployment, this property represents the column of the text file where the error occurred. componenttype the metadata type of the component in the deployment. created if true, the component was created as a result of the deployment. if false, the component was modified as a result of the deployment. createddate the date and time when the component was created as a result of the deployment. 2366apex reference guide deploymessage class deleted if true, the component was deleted as a result of the deployment. if false, the component was either new or modified as result of the deployment. filename the name of the file in the metadata archive used to deploy the component. fullname full name for the custom metadata component. id id of the component that was deployed. linenumber each component is represented by a text file. if an error occurs during deployment, this field represents the line number of the text file where the error occurred. problem if an error or warning occurred, this field contains a description of the problem that caused the deployment to fail. problemtype indicates the problem type, for example, an error or warning. success indicates whether the component was successfully deployed (
true) or not (false). changed determines whether the component was changed after deployment. if true, the component was changed as a result of the deployment. if false, the deployed component was the same as the corresponding component already in the org. signature public boolean changed {get; set;} property value type: boolean columnnumber each component is represented by a text file. if an error occurs during deployment, this property represents the column of the text file where the error occurred. signature public integer columnnumber {get; set;} property value type: integer 2367apex reference guide deploymessage class componenttype the metadata type of the component in the deployment. signature public string componenttype {get; set;} property value type: string created if true, the component was created as a result of the deployment. if false, the component was modified as a result of the deployment. signature public boolean created {get; set;} property value type: boolean createddate the date and time when the component was created as a result of the deployment. signature public datetime createddate {get; set;} property value type: datetime deleted if true, the component was deleted as a result of the deployment. if false, the component was either new or modified as result of the deployment. signature public boolean deleted {get; set;} property value type: boolean 2368apex reference guide deploymessage class filename the name of the file in the metadata archive used to deploy the component. signature public string filename {get; set;} property value type: string fullname full name for the custom metadata component. signature public string fullname {get; set;} property value type: string id id of the component that was deployed. signature public id id {get; set;} property value type: id linenumber each component is represented by a text file. if an error occurs during deployment, this field represents the line number of the text file where the error occurred. signature public integer linenumber {get; set;} property value type: integer 2369apex reference guide deploymessage class problem if an error or warning occurred, this field contains a description of the problem that caused the deployment to fail. signature public string problem {get; set;} property value type: string problemtype indicates the problem type, for example, an error or warning. signature public metadata.deployproblemtype problemtype {get; set;} property value type: metadata.deployproblemtype success indicates whether the component was successfully deployed (true) or not (false). signature public boolean success {get; set;} property value type: boolean deploymessage methods the following are methods for deploymessage. in this section: clone() makes a duplicate copy of the metadata.deploymessage. clone() makes a duplicate copy of the metadata.deploymessage. 2370apex reference guide deployproblemtype enum signature public object clone() return value type: object deployproblemtype enum describes the problem type for an unsuccessful component deploy. enum values the following are the values of the metadata.deployproblemtype enum. value description error the deploy problem is an error. info the deploy problem is of type “info”. warning the deploy problem is a warning. see also: statuscode enum deployresult class represents the results of a metadata deployment. namespace metadata usage after an asynchronous metadata deployment finishes, salesforce provides an instance of metadata.deployresult in a call to your implementation of handleresult() in your metadata.deploycallback class. example public void handleresult(metadata.deployresult result, metadata.deploycallbackcontext context) { if (result.status == metadata.deploystatus.succeeded) { // deployment was successful } else { // deployment was not successful 2371apex reference guide deployresult class } } in this section: deployresult properties deployresult methods deployresult properties the following are properties for deployresult. in this section: canceledby id of the user who canceled the queued deployment. canceledbyname full name of the user who canceled the queued deployment. checkonly indicates whether the deployment checked only the validity of the deployed files without making changes in the org. a check-only deployment does
not deploy components or change the org in any way. completeddate date and time for when the deployment process ended. createdby id of the user who created the deployment job. createdbyname full name of the user who created the deployment job. createddate date and time the deployment job was first queued. details provides the details for components in a completed deployment. done indicates whether salesforce finished processing the deployment. errormessage message corresponding to the values in the errorstatuscode property, if any. errorstatuscode if an error occurs during deployment, a status code is returned. the message corresponding to the status code is returned in the errormessagefield property. id id of the deployment job. ignorewarnings specifies whether a deployment continues, even if the deployment generates warnings. 2372apex reference guide deployresult class lastmodifieddate date and time of the last update for the deployment process. messages a list of all the detail messages for a deployment. numbercomponenterrors the number of components that generated errors during the deployment. numbercomponentsdeployed the number of components deployed in the deployment process. use this value with the numbercomponentstotal property to get an estimate of the deployment’s progress. numbercomponentstotal the total number of components in the deployment. use this value with the numbercomponentsdeployed property to get an estimate of the deployment’s progress. rollbackonerror indicates whether any failure causes a complete rollback (true) or not (false) of the deployment. startdate date and time the deployment process began. statedetail indicates which component is being deployed. status indicates the current state of the deployment. success indicates whether the deployment was successful (true) or not (false). canceledby id of the user who canceled the queued deployment. signature public string canceledby {get; set;} property value type: string canceledbyname full name of the user who canceled the queued deployment. signature public string canceledbyname {get; set;} property value type: string 2373apex reference guide deployresult class checkonly indicates whether the deployment checked only the validity of the deployed files without making changes in the org. a check-only deployment does not deploy components or change the org in any way. signature public boolean checkonly {get; set;} property value type: boolean completeddate date and time for when the deployment process ended. signature public datetime completeddate {get; set;} property value type: datetime createdby id of the user who created the deployment job. signature public string createdby {get; set;} property value type: string createdbyname full name of the user who created the deployment job. signature public string createdbyname {get; set;} property value type: string 2374apex reference guide deployresult class createddate date and time the deployment job was first queued. signature public datetime createddate {get; set;} property value type: datetime details provides the details for components in a completed deployment. signature public metadata.deploydetails details {get; set;} property value type: metadata.deploydetails done indicates whether salesforce finished processing the deployment. signature public boolean done {get; set;} property value type: boolean errormessage message corresponding to the values in the errorstatuscode property, if any. signature public string errormessage {get; set;} property value type: string 2375apex reference guide deployresult class errorstatuscode if an error occurs during deployment, a status code is returned. the message corresponding to the status code is returned in the errormessagefield property. signature public string errorstatuscode {get; set;} property value type: string for a description of each status code value, see core data types used in api calls in the soap api developer guide. id id of the deployment job. signature public id id {get; set;} property value type: id ignorewarnings specifies whether a deployment continues, even if the deployment generates warnings. signature public boolean ignorewarnings {get; set;} property value type: boolean lastmodifieddate date and time of the last update for the deployment process. signature public datetime lastmodifieddate {get; set;} property value type: dat
etime 2376apex reference guide deployresult class messages a list of all the detail messages for a deployment. signature public list<metadata.deploymessage> messages {get; set;} property value type: list<metadata.deploymessage> numbercomponenterrors the number of components that generated errors during the deployment. signature public integer numbercomponenterrors {get; set;} property value type: integer numbercomponentsdeployed the number of components deployed in the deployment process. use this value with the numbercomponentstotal property to get an estimate of the deployment’s progress. signature public integer numbercomponentsdeployed {get; set;} property value type: integer numbercomponentstotal the total number of components in the deployment. use this value with the numbercomponentsdeployed property to get an estimate of the deployment’s progress. signature public integer numbercomponentstotal {get; set;} property value type: integer 2377apex reference guide deployresult class rollbackonerror indicates whether any failure causes a complete rollback (true) or not (false) of the deployment. signature public boolean rollbackonerror {get; set;} property value type: boolean startdate date and time the deployment process began. signature public datetime startdate {get; set;} property value type: datetime statedetail indicates which component is being deployed. signature public string statedetail {get; set;} property value type: string status indicates the current state of the deployment. signature public metadata.deploystatus status {get; set;} property value type: metadata.deploystatus success indicates whether the deployment was successful (true) or not (false). 2378apex reference guide deploystatus enum signature public boolean success {get; set;} property value type: boolean deployresult methods the following are methods for deployresult. in this section: clone() makes a duplicate copy of the metadata.deployresult. clone() makes a duplicate copy of the metadata.deployresult. signature public object clone() return value type: object deploystatus enum the result status of a deployment. usage metadata.deployresult.status uses this enum to describe the results of the deployment. enum values the following are the values of the metadata.deploystatus enum. value description canceled the queued deployment was canceled. canceling the queued deployment is being canceled. failed the deployment failed. inprogress the deployment has been started and is in progress. pending the deployment has been queued but not started. 2379apex reference guide feeditemtypeenum enum value description succeeded the deployment succeeded. succeededpartial the deployment succeeded, but some components might not have been successfully deployed. check metadata.deployresult for more details. feeditemtypeenum enum the type of feed item in a feed-based page layout. enum values the following are the values of the metadata.feeditemtypeenum enum. value description activityevent activity on tasks and events associated with a case. available only on case layouts. advancedtextpost group announcements posted on a feed. announcementpost not used. approvalpost approvals submitted on a feed. attacharticleevent activity related to attaching articles to cases. basictemplatefeeditem activity from the log a call action. available only on layouts for objects that support activities (tasks and events). calllogpost activity from the log a call action. available only on layouts for objects that support activities (tasks and events). canvaspost posts a canvas app makes on a feed. casecommentpost activity from the case note action. available only on case layouts. changestatuspost activity from the change status action. available only on case layouts. chattranscriptpost activity related to attaching chat transcripts to cases. available only on case layouts. collaborationgroupcreated creating a public group. collaborationgroupunarchived not used. contentpost attaching a file to a post. createrecordevent creating a record from the publisher. dashboardcomponentalert not used. dashboardcomponentsnapshot posting a dashboard snapshot on a feed. emailmessageevent activity from the email action. available only on case layouts. facebookpost not used. 2380apex reference guide feedlayout class value description linkpost attaching a url to a post
. milestoneevent changing the milestone status on a case. available only on case layouts. pollpost posting a poll on a feed. profileskillpost adding skills to a user’s chatter profile. questionpost posting a question on a feed. replypost activity from the portal action. available only on case layouts. rypplepost creating a thanks badge in wdc. socialpost activity on twitter from the social post action. testitem creating a text post from the publisher. textpost making a change or group of changes to a tracked field. trackedchange not used. undefined undefined feed item. userstatus not used. feedlayout class represents the values that define the feed view of a feed-based page layout. feed-based layouts are available on account, case, contact, lead, opportunity, custom, and external objects. they include a feed view and a detail view. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “feedlayout” in the metadata api developer guide. in this section: feedlayout properties feedlayout methods feedlayout properties the following are properties for feedlayout. 2381apex reference guide feedlayout class in this section: autocollapsepublisher specifies whether the publisher is collapsed when the page loads (true) or not (false). compactfeed specifies whether the feed-based page layout uses a compact feed (true) or not (false). if set to true, feed items on the page are collapsed by default, and the feed view has an updated design. feedfilterposition indicates where the feed filters list is included in the layout. feedfilters the individual filters displayed in the feed filters list. fullwidthfeed specifies whether the feed expands horizontally to take up all available space on the page (true) or not (false). hidesidebar specifies whether the sidebar is hidden (true) or not (false). highlightexternalfeeditems controls whether to highlight external feed items (true) or not (false). leftcomponents the individual components displayed in the left column of the feed view. rightcomponents lists the individual components displayed in the right column of the feed view. useinlinefiltersinconsole indicates whether to use inline filters in the salesforce console. autocollapsepublisher specifies whether the publisher is collapsed when the page loads (true) or not (false). signature public boolean autocollapsepublisher {get; set;} property value type: boolean compactfeed specifies whether the feed-based page layout uses a compact feed (true) or not (false). if set to true, feed items on the page are collapsed by default, and the feed view has an updated design. signature public boolean compactfeed {get; set;} 2382
apex reference guide feedlayout class property value type: boolean feedfilterposition indicates where the feed filters list is included in the layout. signature public metadata.feedlayoutfilterposition feedfilterposition {get; set;} property value type: feedlayoutfilterposition enum feedfilters the individual filters displayed in the feed filters list. signature public list<metadata.feedlayoutfilter> feedfilters {get; set;} property value type: list<feedlayoutfilter class>. fullwidthfeed specifies whether the feed expands horizontally to take up all available space on the page (true) or not (false). signature public boolean fullwidthfeed {get; set;} property value type: boolean hidesidebar specifies whether the sidebar is hidden (true) or not (false). signature public boolean hidesidebar {get; set;} property value type: boolean 2383apex reference guide feedlayout class highlightexternalfeeditems controls whether to highlight external feed items (true) or not (false). signature public boolean highlightexternalfeeditems {get; set;} property value type: boolean leftcomponents the individual components displayed in the left column of the feed view. signature public list<metadata.feedlayoutcomponent> leftcomponents {get; set;} property value type: list<feedlayoutcomponent class> rightcomponents lists the individual components displayed in the right column of the feed view. signature public list<metadata.feedlayoutcomponent> rightcomponents {get; set;} property value type: list<feedlayoutcomponent class> useinlinefiltersinconsole indicates whether to use inline filters in the salesforce console. signature public boolean useinlinefiltersinconsole {get; set;} property value type: boolean feedlayout methods the following are methods for feedlayout. 2384apex reference guide feedlayoutcomponent class in this section: clone() makes a duplicate copy of the metadata.feedlayout. clone() makes a duplicate copy of the metadata.feedlayout. signature public object clone() return value type: object feedlayoutcomponent class represents a component in the feed view of a feed-based page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “feedlayoutcomponent” in the metadata api developer guide. in this section: feedlayoutcomponent properties feedlayoutcomponent methods feedlayoutcomponent properties the following are properties for feedlayoutcomponent. see feedlayoutcomponent in the metadata api developer guide in this section: componenttype represents a component in the feed view of a feed-based page layout. the type of component is required. height the height, in pixels, of the component. doesn’t apply to standardcomponents page_x the name of the visualforce page used as a custom component. 2385apex reference guide feedlayoutcomponent class componenttype represents a component in the feed view of a feed-based page layout. the type of component is required. signature public metadata.feedlayoutcomponenttype componenttype {get; set;} property value type: metadata.feedlayoutcomponenttype on page 2387 height the height, in pixels, of the component. doesn’t apply to standardcomponents signature public integer height {get; set;} property value type: integer page_x the name of the visualforce page used as a custom component. signature public string page_x {get; set;} property value type: string feedlayoutcomponent methods the following are methods for feedlayoutcomponent. in this section: clone() makes a duplicate copy of the metadata.feedlayoutcomponent. clone() makes a duplicate copy of the metadata.feedlayoutcomponent. 2386apex reference guide feedlayoutcomponenttype enum signature public object clone() return value type: object feedlayoutcomponenttype enum indicates the type of feed layout component. enum values the following are the values of the metadata.feedlayoutcomponenttype enum. value description caseexperts list of case experts. caseunifiedfiles list of all files attached to the case. custombuttons custom button. customlinks custom link. followers list of followers. following icon that toggles between a follow button (if the user viewing a record doesn’t already follow it) and a following indicator (
if the user viewing a record does follow it). helpandtoollinks icons that link to the help topic for the page, the page layout, and, the printable view of the page. available only on case layouts. milestones milestone tracker, which lets users see the status of a milestone on a case. available only on case layouts. similarcases list of similar cases. topics list of topics related to the record. visualforce custom visualforce component. feedlayoutfilter class represents a feed filter option in the feed view of a feed-based page layout. a filter can have only standardfilter or feeditemtype set. namespace metadata 2387apex reference guide feedlayoutfilter class usage use this class when accessing metadata.layout metadata components. for more information, see “feedlayoutfilter” in the metadata api developer guide. in this section: feedlayoutfilter properties feedlayoutfilter methods feedlayoutfilter properties the following are properties for feedlayoutfilter. in this section: feedfiltername the name of a customfeedfilter component. names are prefixed with the name of the parent object. for example, case.mycustomfeedfilter. feedfiltertype the type of filter. feeditemtype the type of feed item to display. feedfiltername the name of a customfeedfilter component. names are prefixed with the name of the parent object. for example, case.mycustomfeedfilter. signature public string feedfiltername {get; set;} property value type: string feedfiltertype the type of filter. signature public metadata.feedlayoutfiltertype feedfiltertype {get; set;} property value type: feedlayoutfiltertype enum 2388apex reference guide feedlayoutfilterposition enum feeditemtype the type of feed item to display. signature public metadata.feeditemtypeenum feeditemtype {get; set;} property value type: feeditemtypeenum enum feedlayoutfilter methods the following are methods for feedlayoutfilter. in this section: clone() makes a duplicate copy of the metadata.feedlayoutfilter. clone() makes a duplicate copy of the metadata.feedlayoutfilter. signature public object clone() return value type: object feedlayoutfilterposition enum describes where the feed filters list is included in the layout. enum values the following are the values of the metadata.feedlayoutfilterposition enum. value description centerdropdown as a drop-down list in the center column. leftfixed as a fixed list in the left column. leftfloat as a floating list in the left column. 2389apex reference guide feedlayoutfiltertype enum feedlayoutfiltertype enum the type of feed layout filter. enum values the following are the values of the metadata.feedlayoutfiltertype enum. value description allupdates shows all feed items on a record. custom shows custom feed items. feeditemtype shows feed items only for a particular type of activity on the record. layout class represents the metadata associated with a page layout. namespace metadata usage use this class to access layout metadata components. for more information, see layout in the metadata api developer guide. in this section: layout properties layout methods layout properties the following are properties for layout. in this section: custombuttons the custom buttons for this layout. customconsolecomponents represents custom console components (visualforce pages, lookup fields, or related lists) on a page layout. emaildefault default value for the email checkbox. only relevant if the showemailcheckbox property is set. excludebuttons list of standard buttons to exclude from this layout. 2390apex reference guide layout class feedlayout represents the values that define the feed view of a feed-based page layout. headers represents the layout headers used for tagging. layoutsections the main sections of the layout containing fields, s-controls, and custom links. the order here determines the layout order. minilayout represents a minilayout, which is used in the mini view of a record in the console tab, hover details, and event overlays. multilinelayoutfields fields for special multiline layout fields which appear in opportunityproduct layouts. platformactionlist the list of actions, and their order, that display in the salesforce mobile action bar for the layout. quickactionlist the list of quick actions that display in the full salesforce site
for the page layout. relatedcontent the related content section of the page layout. relatedlists the related lists for the layout, listed in the order they appear in the user interface. relatedobjects the list of related objects that appears in the mini view of the console. runassignmentrulesdefault default value for the “run assignment rules” checkbox. only relevant if the showrunassignmentrulescheckbox property is set. showemailcheckbox controls whether to show the email checkbox. only allowed on case, caseclose, and task layouts. the default state of checkbox is controlled by the emaildefault property. showhighlightspanel if set, the highlights panel displays on pages in the salesforce console. showinteractionlogpanel if set, the interaction log displays on pages in the salesforce console. showknowledgecomponent only allowed on case layouts. if set, the knowledge sidebar displays on cases in the salesforce console. showrunassignmentrulescheckbox controls whether to show the run assignment rules checkbox. only allowed on lead and case layouts. the default state of checkbox is controlled by the runassignmentrulesdefault property. showsolutionsection only allowed on caseclose layout. if set, the built-in solution information section shows up on the page. showsubmitandattachbutton for cast layouts only. if set, the submit & add attachment button displays on case edit pages to portal users in the customer portal. summarylayout the summary layout for this layout. 2391apex reference guide layout class custombuttons the custom buttons for this layout. signature public list<string> custombuttons {get; set;} property value type: list<string> customconsolecomponents represents custom console components (visualforce pages, lookup fields, or related lists) on a page layout. signature public metadata.customconsolecomponents customconsolecomponents {get; set;} property value type: customconsolecomponents class emaildefault default value for the email checkbox. only relevant if the showemailcheckbox property is set. signature public boolean emaildefault {get; set;} property value type: boolean excludebuttons list of standard buttons to exclude from this layout. signature public list<string> excludebuttons {get; set;} property value type: list<string> feedlayout represents the values that define the feed view of a feed-based page layout. 2392apex reference guide layout class signature public metadata.feedlayout feedlayout {get; set;} property value type: metadata.feedlayout headers represents the layout headers used for tagging. signature public list<metadata.layoutheader> headers {get; set;} property value type: list<metadata.layoutheader> layoutsections the main sections of the layout containing fields, s-controls, and custom links. the order here determines the layout order. signature public list<metadata.layoutsection> layoutsections {get; set;} property value type: list<metadata.layoutsection> minilayout represents a minilayout, which is used in the mini view of a record in the console tab, hover details, and event overlays. signature public metadata.minilayout minilayout {get; set;} property value type: metadata.minilayout multilinelayoutfields fields for special multiline layout fields which appear in opportunityproduct layouts. signature public list<string> multilinelayoutfields {get; set;} 2393apex reference guide layout class property value type: list<string> platformactionlist the list of actions, and their order, that display in the salesforce mobile action bar for the layout. signature public metadata.platformactionlist platformactionlist {get; set;} property value type: metadata.platformactionlist quickactionlist the list of quick actions that display in the full salesforce site for the page layout. signature public metadata.quickactionlist quickactionlist {get; set;} property value type: meatadata.quickactionl. relatedcontent the related content section of the page layout. signature public metadata.relatedcontent relatedcontent {get; set;} property value type: metadata.relatedcontent relatedlists the related lists for the layout, listed in the order they appear in the user interface. signature public list<metadata.relatedlistitem> relatedlists {get; set;}
property value type: list<metadata.relatedlistitem> 2394apex reference guide layout class relatedobjects the list of related objects that appears in the mini view of the console. signature public list<string> relatedobjects {get; set;} property value type: list<string> runassignmentrulesdefault default value for the “run assignment rules” checkbox. only relevant if the showrunassignmentrulescheckbox property is set. signature public boolean runassignmentrulesdefault {get; set;} property value type: boolean showemailcheckbox controls whether to show the email checkbox. only allowed on case, caseclose, and task layouts. the default state of checkbox is controlled by the emaildefault property. signature public boolean showemailcheckbox {get; set;} property value type: boolean showhighlightspanel if set, the highlights panel displays on pages in the salesforce console. signature public boolean showhighlightspanel {get; set;} property value type: boolean 2395apex reference guide layout class showinteractionlogpanel if set, the interaction log displays on pages in the salesforce console. signature public boolean showinteractionlogpanel {get; set;} property value type: boolean showknowledgecomponent only allowed on case layouts. if set, the knowledge sidebar displays on cases in the salesforce console. signature public boolean showknowledgecomponent {get; set;} property value type: boolean showrunassignmentrulescheckbox controls whether to show the run assignment rules checkbox. only allowed on lead and case layouts. the default state of checkbox is controlled by the runassignmentrulesdefault property. signature public boolean showrunassignmentrulescheckbox {get; set;} property value type: boolean showsolutionsection only allowed on caseclose layout. if set, the built-in solution information section shows up on the page. signature public boolean showsolutionsection {get; set;} property value type: boolean 2396apex reference guide layoutcolumn class showsubmitandattachbutton for cast layouts only. if set, the submit & add attachment button displays on case edit pages to portal users in the customer portal. signature public boolean showsubmitandattachbutton {get; set;} property value type: boolean summarylayout the summary layout for this layout. signature public metadata.summarylayout summarylayout {get; set;} property value type: metadata.summarylayout layout methods the following are methods for layout. in this section: clone() makes a duplicate copy of the metadata.layout. clone() makes a duplicate copy of the metadata.layout. signature public object clone() return value type: object layoutcolumn class represents the items in a column within a layout section. 2397apex reference guide layoutcolumn class namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “layoutcolumn” in the metadata api developer guide. in this section: layoutcolumn properties layoutcolumn methods layoutcolumn properties the following are properties for layoutcolumn. in this section: layoutitems the individual items within a column (ordered from top to bottom). reserved this field is reserved for salesforce. layoutitems the individual items within a column (ordered from top to bottom). signature public list<metadata.layoutitem> layoutitems {get; set;} property value type: list<metadata.layoutitem> reserved this field is reserved for salesforce. signature public string reserved {get; set;} property value type: string 2398apex reference guide layoutheader enum layoutcolumn methods the following are methods for layoutcolumn. in this section: clone() makes a duplicate copy of the metadata.layoutcolumn. clone() makes a duplicate copy of the metadata.layoutcolumn. signature public object clone() return value type: object layoutheader enum represents tagging types used for metadata.layout.headers enum values the following are the values of the metadata.layoutheader enum. value description personaltagging tag is set to private user. publictagging tag is viewable to any user who can access the record. layoutitem class represents the valid values that define a layout item. namespace metadata usage use this class when accessing metadata.layout metadata components
. for more information, see “layoutitem” in the metadata api developer guide. 2399apex reference guide layoutitem class in this section: layoutitem properties layoutitem methods layoutitem properties the following are properties for layoutitem. in this section: analyticscloudcomponent a wave analytics dashboard component on a page. behavior determines the field behavior. canvas references a canvas app. component references a component. customlink the custom link reference. emptyspace controls if this layout item is a blank space. field the field name reference, relative to the layout, for example “description” or “myfield__c”. height for s-controls and pages only, the height in pixels. page_x reference to a visualforce page. reportchartcomponent refers to a report chart that you can add to a standard or custom object page. scontrol reference to an s-control. showlabel for s-control and pages only, whether to show the label. showscrollbars for s-control and pages only, whether to show scrollbars. width for s-control and pages only, the width in pixels or percent. pixel values are simply the number of pixels, for example, 500. percentage values must include the percent sign, for example, 20%. analyticscloudcomponent a wave analytics dashboard component on a page. 2400apex reference guide layoutitem class signature public metadata.analyticscloudcomponentlayoutitem analyticscloudcomponent {get; set;} property value type: metadata.analyticscloudcomponentlayoutitem behavior determines the field behavior. signature public metadata.uibehavior behavior {get; set;} property value type: metadata.uibehavior canvas references a canvas app. signature public string canvas {get; set;} property value type: string component references a component. signature public string component {get; set;} property value type: string customlink the custom link reference. signature public string customlink {get; set;} 2401apex reference guide layoutitem class property value type: string emptyspace controls if this layout item is a blank space. signature public boolean emptyspace {get; set;} property value type: boolean field the field name reference, relative to the layout, for example “description” or “myfield__c”. signature public string field {get; set;} property value type: string height for s-controls and pages only, the height in pixels. signature public integer height {get; set;} property value type: integer page_x reference to a visualforce page. signature public string page_x {get; set;} property value type: string 2402apex reference guide layoutitem class reportchartcomponent refers to a report chart that you can add to a standard or custom object page. signature public metadata.reportchartcomponentlayoutitem reportchartcomponent {get; set;} property value type: metadata.reportchartcomponentlayoutitem scontrol reference to an s-control. signature public string scontrol {get; set;} property value type: string showlabel for s-control and pages only, whether to show the label. signature public boolean showlabel {get; set;} property value type: boolean showscrollbars for s-control and pages only, whether to show scrollbars. signature public boolean showscrollbars {get; set;} property value type: boolean 2403apex reference guide layoutsection class width for s-control and pages only, the width in pixels or percent. pixel values are simply the number of pixels, for example, 500. percentage values must include the percent sign, for example, 20%. signature public string width {get; set;} property value type: string layoutitem methods the following are methods for layoutitem. in this section: clone() makes a duplicate copy of the metadata.layoutitem. clone() makes a duplicate copy of the metadata.layoutitem. signature public object clone() return value type: object layoutsection class represents a section of a page layout, such as the custom links section. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “layout
section” in the metadata api developer guide. in this section: layoutsection properties 2404apex reference guide layoutsection class layoutsection methods layoutsection properties the following are properties for layoutsection. in this section: customlabel indicates if this section's label is custom or standard (built-in). detailheading controls if this section appears in the detail page. editheading controls if this section appears in the edit page. label the label; either standard or custom, based on the customlabel property. layoutcolumns lists the layout columns. you can have one, two, or three columns, ordered left to right, are possible. style the style of the layout for this section. customlabel indicates if this section's label is custom or standard (built-in). signature public boolean customlabel {get; set;} property value type: boolean detailheading controls if this section appears in the detail page. signature public boolean detailheading {get; set;} property value type: boolean editheading controls if this section appears in the edit page. 2405apex reference guide layoutsection class signature public boolean editheading {get; set;} property value type: boolean label the label; either standard or custom, based on the customlabel property. signature public string label {get; set;} property value type: string layoutcolumns lists the layout columns. you can have one, two, or three columns, ordered left to right, are possible. signature public list<metadata.layoutcolumn> layoutcolumns {get; set;} property value type: list<metadata.layoutcolumn> style the style of the layout for this section. signature public metadata.layoutsectionstyle style {get; set;} property value type: metadata.layoutsectionstyle layoutsection methods the following are methods for layoutsection. 2406apex reference guide layoutsectionstyle enum in this section: clone() makes a duplicate copy of the metadata.layoutsection. clone() makes a duplicate copy of the metadata.layoutsection. signature public object clone() return value type: object layoutsectionstyle enum describes the possible styles for a layout section. enum values the following are the values of the metadata.layoutsectionstyle enum. value description customlinks contains custom links only onecolumn one column twocolumnslefttoright two columns, tab goes left to right twocolumnstoptobottom two columns, tab goes top to bottom metadata class an abstract base class that represents a custom metadata component. namespace metadata usage you can’t create instances of this abstract class. instead, create an instance of a specific custom metadata component class that derives from metadata.metadata, such as metadata.custommetadata. for more information, see metadata in the metadata api developer guide. 2407apex reference guide metadata class in this section: metadata properties metadata methods metadata properties the following are properties for metadata. in this section: fullname the full name of the custom metadata, which can include the namespace, type, and component name. fullname the full name of the custom metadata, which can include the namespace, type, and component name. signature public string fullname {get; set;} property value type: string the format of the full name can include the namespace, metadata type, and metadata component name. if you’re updating components in a namespace, you also need to qualify the namespace for the component in the full name. for example, the full name for a custom metadata "mdtype1__mdt" component named "component1" that is contained in the "mypackage" namespace is "mypackage__mdtype1__mdt.mypackage__component1". for more information on full name formats for different metadata types, see reference documentation on the metadata types in the metadata api developer guide. metadata methods the following are methods for metadata. in this section: clone() makes a duplicate copy of the metadata.metadata. clone() makes a duplicate copy of the metadata.metadata. signature public object clone() 2408apex reference guide metadatatype enum return value type: object metadatatype enum represents the custom metadata components available in apex. enum values the following are the values of the met
adata.metadatatype enum. value description custommetadata records of custom metadata types layout layouts metadatavalue class an abstract base class that represents a custom metadata component field. namespace metadata usage you can’t create instances of this abstract class. instead, create an instance of a specific custom metadata component value class that derives from metadata.metadatavalue, such as metadata.custommetadatavalue. in this section: metadatavalue methods metadatavalue methods the following are methods for metadatavalue. in this section: clone() makes a duplicate copy of the metadata.metadatavalue. clone() makes a duplicate copy of the metadata.metadatavalue. 2409apex reference guide minilayout class signature public object clone() return value type: object minilayout class represents a mini view of a record in the console tab, hover details, and event overlays. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “minilayout” in the metadata api developer guide. in this section: minilayout properties minilayout methods minilayout properties the following are properties for minilayout. in this section: fields the fields for the mini-layout, listed in the order they appear in the ui. fields that appear in the mini-layout must appear in the main layout. relatedlists the mini related lists, listed in the order they appear in the ui. you cannot set sorting on mini related lists. fields that appear in the mini related lists must appear in the main layout. fields the fields for the mini-layout, listed in the order they appear in the ui. fields that appear in the mini-layout must appear in the main layout. signature public list<string> fields {get; set;} 2410apex reference guide operations class property value type: list<string> relatedlists the mini related lists, listed in the order they appear in the ui. you cannot set sorting on mini related lists. fields that appear in the mini related lists must appear in the main layout. signature public list<metadata.relatedlistitem> relatedlists {get; set;} property value type: list<metadata.relatedlistitem> minilayout methods the following are methods for minilayout. in this section: clone() makes a duplicate copy of the metadata.minilayout. clone() makes a duplicate copy of the metadata.minilayout. signature public object clone() return value type: object operations class represents a class to execute metadata operations, such as retrieving or deploying custom metadata. namespace metadata usage use the metadata.operations class to execute metadata operations. for more information on use cases and restrictions of metadata operations in apex, see metadata. 2411apex reference guide operations class example: retrieve metadata the following example retrieves the “mytestcustommdtype” custom metadata record from the subscriber org, and inspects the custom fields. public class readmetadata { public void retrievemetadata () { // list fullnames of components we want to retrieve list<string> componentnamelist = new list<string>{'isvnamespace__testcustommdtype.mytestcustommdtype'}; // retrieve components that are records of custom metadata types // based on name list<metadata.metadata> components = metadata.operations.retrieve( metadata.metadatatype.custommetadata, componentnamelist); metadata.custommetadata custommetadatarecord = (metadata.custommetadata) components.get(0); // check fields of retrieved component list<metadata.custommetadatavalue> values = custommetadatarecord.values; for (integer i = 0; i < values.size(); i++) { if (values.get(i).field == 'testfield__c' && values.get(i).value == 'desired value') { // ...process accordingly... } } } } example: deploy metadata the following example uses the metadata api in apex to update the customfield custom field value of the metadatarecordname custom metadata record and deploy this change into the subscriber org. because the deployment is asynchronous, you must provide a callback class that implements the metadata.deploycallback interface, which is then used when the queued deployment completes. public class createmetadata{ public void updateanddeploymetadata
() { // setup custom metadata to be created in the subscriber org. metadata.custommetadata custommetadata = new metadata.custommetadata(); custommetadata.fullname = 'isvnamespace__metadatatypename.metadatarecordname'; metadata.custommetadatavalue customfield = new metadata.custommetadatavalue(); customfield.field = 'customfield__c'; customfield.value = 'new value'; custommetadata.values.add(customfield); metadata.deploycontainer mdcontainer = new metadata.deploycontainer(); mdcontainer.addmetadata(custommetadata); // setup deploy callback, mydeploycallback implements // the metadata.deploycallback interface (code for // this class not shown in this example) mydeploycallback callback = new mydeploycallback(); 2412apex reference guide operations class // enqueue custom metadata deployment id jobid = metadata.operations.enqueuedeployment(mdcontainer, callback); } } example: create two metadata records synchronously create a metadata record along with another one that references it in the same transaction. if the parent record was installed with a namespace, prefix the developer name with recordns__. note: no custom metadata relationship can relate records of the same type to each other. public class createmetadata { public id docreate( string parentrecdevname, string parentreclabel, string childrecdevname, string childreclabel) { metadata.deploycontainer mdcontainer = new metadata.deploycontainer(); metadata.custommetadata parentrecord = new metadata.custommetadata(); parentrecord.fullname = 'parenttype.' + parentrecdevname; parentrecord.label = parentreclabel; mdcontainer.addmetadata(parentrecord); metadata.custommetadata childrecord = new metadata.custommetadata(); childrecord.fullname = 'childtype.' + childrecdevname; childrecord.label = childreclabel; metadata.custommetadatavalue relvalue = new metadata.custommetadatavalue(); relvalue.field = 'parent__c'; relvalue.value = parentrecdevname; childrecord.values.add(relvalue); mdcontainer.addmetadata(childrecord); id jobid = metadata.operations.enqueuedeployment(mdcontainer, null); return jobid; } } in this section: operations methods operations methods the following are methods for operations. 2413apex reference guide operations class in this section: clone() makes a duplicate copy of the metadata.operations. enqueuedeployment(container, callback) deploys custom metadata components asynchronously. retrieve(type, fullnames) retrieves a list of custom metadata components. clone() makes a duplicate copy of the metadata.operations. signature public object clone() return value type: object enqueuedeployment(container, callback) deploys custom metadata components asynchronously. signature public static id enqueuedeployment(metadata.deploycontainer container, metadata.deploycallback callback) parameters container type: metadata.deploycontainer container that contains the set of metadata components to deploy. callback type: metadata.deploycallback a class that implements the metadata.deploycallback interface. used by salesforce to return information about the deployment results. return value type: id id of deployment request. retrieve(type, fullnames) retrieves a list of custom metadata components. 2414apex reference guide platformactionlist class signature public static list<metadata.metadata> retrieve(metadata.metadatatype type, list<string> fullnames) parameters type type: metadata.metadatatype the metadata component type. fullnames type: list<string> a list of component names to retrieve. for information on component name formats, see metadata.fullname(). return value type: list<metadata.metadata> platformactionlist class represents the list of actions, and their order, that display in the salesforce mobile action bar for the layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “platformactionlist” in the metadata api developer guide. in this section: platformactionlist properties platformactionlist methods platformactionlist properties the following are properties for platformactionlist. in this section
: actionlistcontext the context of the action list. platformactionlistitems the actions in the platform action list. 2415apex reference guide platformactionlist class relatedsourceentity when the actionlistcontext property is “relatedlist” or” “relatedlistrecord”, this field represents the api name of the related list to which the action belongs. actionlistcontext the context of the action list. signature public metadata.platformactionlistcontextenum actionlistcontext {get; set;} property value type: metadata.platformactionlistcontextenum platformactionlistitems the actions in the platform action list. signature public list<metadata.platformactionlistitem> platformactionlistitems {get; set;} property value type: list<metadata.platformactionlistitem> relatedsourceentity when the actionlistcontext property is “relatedlist” or” “relatedlistrecord”, this field represents the api name of the related list to which the action belongs. signature public string relatedsourceentity {get; set;} property value type: string platformactionlist methods the following are methods for platformactionlist. in this section: clone() makes a duplicate copy of the metadata.platformactionlist. 2416apex reference guide platformactionlistcontextenum enum clone() makes a duplicate copy of the metadata.platformactionlist. signature public object clone() return value type: object platformactionlistcontextenum enum describes the different contexts of action lists. enum values the following are the values of the metadata.platformactionlistcontextenum enum. value description actiondefinition action definition context. assistant assistant context. bannerphoto banner photo context. chatter chatter context. dockable dockable context. feedelement feed element context. flexipage flexipage context. global_x global context. listview listview context. listviewdefinition listview definition context. listviewrecord listview record context. lookup lookup context. mrulist mru list context. mrurow mru row context. objecthomechart object home chart context. photo photo context record record context. recordedit record edit context 2417apex reference guide platformactionlistitem class value description relatedlist related list context. relatedlistrecord related list record context. platformactionlistitem class represents an action in the platform action list for a layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “platformactionlistitem” in the metadata api developer guide. in this section: platformactionlistitem properties platformactionlistitem methods platformactionlistitem properties the following are properties for platformactionlistitem. in this section: actionname the api name for the action in the list. actiontype the type of action. sortorder the placement of the action in the list. subtype the subtype of the action. actionname the api name for the action in the list. signature public string actionname {get; set;} 2418apex reference guide platformactionlistitem class property value type: string actiontype the type of action. signature public metadata.platformactiontypeenum actiontype {get; set;} property value type: metadata.platformactiontypeenum sortorder the placement of the action in the list. signature public integer sortorder {get; set;} property value type: integer subtype the subtype of the action. signature public string subtype {get; set;} property value type: string platformactionlistitem methods the following are methods for platformactionlistitem. in this section: clone() makes a duplicate copy of the metadata.platformactionlistitem. 2419apex reference guide platformactiontypeenum enum clone() makes a duplicate copy of the metadata.platformactionlistitem. signature public object clone() return value type: object platformactiontypeenum enum the type of action for a platformactionlistitem. enum values the following are the values of the metadata.platformactiontypeenum enum. value description actionlink an indicator on a feed element that targets an api, a web page, or a file, represented by a button in the salesforce chatter feed ui. custombutton
when clicked, opens a url or a visualforce page in a window or executes javascript. invocableaction an invocable action such as posting to chatter. productivityaction productivity actions are predefined by salesforce and are attached to a limited set of objects. you can’t edit or delete productivity actions. quickaction a global or object-specific action. standardbutton a predefined salesforce button such as new, edit, and delete. primarytabcomponents class represents custom console components on primary tabs in the salesforce console. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “primarytabcomponents” in the metadata api developer guide. 2420apex reference guide primarytabcomponents class in this section: primarytabcomponents properties primarytabcomponents methods primarytabcomponents properties the following are properties for primarytabcomponents. in this section: component represents a custom console component (visualforce page, lookup field, or related lists) on a section of a page layout. containers represents a location and style in which to display more than one custom console component on the sidebars of the salesforce console. component represents a custom console component (visualforce page, lookup field, or related lists) on a section of a page layout. signature public list<metadata.consolecomponent> component {get; set;} property value type: list<metadata.consolecomponent> containers represents a location and style in which to display more than one custom console component on the sidebars of the salesforce console. signature public list<metadata.container> containers {get; set;} property value type: list<metadata.container> primarytabcomponents methods the following are methods for primarytabcomponents. in this section: clone() makes a duplicate copy of the metadata.primarytabcomponents. 2421apex reference guide quickactionlist class clone() makes a duplicate copy of the metadata.primarytabcomponents. signature public object clone() return value type: object quickactionlist class represents the list of actions associated with the page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “quickactionlist” in the metadata api developer guide. in this section: quickactionlist properties quickactionlist methods quickactionlist properties the following are properties for quickactionlist. in this section: quickactionlistitems list of quickactionlist objects. quickactionlistitems list of quickactionlist objects. signature public list<metadata.quickactionlistitem> quickactionlistitems {get; set;} property value type: list<metadata.quickactionlistitem> 2422apex reference guide quickactionlistitem class quickactionlist methods the following are methods for quickactionlist. in this section: clone() makes a duplicate copy of the metadata.quickactionlist. clone() makes a duplicate copy of the metadata.quickactionlist. signature public object clone() return value type: object quickactionlistitem class represents an action in the quickactionlist. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “quickactionlistitem” in the metadata api developer guide. in this section: quickactionlistitem properties quickactionlistitem methods quickactionlistitem properties the following are properties for quickactionlistitem. in this section: quickactionname the api name of the action. 2423apex reference guide relatedcontent class quickactionname the api name of the action. signature public string quickactionname {get; set;} property value type: string quickactionlistitem methods the following are methods for quickactionlistitem. in this section: clone() makes a duplicate copy of the metadata.quickactionlistitem. clone() makes a duplicate copy of the metadata.quickactionlistitem. signature public object clone() return value type: object relatedcontent class represents the mobile cards section of the page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “relatedcontent” in the metadata api developer guide. in this section: relatedcontent properties related
content methods 2424apex reference guide relatedcontentitem class relatedcontent properties the following are properties for relatedcontent. in this section: relatedcontentitems a list of layout items in the mobile cards section of the page layout. relatedcontentitems a list of layout items in the mobile cards section of the page layout. signature public list<metadata.relatedcontentitem> relatedcontentitems {get; set;} property value type: list<metadata.relatedcontentitem> relatedcontent methods the following are methods for relatedcontent. in this section: clone() makes a duplicate copy of the metadata.relatedcontent. clone() makes a duplicate copy of the metadata.relatedcontent. signature public object clone() return value type: object relatedcontentitem class represents an individual item in the relatedcontent list. namespace metadata 2425apex reference guide relatedcontentitem class usage use this class when accessing metadata.layout metadata components. for more information, see “relatedcontentitem” in the metadata api developer guide. in this section: relatedcontentitem properties relatedcontentitem methods relatedcontentitem properties the following are properties for relatedcontentitem. in this section: layoutitem an individual layout item in the mobile cards section. layoutitem an individual layout item in the mobile cards section. signature public metadata.layoutitem layoutitem {get; set;} property value type: metadata.layoutitem relatedcontentitem methods the following are methods for relatedcontentitem. in this section: clone() makes a duplicate copy of the metadata.relatedcontentitem. clone() makes a duplicate copy of the metadata.relatedcontentitem. signature public object clone() 2426apex reference guide relatedlist class return value type: object relatedlist class represents related list custom components on the sidebars of the salesforce console. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “relatedlist” in the metadata api developer guide. in this section: relatedlist properties relatedlist methods relatedlist properties the following are properties for relatedlist. in this section: hideondetail when set to true, the related list is hidden from detail pages where it appears as a component to prevent duplicate information from showing. name the name of the component as it appears to console users. hideondetail when set to true, the related list is hidden from detail pages where it appears as a component to prevent duplicate information from showing. signature public boolean hideondetail {get; set;} property value type: boolean 2427apex reference guide relatedlistitem class name the name of the component as it appears to console users. signature public string name {get; set;} property value type: string relatedlist methods the following are methods for relatedlist. in this section: clone() makes a duplicate copy of the metadata.relatedlist. clone() makes a duplicate copy of the metadata.relatedlist. signature public object clone() return value type: object relatedlistitem class represents an item in the related list in a page layout. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “relatedlistitem” in the metadata api developer guide. in this section: relatedlistitem properties relatedlistitem methods 2428apex reference guide relatedlistitem class relatedlistitem properties the following are properties for relatedlistitem. in this section: custombuttons a list of custom buttons used in the related list. excludebuttons a list of excluded related-list buttons. fields a list of fields displayed in the related list. uses aliases instead of field or api names. relatedlist the name of the related list. sortfield the name of the field used for sorting. sortorder when sortfield is set, the sortorder property determines the sort order. custombuttons a list of custom buttons used in the related list. signature public list<string> custombuttons {get; set;} property value type: list<string> for more information, see “define custom buttons and links” in the salesforce online help. excludebuttons a list of excluded related-list buttons. signature public list<string> excludebuttons
{get; set;} property value type: list<string> fields a list of fields displayed in the related list. uses aliases instead of field or api names. 2429apex reference guide relatedlistitem class signature public list<string> fields {get; set;} property value type: list<string> relatedlist the name of the related list. signature public string relatedlist {get; set;} property value type: string sortfield the name of the field used for sorting. signature public string sortfield {get; set;} property value type: string sortorder when sortfield is set, the sortorder property determines the sort order. signature public metadata.sortorder sortorder {get; set;} property value type: metadata.sortorder relatedlistitem methods the following are methods for relatedlistitem. 2430apex reference guide reportchartcomponentlayoutitem class in this section: clone() makes a duplicate copy of the metadata.relatedlistitem. clone() makes a duplicate copy of the metadata.relatedlistitem. signature public object clone() return value type: object reportchartcomponentlayoutitem class represents the settings for a report chart on a standard or custom page. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “reportchartcomponentlayoutitem” in the metadata api developer guide. in this section: reportchartcomponentlayoutitem properties reportchartcomponentlayoutitem methods reportchartcomponentlayoutitem properties the following are properties for reportchartcomponentlayoutitem. in this section: cachedata indicates whether to use cached data when displaying the chart. when the attribute is set to true, data is cached for 24 hours. when the attribute is set to false, the report is run every time the page is refreshed. contextfilterablefield unique development name of the field by which a report chart is filtered to return data relevant to the page. if set, the id field for the parent object of the page or report type is the chart data filter. the parent object for the report type and the page must match for a chart to return relevant data. 2431apex reference guide reportchartcomponentlayoutitem class error error string that is populated only when an error occurs in the underlying report. hideonerror controls whether users see a chart that has an error. when an error occurs and this attribute is not set, the chart doesn’t show any data except the error. set the attribute to true to hide the chart from a page on error. includecontext if true, filters the report chart to return data that’s relevant to the page. reportname unique development name of a report that includes a chart. showtitle if true, applies the title from the report to the chart. size size of the displayed chart. the default is medium. cachedata indicates whether to use cached data when displaying the chart. when the attribute is set to true, data is cached for 24 hours. when the attribute is set to false, the report is run every time the page is refreshed. signature public boolean cachedata {get; set;} property value type: boolean contextfilterablefield unique development name of the field by which a report chart is filtered to return data relevant to the page. if set, the id field for the parent object of the page or report type is the chart data filter. the parent object for the report type and the page must match for a chart to return relevant data. signature public string contextfilterablefield {get; set;} property value type: string error error string that is populated only when an error occurs in the underlying report. signature public string error {get; set;} 2432
apex reference guide reportchartcomponentlayoutitem class property value type: string hideonerror controls whether users see a chart that has an error. when an error occurs and this attribute is not set, the chart doesn’t show any data except the error. set the attribute to true to hide the chart from a page on error. signature public boolean hideonerror {get; set;} property value type: boolean includecontext if true, filters the report chart to return data that’s relevant to the page. signature public boolean includecontext {get; set;} property value type: boolean reportname unique development name of a report that includes a chart. signature public string reportname {get; set;} property value type: string showtitle if true, applies the title from the report to the chart. signature public boolean showtitle {get; set;} 2433apex reference guide reportchartcomponentsize enum property value type: boolean size size of the displayed chart. the default is medium. signature public metadata.reportchartcomponentsize size {get; set;} property value type: metadata.reportchartcomponentsize reportchartcomponentlayoutitem methods the following are methods for reportchartcomponentlayoutitem. in this section: clone() makes a duplicate copy of the metadata.reportchartcomponentlayoutitem. clone() makes a duplicate copy of the metadata.reportchartcomponentlayoutitem. signature public object clone() return value type: object reportchartcomponentsize enum describes the size of the displayed report chart component. enum values the following are the values of the metadata.reportchartcomponentsize enum. value description large large chart size. medium medium chart size. 2434apex reference guide sidebarcomponent class value description small small chart size. sidebarcomponent class represents a specific custom console component to display in a container that hosts multiple components in one of the sidebars of the salesforce console. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “sidebarcomponent” in the metadata api developer guide. in this section: sidebarcomponent properties sidebarcomponent methods sidebarcomponent properties the following are properties for sidebarcomponent. in this section: componenttype specifies the component type. valid values are “knowledgeone”, “lookup”, “milestones”, “relatedlist”, “topics”, “files”, and “caseexperts”. createaction if the component is a lookup field, the name of the quick action used to create a record. enablelinking if the component is a lookup field, lets users associate a record with this field. height the height of the component in the container. the unit property determines the unit of measurement, in pixels or percent. knowledgeoneenable indicates if the component is enabled for knowledge one. label the name of the component as it displays to console users. available for components in a container with the style of tabs or accordion. lookup if the component is a lookup field, the name of the field. 2435apex reference guide sidebarcomponent class page_x if the component is a visualforce page, the name of the visualforce page. relatedlists if the component is a related list component, the list of related list names. unit the unit of measurement (pixels or percent) for the height and width of the component in the container. updateaction if the component is a lookup field, the name of the quick action used to update a record. width the width of the component in the container. the unit property determines the unit of measurement, in pixels or percent. componenttype specifies the component type. valid values are “knowledgeone”, “lookup”, “milestones”, “relatedlist”, “topics”, “files”, and “caseexperts”. signature public string componenttype {get; set;} property value type: string createaction if the component is a lookup field, the name of the quick action used to create a record. signature public string createaction {get; set;} property value type: string enablelinking if the component is a lookup field, lets users associate a record with this field. signature public boolean enablelinking {
get; set;} property value type: boolean 2436apex reference guide sidebarcomponent class height the height of the component in the container. the unit property determines the unit of measurement, in pixels or percent. signature public integer height {get; set;} property value type: integer knowledgeoneenable indicates if the component is enabled for knowledge one. signature public boolean knowledgeoneenable {get; set;} property value type: boolean label the name of the component as it displays to console users. available for components in a container with the style of tabs or accordion. signature public string label {get; set;} property value type: string lookup if the component is a lookup field, the name of the field. signature public string lookup {get; set;} property value type: string page_x if the component is a visualforce page, the name of the visualforce page. 2437apex reference guide sidebarcomponent class signature public string page_x {get; set;} property value type: string relatedlists if the component is a related list component, the list of related list names. signature public list<metadata.relatedlist> relatedlists {get; set;} property value type: list<metadata.relatedlist> unit the unit of measurement (pixels or percent) for the height and width of the component in the container. signature public string unit {get; set;} property value type: string updateaction if the component is a lookup field, the name of the quick action used to update a record. signature public string updateaction {get; set;} property value type: string width the width of the component in the container. the unit property determines the unit of measurement, in pixels or percent. signature public integer width {get; set;} 2438apex reference guide sortorder enum property value type: integer sidebarcomponent methods the following are methods for sidebarcomponent. in this section: clone() makes a duplicate copy of the metadata.sidebarcomponent. clone() makes a duplicate copy of the metadata.sidebarcomponent. signature public object clone() return value type: object sortorder enum describes the sort order of a related list. enum values the following are the values of the metadata.sortorder enum. value description asc_x sort in ascending order. desc_x sort in descending order. statuscode enum describes the status code for an unsuccessful component deploy. enum values the following are the values of the metadata.statuscode enum. value description invalid_scs_inbound_user log in as the runas user configured in your scs setup. 2439apex reference guide subtabcomponents class value description require_connected_app_scs scs connected app is not installed. require_connected_app_session_scs to use the scs connected app, the user must be authenticated. require_runas_user a runas user must be configured in your org. see also: deployproblemtype enum subtabcomponents class represents custom console components on subtabs in the salesforce console. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “subtabcomponents” in the metadata api developer guide. in this section: subtabcomponents properties subtabcomponents methods subtabcomponents properties the following are properties for subtabcomponents. in this section: component represents a custom console component (visualforce page, lookup field, or related lists) on a section of a page layout. containers represents a location and style in which to display more than one custom console component on the sidebars of the salesforce console. component represents a custom console component (visualforce page, lookup field, or related lists) on a section of a page layout. signature public list<metadata.consolecomponent> component {get; set;} 2440apex reference guide summarylayoutstyleenum enum property value type: list<metadata.consolecomponent> containers represents a location and style in which to display more than one custom console component on the sidebars of the salesforce console. signature public list<metadata.container> containers {get; set;} property value
type: list<metadata.container> subtabcomponents methods the following are methods for subtabcomponents. in this section: clone() makes a duplicate copy of the metadata.subtabcomponents. clone() makes a duplicate copy of the metadata.subtabcomponents. signature public object clone() return value type: object summarylayoutstyleenum enum describes the highlights panel style for a summarylayout. enum values the following are the values of the metadata.summarylayoutstyleenum enum. value description caseinteraction case interaction style. childservicereporttemplatestyle child service report template style. 2441apex reference guide summarylayout class value description defaultquotetemplate default quote template style. defaultservicereporttemplate default service report style default_x default style. pathassistant path assisstant style. quickactionlayoutleftright quick action left-right layout style. quickactionlayouttopdown quick action top-down layout style. quotetemplate quote template style. servicereporttemplate service report style. summarylayout class controls the appearance of the highlights panel, which summarizes key fields in a grid at the top of a page layout, when case feed is enabled. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “summarylayout” in the metadata api developer guide. in this section: summarylayout properties summarylayout methods summarylayout properties the following are properties for summarylayout. in this section: masterlabel the name of the layout label. sizex number of columns in the highlights pane, between 1 and 4 (inclusive). sizey number of rows in each column, either 1 or 2. 2442apex reference guide summarylayout class sizez if provided, the setting is not visible to users. summarylayoutitems controls the appearance of an individual field and its column and row position within the highlights panel grid, when case feed is enabled. at least one is required. summarylayoutstyle specifies the panel style. masterlabel the name of the layout label. important: where possible, we changed noninclusive terms to align with our company value of equality. we maintained certain terms to avoid any effect on customer implementations. signature public string masterlabel {get; set;} property value type: string sizex number of columns in the highlights pane, between 1 and 4 (inclusive). signature public integer sizex {get; set;} property value type: integer sizey number of rows in each column, either 1 or 2. signature public integer sizey {get; set;} property value type: integer sizez if provided, the setting is not visible to users. 2443apex reference guide summarylayout class signature public integer sizez {get; set;} property value type: integer summarylayoutitems controls the appearance of an individual field and its column and row position within the highlights panel grid, when case feed is enabled. at least one is required. signature public list<metadata.summarylayoutitem> summarylayoutitems {get; set;} property value type: list<metadata.summarylayoutitem> summarylayoutstyle specifies the panel style. signature public metadata.summarylayoutstyleenum summarylayoutstyle {get; set;} property value type: metadata.summarylayoutstyleenum summarylayout methods the following are methods for summarylayout. in this section: clone() makes a duplicate copy of the metadata.summarylayout. clone() makes a duplicate copy of the metadata.summarylayout. signature public object clone() 2444apex reference guide summarylayoutitem class return value type: object summarylayoutitem class controls the appearance of an individual field and its column and row position within the highlights panel grid, when case feed is enabled. you can have two fields per each grid in a highlights panel. namespace metadata usage use this class when accessing metadata.layout metadata components. for more information, see “summarylayoutitem” in the metadata api developer guide. in this section: summarylayoutitem properties summarylayoutitem methods summarylayoutitem properties the following are properties for summarylayoutitem. in this section: customlink the custom link reference. field the field name reference, relative to the page layout. must be a standard or custom field that also exists on the detail page. posx the item's column
position in the highlights panel grid. must be within the range of sizex. posy the item's row position in the highlights panel grid. must be within the range of sizey. posz reserved for future use. if provided, the setting is not visible to users. customlink the custom link reference. signature public string customlink {get; set;} 2445apex reference guide summarylayoutitem class property value type: string field the field name reference, relative to the page layout. must be a standard or custom field that also exists on the detail page. signature public string field {get; set;} property value type: string posx the item's column position in the highlights panel grid. must be within the range of sizex. signature public integer posx {get; set;} property value type: integer posy the item's row position in the highlights panel grid. must be within the range of sizey. signature public integer posy {get; set;} property value type: integer posz reserved for future use. if provided, the setting is not visible to users. signature public integer posz {get; set;} property value type: integer 2446apex reference guide uibehavior enum summarylayoutitem methods the following are methods for summarylayoutitem. in this section: clone() makes a duplicate copy of the metadata.summarylayoutitem. clone() makes a duplicate copy of the metadata.summarylayoutitem. signature public object clone() return value type: object uibehavior enum describes the behavior for a layout item on a layout page. enum values the following are the values of the metadata.uibehavior enum. value description edit the layout field can be edited but is not required. readonly the layout field is read-only. required the layout field can be edited and is required. pref_center namespace the pref_center namespace provides an interface, classes, and methods to create and retrieve data in forms in preference manager. preference manager, previously called preference center, is a feature within the privacy center app. the following are the classes in the pref_center namespace. in this section: loadformdata class retrieve records related to the tokenized record id, and populate the values of a preference form. 2447apex reference guide loadformdata class loadparameters class contains methods to retrieve record id information for parameters passed into the load-form handler. preferencecenterapexhandler interface pass data between your organization and a form in preference manager. submitformdata class contains methods to retrieve information on buttons and options selected in a preference form. submitparameters class retrieve record id information to use with your submit-form handler. tokentype enum defines the types of values supported by the tokenutility methods. tokenutility class generate authentication tokens to access preference forms. validationresult class this class is reserved for future use with preference manager. loadformdata class retrieve records related to the tokenized record id, and populate the values of a preference form. namespace pref_center example use methods in the loadformdata class to set available and selected values in different form components: list<system.selectoption> picklistoptions = new list<system.selectoption>(); picklistoptions.add(new system.selectoption('optin', 'opt in')); picklistoptions.add(new system.selectoption('optout', 'opt out')); // set the available options for the picklist loadformdata.setoptions('mypicklist', picklistoptions); // add an option to the existing options for the picklist loadformdata.addoption('mypicklist', 'optoutall', 'opt out all'); // select the 'optin' option in the picklist loadformdata.setselectedoption('mypicklist', 'optin'); list<system.selectoption> checkboxoptions = new list<system.selectoption>(); checkboxoptions.add(new system.selectoption('yes', 'yes')); checkboxoptions.add(new system.selectoption('no', 'no')); // set available options for the checkbox group loadformdata.setoptions('mycheckbox', checkboxoptions); // select the 'yes' option in the checkbox group loadformdata.addselectedoption('mycheckbox', 'yes'); 2448apex reference guide loadformdata
class // also select the 'no' option in the checkbox group loadformdata.addselectedoption('mycheckbox', 'no'); // another way to select both the 'yes' and 'no' options in the checkbox group loadformdata.setselectedoptions('mycheckbox', new list<string>{'yes', 'no'}); // fill the value in the text input loadformdata.settextvalue('mytextinput', '[email protected]'); // set the hint text for the text input loadformdata.settexthint('mytextinput', 'email address'); // set the label for the button loadformdata.setbuttonlabel('mybutton', 'save preferences'); in this section: loadformdata constructors loadformdata methods loadformdata constructors the following are constructors for loadformdata. in this section: loadformdata(data) creates an instance of the loadformdata class for running tests on any custom apex classes you create for preference manager. loadformdata(data) creates an instance of the loadformdata class for running tests on any custom apex classes you create for preference manager. signature public loadformdata(map<string,pref_center.fieldproperties> data) parameters data type: map<string,pref_center.fieldproperties>map maps preference form data from the field id to the field properties. usage this constructor is available in api version 56.0 and later. loadformdata methods the following are methods for loadformdata. 2449apex reference guide loadformdata class in this section: addoption(fieldid, value, label) add an option for a checkbox, picklist, or radio button field in a preference form using the label and value. addoption(fieldid, option) add a defined, selectable option for a checkbox, picklist, or radio button field in a preference form. addselectedoption(fieldid, option) add a selected option for a checkbox field in a preference form. this requires the field on the form to have a defined option with a set value. setbuttonlabel(fieldid, label) set the label of a button added to the preference form. setoptions(fieldid, options) add a list of selectable options for a field on a preference form. setselectedoption(fieldid, optionvalue) for a picklist or radio button field on a preference form that has defined values, set the value entered in the optionvalue field as the selected option. setselectedoptions(fieldid, options) for an existing checkbox field on a preference form that has defined values, set the values entered in the options field as the selected options. this requires the field on the form to have defined options with a set value. settexthint(fieldid, hinttext) set the hint text inside a text input field. the hint text tells the user what type of information to enter, like an email address. settextvalue(fieldid, value) set the value of a text field in a preference form. addoption(fieldid, value, label) add an option for a checkbox, picklist, or radio button field in a preference form using the label and value. signature public void addoption(string fieldid, string value, string label) parameters fieldid type: string identifies a field in the preference form. value type: string represents the selection or text entered in a preference form field. label type: string the label for the value of a field in a preference form. 2450apex reference guide loadformdata class return value type: void addoption(fieldid, option) add a defined, selectable option for a checkbox, picklist, or radio button field in a preference form. signature public void addoption(string fieldid, system.selectoption option) parameters fieldid type: string identifies a field in the preference form. option type: system.selectoption the option selected on a field in the preference form. return value type: void addselectedoption(fieldid, option) add a selected option for a checkbox field in a preference form. this requires the field on the form to have a defined option with a set value. signature public void addselectedoption(string fieldid, string option) parameters fieldid type: string identifies a field in the preference form. option type: string the
selectable option being added. return value type: void 2451apex reference guide loadformdata class setbuttonlabel(fieldid, label) set the label of a button added to the preference form. signature public void setbuttonlabel(string fieldid, string label) parameters fieldid type: string identifies a field in the preference form. label type: string the label for a button added to the preference form. return value type: void setoptions(fieldid, options) add a list of selectable options for a field on a preference form. signature public void setoptions(string fieldid, list<system.selectoption> options) parameters fieldid type: string identifies a field in the preference form. options type: list<system.selectoption> the selectable options for a field in the preference form. return value type: void setselectedoption(fieldid, optionvalue) for a picklist or radio button field on a preference form that has defined values, set the value entered in the optionvalue field as the selected option. 2452apex reference guide loadformdata class signature public void setselectedoption(string fieldid, string optionvalue) parameters fieldid type: string identifies a field in the preference form. optionvalue type: string the value for the selected option. return value type: void setselectedoptions(fieldid, options) for an existing checkbox field on a preference form that has defined values, set the values entered in the options field as the selected options. this requires the field on the form to have defined options with a set value. signature public void setselectedoptions(string fieldid, list<string> options) parameters fieldid type: string identifies the checkbox field in the preference form. options type: list<string> the selected options for a field in the preference form. return value type: void settexthint(fieldid, hinttext) set the hint text inside a text input field. the hint text tells the user what type of information to enter, like an email address. signature public void settexthint(string fieldid, string hinttext) 2453apex reference guide loadparameters class parameters fieldid type: string the id of the text input field in the preference form. hinttext type: string the hint text in the text input field. return value type: void settextvalue(fieldid, value) set the value of a text field in a preference form. signature public void settextvalue(string fieldid, string value) parameters fieldid type: string identifies a field in the preference form. value type: string represents the value entered for the text field in a preference form. return value type: void loadparameters class contains methods to retrieve record id information for parameters passed into the load-form handler. namespace pref_center example string userid = loadparams.getrecordid(); user user = [select id, aboutme from user where id=:userid]; 2454apex reference guide preferencecenterapexhandler interface in this section: loadparameters methods loadparameters methods the following are methods for loadparameters. in this section: getrecordid() returns the untokenized version of the record id. getrecordid() returns the untokenized version of the record id. signature public string getrecordid() return value type: string preferencecenterapexhandler interface pass data between your organization and a form in preference manager. namespace pref_center in this section: preferencecenterapexhandler methods preferencecenterapexhandler methods the following are methods for preferencecenterapexhandler. in this section: load(loadparams, formdata, validationresult) retrieve the record ids and initial values from a preference form before it is edited and submitted. submit(loadparams, formdata, validationresult) updates the changed values of fields when the preference form is submitted. 2455apex reference guide preferencecenterapexhandler interface load(loadparams, formdata, validationresult) retrieve the record ids and initial values from a preference form before it is edited and submitted. signature public pref_center.loadformdata load(pref_center.loadparameters loadparams, pref_center.loadformdata formdata, pref_
center.validationresult validationresult) parameters loadparams type: pref_center.loadparameters retrieve the tokenized record id. formdata type: pref_center.loadformdata set the initial values of fields in a form before they are edited. validationresult type: pref_center.validationresult reserved for future use. return value type: pref_center.loadformdata submit(loadparams, formdata, validationresult) updates the changed values of fields when the preference form is submitted. signature public void submit(pref_center.submitparameters submitparams, pref_center.submitformdata formdata, pref_center.validationresult validationresult) parameters submitparams type: pref_center.submitparameters retrieve the tokenized record id. formdata type: pref_center.submitformdata retrieve the values of fields in a submitted form. validationresult type: pref_center.validationresult reserved for future use. 2456apex reference guide submitformdata class return value type: void submitformdata class contains methods to retrieve information on buttons and options selected in a preference form. namespace pref_center example use methods in the submitformdata class to retrieve the selected values in different form components: string buttonclickedid = formdata.getbuttonclicked(); if (buttonclickedid == 'submitbutton') { // handle form submit } else if (buttonclickedid == 'cancelbutton') { // handle form cancel } string picklistvalueold = formdata.getoldselectedvalue('mypicklist'); string picklistvaluenew = formdata.getselectedvalue('mypicklist'); if (picklistvalueold != picklistvaluenew) { // do something } list<string> checkboxvaluesold = formdata.getoldselectedvalues('mycheckbox'); list<string> checkboxvaluesnew = formdata.getselectedvalues('mycheckbox'); if (checkboxvaluesold != null && checkboxvaluesnew != null && (checkboxvaluesold.size() != checkboxvaluesnew.size())) { // do something } string textinputvalueold = formdata.getoldstringvalue('mytextinput'); string textinputvaluenew = formdata.getstringvalue('mytextinput'); if (textinputvalueold != textinputvaluenew) { // do something } in this section: submitformdata methods submitformdata methods the following are methods for submitformdata. 2457apex reference guide submitformdata class in this section: getbuttonclicked() returns the field id of the button that was clicked in the preference form. for example, use this method to determine if the clicked button was submit or cancel. getoldselectedvalue(fieldid) returns the value that was set for the specified field when the preference form was previously edited by the user. this method is used for field types such as picklist or radio buttons. getoldselectedvalues(fieldid) returns a list of the string values that were set on a checkbox field when the preference form was previously edited by the user. getoldstringvalue(fieldid) returns the string value that was set on a field when the preference form was loaded. this method is used for field types such as text, and throws a typeexception if used with a field that can return more than one value, like a checkbox field. getselectedvalue(fieldid) returns the string value that is currently selected for a picklist or radio button field in the preference form. getselectedvalues(fieldid) returns a list of string values that are currently selected on a checkbox field in the preference form. getstringvalue(fieldid) returns the string value that was set on a field when the preference form was loaded. this method is used for field types such as text. getbuttonclicked() returns the field id of the button that was clicked in the preference form. for example, use this method to determine if the clicked button was submit or cancel. signature public string getbuttonclicked() return value type: string getoldselectedvalue(fieldid) returns the value that was set for the specified field when the preference form was previously edited by the user. this method is used for field types such as picklist or radio buttons. signature public string getoldselectedvalue(string fieldid) parameters fieldid type: string 2458apex
reference guide submitformdata class identifies a field in the preference form. return value type: string getoldselectedvalues(fieldid) returns a list of the string values that were set on a checkbox field when the preference form was previously edited by the user. signature public list<string> getoldselectedvalues(string fieldid) parameters fieldid type: string identifies a field in the preference form. return value type: list<string> getoldstringvalue(fieldid) returns the string value that was set on a field when the preference form was loaded. this method is used for field types such as text, and throws a typeexception if used with a field that can return more than one value, like a checkbox field. signature public string getoldstringvalue(string fieldid) parameters fieldid type: string identifies a field in the preference form. return value type: string getselectedvalue(fieldid) returns the string value that is currently selected for a picklist or radio button field in the preference form. signature public string getselectedvalue(string fieldid) 2459apex reference guide submitparameters class parameters fieldid type: string identifies a field in the preference form. return value type: string getselectedvalues(fieldid) returns a list of string values that are currently selected on a checkbox field in the preference form. signature public list<string> getselectedvalues(string fieldid) parameters fieldid type: string identifies a field in the preference form. return value type: list<string> getstringvalue(fieldid) returns the string value that was set on a field when the preference form was loaded. this method is used for field types such as text. signature public string getstringvalue(string fieldid) parameters fieldid type: string identifies a field in the preference form. return value type: string submitparameters class retrieve record id information to use with your submit-form handler. 2460apex reference guide tokentype enum namespace pref_center example string userid = submitparams.getrecordid(); user user = [select id, aboutme from user where id=:userid]; in this section: submitparameters methods submitparameters methods the following are methods for submitparameters. in this section: getrecordid() returns the untokenized version of the record id. getrecordid() returns the untokenized version of the record id. signature public string getrecordid() return value type: string tokentype enum defines the types of values supported by the tokenutility methods. enum values the following are the values of the pref_center.tokentype enum. value description email identifies the token as an email address. standard identifies the token as a salesforce record id. this is the default token type. 2461apex reference guide tokenutility class tokenutility class generate authentication tokens to access preference forms. namespace pref_center example call the generatetoken() method to generate a single token for a specified salesforce record id: individual individual = [select id from individual limit 1]; string token = pref_center.tokenutility.generatetoken(individual.id); // do something with the token system.debug(token) call the generatetokens() method to generate tokens in bulk when given a list of salesforce record ids: list<id> individualids = new list<id>(); // get ids of individuals who have not opted out of tracking for (individual individual : [select id from individual where hasoptedouttracking = false]) { individualids.add(individual.id); } // generate tokens for the list of individual record ids map<string, string> tokens = pref_center.tokenutility.generatetokens(individualids); string firstindividualid = individualids[0]; // the returned map has the input record id as key and the corresponding token as value string tokenforfirstindividual = tokens.get(firstindividualid); // do something with the token system.debug(tokenforfirstindividual); in this section: tokenutility methods tokenutility methods the following are methods for tokenutility. in this section: generatetoken(tokenvalue, tokentype) returns the authentication token for the specified token value using the given token type. generatetoken
(tokenvalue) returns the authentication token for the specified token value using the default standard token type. generatetokens(tokenvalues, tokentype) returns the authentication tokens in the form of a map, where the map key is the input value to be tokenized and the map value is the corresponding token. the given token type is used to generate the tokens. 2462apex reference guide tokenutility class generatetokens(tokenvalues) returns the generated tokens in the form of a map. this method uses the default standard token type to generate the tokens. generatetoken(tokenvalue, tokentype) returns the authentication token for the specified token value using the given token type. signature public static string generatetoken(string tokenvalue, pref_center.tokentype tokentype) parameters tokenvalue type: string the value passed to loadparameters.getrecordid() and submitparameters.getrecordid(). identifies the entity that the preference form is acting on. tokentype type: pref_center.tokentype specifies the type of the value to be encrypted with authentication tokens. return value type: string generatetoken(tokenvalue) returns the authentication token for the specified token value using the default standard token type. signature public static string generatetoken(string tokenvalue) parameters tokenvalue type: string identifies the entity that the preference form is acting on. the value passed to loadparameters.getrecordid() and submitparameters.getrecordid(). return value type: string generatetokens(tokenvalues, tokentype) returns the authentication tokens in the form of a map, where the map key is the input value to be tokenized and the map value is the corresponding token. the given token type is used to generate the tokens. 2463apex reference guide validationresult class signature public static map<string,string> generatetokens(list<string> tokenvalues, pref_center.tokentype tokentype) parameters tokenvalues type: list<string> the values passed to loadparameters.getrecordid() and submitparameters.getrecordid(). identifies the entity that the preference form is acting on. contains multiple values to be encrypted with authentication tokens. tokentype type: pref_center.tokentype specifies the type of the value to be encrypted with authentication tokens. return value type: map<string,string> generatetokens(tokenvalues) returns the generated tokens in the form of a map. this method uses the default standard token type to generate the tokens. signature public static map<string,string> generatetokens(list<string> tokenvalues) parameters tokenvalues type: list<string> the list of string values passed to loadparameters.getrecordid() and submitparameters.getrecordid(). contains multiple values to be encrypted with authentication tokens. return value type: map<string,string>, where the map key is the input value to be tokenized and the map value is the corresponding token. validationresult class this class is reserved for future use with preference manager. namespace pref_center 2464apex reference guide process namespace process namespace the process namespace provides an interface and classes for passing data between your organization and a flow. the following are the interfaces and classes in the process namespace. in this section: plugin interface allows you to pass data between your organization and a specified flow. plugindescriberesult class describes the input and output parameters for process.pluginresult. plugindescriberesult.inputparameter class describes the input parameter for process.pluginresult. plugindescriberesult.outputparameter class describes the output parameter for process.pluginresult. pluginrequest class passes input parameters from the class that implements the process.plugin interface to the flow. pluginresult class returns output parameters from the class that implements the process.plugin interface to the flow. plugin interface allows you to pass data between your organization and a specified flow. namespace process tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. in this section: plugin methods plugin example implementation plugin methods the
following are instance methods for plugin. 2465apex reference guide plugin interface in this section: describe() returns a process.plugindescriberesult object that describes this method call. invoke(request) primary method that the system invokes when the class that implements the interface is instantiated. describe() returns a process.plugindescriberesult object that describes this method call. signature public process.plugindescriberesult describe() return value type: process.plugindescriberesult invoke(request) primary method that the system invokes when the class that implements the interface is instantiated. signature public process.pluginresult invoke(process.pluginrequest request) parameters request type: process.pluginrequest return value type: process.pluginresult plugin example implementation global class flowchat implements process.plugin { // the main method to be implemented. the flow calls this at run time. global process.pluginresult invoke(process.pluginrequest request) { // get the subject of the chatter post from the flow string subject = (string) request.inputparameters.get('subject'); // use the chatter apis to post it to the current user's feed feeditem fitem = new feeditem(); fitem.parentid = userinfo.getuserid(); fitem.body = 'flow update: ' + subject; insert fitem; 2466apex reference guide plugindescriberesult class // return to flow map<string,object> result = new map<string,object>(); return new process.pluginresult(result); } // returns the describe information for the interface global process.plugindescriberesult describe() { process.plugindescriberesult result = new process.plugindescriberesult(); result.name = 'flowchatplugin'; result.tag = 'chat'; result.inputparameters = new list<process.plugindescriberesult.inputparameter>{ new process.plugindescriberesult.inputparameter('subject', process.plugindescriberesult.parametertype.string, true) }; result.outputparameters = new list<process.plugindescriberesult.outputparameter>{ }; return result; } } test class the following is a test class for the above class. @istest private class flowchattest { static testmethod void flowchattests() { flowchat plugin = new flowchat(); map<string,object> inputparams = new map<string,object>(); string feedsubject = 'flow is alive'; inputparams.put('subject', feedsubject); process.pluginrequest request = new process.pluginrequest(inputparams); plugin.invoke(request); } } plugindescriberesult class describes the input and output parameters for process.pluginresult. namespace process 2467apex reference guide plugindescriberesult class tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. in this section: plugindescriberesult constructors plugindescriberesult properties plugindescriberesult constructors the following are constructors for plugindescriberesult. in this section: plugindescriberesult() creates a new instance of the process.plugindescriberesult class. plugindescriberesult() creates a new instance of the process.plugindescriberesult class. signature public plugindescriberesult() plugindescriberesult properties the following are properties for plugindescriberesult. in this section: description this optional field describes the purpose of the plug-in. inputparameters the input parameters passed by the process.pluginrequest class from a flow to the class that implements the process.plugin interface. name unique name of the plug-in. outputparameters the output parameters passed by the process.pluginresult class from the class that implements the process.plugin interface to the flow. 2468apex reference guide plugindescriberesult class description this optional field describes the purpose of the plug-in. signature public string description {get; set;} property value type: string usage size limit: 255 characters. inputparameters
the input parameters passed by the process.pluginrequest class from a flow to the class that implements the process.plugin interface. signature public list<process.plugindescriberesult.inputparameter> inputparameters {get; set;} property value type: list<process.plugindescriberesult.inputparameter> name unique name of the plug-in. signature public string name {get; set;} property value type: string usage size limit: 40 characters. outputparameters the output parameters passed by the process.pluginresult class from the class that implements the process.plugin interface to the flow. 2469apex reference guide plugindescriberesult.inputparameter class signature public list<process.plugindescriberesult.outputparameter> outputparameters {get; set;} property value type: list<process.plugindescriberesult.outputparameter> plugindescriberesult.inputparameter class describes the input parameter for process.pluginresult. namespace process tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. in this section: plugindescriberesult.inputparameter constructors plugindescriberesult.inputparameter properties plugindescriberesult.inputparameter constructors the following are constructors for plugindescriberesult.inputparameter. in this section: plugindescriberesult.inputparameter(name, description, parametertype, required) creates a new instance of the process.plugindescriberesult.inputparameter class using the specified name, description, parameter type, and required option. plugindescriberesult.inputparameter(name, parametertype, required) creates a new instance of the process.plugindescriberesult.inputparameter class using the specified name, parameter type, and required option. plugindescriberesult.inputparameter(name, description, parametertype, required) creates a new instance of the process.plugindescriberesult.inputparameter class using the specified name, description, parameter type, and required option. 2470apex reference guide plugindescriberesult.inputparameter class signature public plugindescriberesult.inputparameter(string name, string description, process.plugindescriberesult.parametertype parametertype, boolean required) parameters name type: string unique name of the plug-in. description type: string describes the purpose of the plug-in. parametertype type: process.plugindescriberesult.parametertype the data type of the input parameter. required type: boolean set to true for required and false otherwise. plugindescriberesult.inputparameter(name, parametertype, required) creates a new instance of the process.plugindescriberesult.inputparameter class using the specified name, parameter type, and required option. signature public plugindescriberesult.inputparameter(string name, process.plugindescriberesult.parametertype parametertype, boolean required) parameters name type: string unique name of the plug-in. parametertype type: process.plugindescriberesult.parametertype the data type of the input parameter. required type: boolean set to true for required and false otherwise. plugindescriberesult.inputparameter properties the following are properties for plugindescriberesult.inputparameter. 2471apex reference guide plugindescriberesult.inputparameter class in this section: description this optional field describes the purpose of the plug-in. name unique name of the plug-in. parametertype the data type of the input parameter. required set to true for required and false otherwise. description this optional field describes the purpose of the plug-in. signature public string description {get; set;} property value type: string usage size limit: 255 characters. name unique name of the plug-in. signature public string name {get; set;} property value type: string usage size limit: 40 characters. parametertype the data type of the input parameter. signature public process.plugindescriberesult.parametertype parametertype {get; set;} 2472apex reference guide plugin
describeresult.outputparameter class property value type: process.plugindescriberesult.parametertype required set to true for required and false otherwise. signature public boolean required {get; set;} property value type: boolean plugindescriberesult.outputparameter class describes the output parameter for process.pluginresult. namespace process tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. in this section: plugindescriberesult.outputparameter constructors plugindescriberesult.outputparameter properties plugindescriberesult.outputparameter constructors the following are constructors for plugindescriberesult.outputparameter. in this section: plugindescriberesult.outputparameter(name, description, parametertype) creates a new instance of the process.plugindescriberesult.outputparameter class using the specified name, description, and parameter type. plugindescriberesult.outputparameter(name, parametertype) creates a new instance of the process.plugindescriberesult.outputparameter class using the specified name, description, and parameter type. 2473apex reference guide plugindescriberesult.outputparameter class plugindescriberesult.outputparameter(name, description, parametertype) creates a new instance of the process.plugindescriberesult.outputparameter class using the specified name, description, and parameter type. signature public plugindescriberesult.outputparameter(string name, string description, process.plugindescriberesult.parametertype parametertype) parameters name type: string unique name of the plug-in. description type: string describes the purpose of the plug-in. parametertype type: process.plugindescriberesult.parametertype the data type of the input parameter. plugindescriberesult.outputparameter(name, parametertype) creates a new instance of the process.plugindescriberesult.outputparameter class using the specified name, description, and parameter type. signature public plugindescriberesult.outputparameter(string name, process.plugindescriberesult.parametertype parametertype) parameters name type: string unique name of the plug-in. parametertype type: process.plugindescriberesult.parametertype the data type of the input parameter. plugindescriberesult.outputparameter properties the following are properties for plugindescriberesult.outputparameter. 2474apex reference guide plugindescriberesult.outputparameter class in this section: description this optional field describes the purpose of the plug-in. name unique name of the plug-in. parametertype the data type of the input parameter. description this optional field describes the purpose of the plug-in. signature public string description {get; set;} property value type: string usage size limit: 255 characters. name unique name of the plug-in. signature public string name {get; set;} property value type: string usage size limit: 40 characters. parametertype the data type of the input parameter. signature public process.plugindescriberesult.parametertype parametertype {get; set;} 2475apex reference guide pluginrequest class property value type: process.plugindescriberesult.parametertype pluginrequest class passes input parameters from the class that implements the process.plugin interface to the flow. namespace process tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. pluginrequest properties the following are properties for pluginrequest. in this section: inputparameters input parameters that are passed from the class that implements the process.plugin interface to the flow. inputparameters input
parameters that are passed from the class that implements the process.plugin interface to the flow. signature public map<string,any> inputparameters {get; set;} property value type: map<string, object> pluginresult class returns output parameters from the class that implements the process.plugin interface to the flow. tip: we recommend using the @invocablemethod annotation instead of the process.plugin interface. • the interface doesn’t support blob, collection, sobject, and time data types, and it doesn’t support bulk operations. once you implement the interface on a class, the class can be referenced only from flows. • the annotation supports all data types and bulk operations. once you implement the annotation on a class, the class can be referenced from flows, processes, and the custom invocable actions rest api endpoint. 2476apex reference guide quickaction namespace namespace process pluginresult properties the following are properties for pluginresult. in this section: outputparameters output parameters returned from the class that implements the interface to the flow. outputparameters output parameters returned from the class that implements the interface to the flow. signature public map<string, any> outputparameters {get; set;} property value type: map<string, object> quickaction namespace the quickaction namespace provides classes and methods for quick actions. the following are the classes in the quickaction namespace. in this section: describeavailablequickactionresult class contains describe metadata information for a quick action that is available for a specified parent. describelayoutcomponent class represents the smallest unit in a layout—a field or a separator. describelayoutitem class represents an individual item in a quickaction.describelayoutrow. describelayoutrow class represents a row in a quickaction.describelayoutsection. describelayoutsection class represents a section of a layout and consists of one or more columns and one or more rows (an array of quickaction.describelayoutrow). describequickactiondefaultvalue class returns a default value for a quick action. 2477apex reference guide describeavailablequickactionresult class describequickactionresult class contains describe metadata information for a quick action. quickactiondefaults class represents an abstract apex class that provides the context for running the standard email action on case feed and the container of the email message fields for the action payload. you can override the target fields before the standard email action is rendered. quickactiondefaultshandler interface the quickaction.quickactiondefaultshandler interface lets you specify the default values for the standard email and send email actions in the case feed. you can use this interface to specify the from address, cc address, bcc address, subject, and email body for the email action in the case feed. you can use the interface to pre-populate these fields based on the context where the action is displayed, such as the case origin (for example, country) and subject. quickactionrequest class use the quickaction.quickactionrequest class for providing action information for quick actions to be performed by quickaction class methods. action information includes the action name, context record id, and record. quickactionresult class after you initiate a quick action with the quickaction class, use the quickactionresult class for processing action results. sendemailquickactiondefaults class represents an apex class that provides: the from address list; the original email’s email message id, provided that the reply action was invoked on the email message feed item; and methods to specify related settings on templates. you can override these fields before the standard email action is rendered. describeavailablequickactionresult class contains describe metadata information for a quick action that is available for a specified parent. namespace quickaction usage the quickaction describeavailablequickactions method returns an array of available quick action describe result objects (quickaction.describeavailablequickactionresult). describeavailablequickactionresult methods the following are methods for describeavailablequickactionresult. all are instance methods. in this section: getactionenumorid() returns the unique id for the action. if the action doesn’t have an id, its api name is used. getlabel() the quick action label. 2478apex reference guide describeavailablequickactionresult class getname() the quick action name. gettype() the quick action type. getactionenumorid() returns the unique id for the action. if the action doesn’t have an id, its api name is used. signature
public string getactionenumorid() return value type: string getlabel() the quick action label. signature public string getlabel() return value type: string getname() the quick action name. signature public string getname() return value type: string gettype() the quick action type. signature public string gettype() 2479apex reference guide describelayoutcomponent class return value type: string describelayoutcomponent class represents the smallest unit in a layout—a field or a separator. namespace quickaction describelayoutcomponent methods the following are methods for describelayoutcomponent. all are instance methods. in this section: getdisplaylines() returns the vertical lines displayed for a field. applies to textarea and multi-select picklist fields. gettaborder() returns the tab order for the item in the row. gettype() returns the name of the quickaction.describelayoutcomponent type for this component. getvalue() returns the name of the field if the type for quickaction.describelayoutcomponent is textarea. getdisplaylines() returns the vertical lines displayed for a field. applies to textarea and multi-select picklist fields. signature public integer getdisplaylines() return value type: integer gettaborder() returns the tab order for the item in the row. signature public integer gettaborder() 2480apex reference guide describelayoutitem class return value type: integer gettype() returns the name of the quickaction.describelayoutcomponent type for this component. signature public string gettype() return value type: string getvalue() returns the name of the field if the type for quickaction.describelayoutcomponent is textarea. signature public string getvalue() return value type: string describelayoutitem class represents an individual item in a quickaction.describelayoutrow. namespace quickaction usage for most fields on a layout, there is only one component per layout item. however, in a display-only view, the quickaction.describelayoutitem might be a composite of the individual fields (for example, an address can consist of street, city, state, country, and postal code data). on the corresponding edit view, each component of the address field would be split up into separate quickaction.describelayoutitems. describelayoutitem methods the following are methods for describelayoutitem. all are instance methods. 2481apex reference guide describelayoutitem class in this section: getlabel() returns the label text for this item. getlayoutcomponents() returns a list of quickaction.describelayoutcomponents for this item. iseditablefornew() indicates whether this item can be edited for new (true) or not (false). iseditableforupdate() indicates whether this item can be edited for update(true) or not (false). isplaceholder() indicates whether this item is a placeholder (true) or not (false). if true, then this item is blank. isrequired() indicates whether this item is required (true) or not (false). getlabel() returns the label text for this item. signature public string getlabel() return value type: string getlayoutcomponents() returns a list of quickaction.describelayoutcomponents for this item. signature public list<quickaction.describelayoutcomponent> getlayoutcomponents() return value type: list<quickaction.describelayoutcomponent> iseditablefornew() indicates whether this item can be edited for new (true) or not (false). signature public boolean iseditablefornew() 2482
apex reference guide describelayoutrow class return value type: boolean iseditableforupdate() indicates whether this item can be edited for update(true) or not (false). signature public boolean iseditableforupdate() return value type: boolean isplaceholder() indicates whether this item is a placeholder (true) or not (false). if true, then this item is blank. signature public boolean isplaceholder() return value type: boolean isrequired() indicates whether this item is required (true) or not (false). signature public boolean isrequired() return value type: boolean usage this is useful if, for example, you want to render required fields in a contrasting color. describelayoutrow class represents a row in a quickaction.describelayoutsection. namespace quickaction 2483apex reference guide describelayoutsection class usage a quickaction.describelayoutrow consists of one or more quickaction.describelayoutitem objects. for each quickaction.describelayoutrow, a quickaction.describelayoutitem refers either to a specific field or to an “empty” quickaction.describelayoutitem (one that contains no quickaction.describelayoutcomponent objects). an empty quickaction.describelayoutitem can be returned when a given quickaction.describelayoutrow is sparse (for example, containing more fields on the right column than on the left column). describelayoutrow methods the following are methods for describelayoutrow. all are instance methods. in this section: getlayoutitems() returns either a specific field or an empty quickaction.describelayoutitem (one that contains no quickaction.describelayoutcomponent objects). getnumitems() returns the number of quickaction.describelayoutitem. getlayoutitems() returns either a specific field or an empty quickaction.describelayoutitem (one that contains no quickaction.describelayoutcomponent objects). signature public list<quickaction.describelayoutitem> getlayoutitems() return value type: list<quickaction.describelayoutitem> getnumitems() returns the number of quickaction.describelayoutitem. signature public integer getnumitems() return value type: integer describelayoutsection class represents a section of a layout and consists of one or more columns and one or more rows (an array of quickaction.describelayoutrow). 2484apex reference guide describelayoutsection class namespace quickaction describelayoutsection properties the following are properties for describelayoutsection. collapsed the current view of the record details section: collapsed (true) or expanded (false). signature public boolean collapsed {get; set;} property value type: boolean layoutsectionid the unique id of the record details section in the layout. signature public id layoutsectionid {get; set;} property value type: id describelayoutsection methods the following are methods for describelayoutsection. in this section: getcolumns() returns the number of columns in the quickaction.describelayoutsection. getheading() the heading text (label) for the quickaction.describelayoutsection. getlayoutrows() returns an array of one or more quickaction.describelayoutrow objects. getlayoutsectionid() returns the id of the record details section in the layout. getparentlayoutid() returns the id of the layout upon which this describelayoutsection resides. 2485apex reference guide describelayoutsection class getrows() returns the number of rows in the quickaction.describelayoutsection. iscollapsed() indicates whether the record details section is collapsed (true) or expanded (false). if you build your own app, you can use this method to see whether the current user collapsed a section, and respect that preference in your own ui. isusecollapsiblesection() indicates whether the quickaction.describelayoutsection is a collapsible section (true) or not (false). isuseheading() indicates whether to use the heading (true) or not (false). getcolumns() returns the number of columns in the quickaction.describelayoutsection. signature public integer getcolumns() return value type: integer getheading() the heading text (label) for the quickaction.describelayoutsection. signature public string getheading() return value type: string getlayoutrows()
returns an array of one or more quickaction.describelayoutrow objects. signature public list<quickaction.describelayoutrow> getlayoutrows() return value type: list<quickaction.describelayoutrow> getlayoutsectionid() returns the id of the record details section in the layout. 2486apex reference guide describelayoutsection class signature public id getlayoutsectionid() return value type: id getparentlayoutid() returns the id of the layout upon which this describelayoutsection resides. signature public id getparentlayoutid() return value type: id getrows() returns the number of rows in the quickaction.describelayoutsection. signature public integer getrows() return value type: integer iscollapsed() indicates whether the record details section is collapsed (true) or expanded (false). if you build your own app, you can use this method to see whether the current user collapsed a section, and respect that preference in your own ui. signature public boolean iscollapsed() return value type: boolean isusecollapsiblesection() indicates whether the quickaction.describelayoutsection is a collapsible section (true) or not (false). 2487apex reference guide describequickactiondefaultvalue class signature public boolean isusecollapsiblesection() return value type: boolean isuseheading() indicates whether to use the heading (true) or not (false). signature public boolean isuseheading() return value type: boolean describequickactiondefaultvalue class returns a default value for a quick action. namespace quickaction usage represents the default values of fields to use in default layouts. describequickactiondefaultvalue methods the following are methods for describequickactiondefaultvalue. all are instance methods. in this section: getdefaultvalue() returns the default value of the quick action. getfield() returns the field name of the action. getdefaultvalue() returns the default value of the quick action. 2488apex reference guide describequickactionresult class signature public string getdefaultvalue() return value type: string getfield() returns the field name of the action. signature public string getfield() return value type: string describequickactionresult class contains describe metadata information for a quick action. namespace quickaction usage the quickaction describequickactions method returns an array of quick action describe result objects (quickaction.describequickactionresult). in this section: describequickactionresult properties describequickactionresult methods describequickactionresult properties the following are properties for describequickactionresult. in this section: canvasapplicationname the name of the canvas application invoked by the custom action. colors array of color information. each color is associated with a theme. 2489apex reference guide describequickactionresult class contextsobjecttype the object used for the action. was getsourcesobjecttype() in api version 29.0 and earlier. defaultvalues the action’s default values. flowdevname if the custom action invokes a flow, the fully qualified name of the flow. flowrecordidvar if the custom action invokes a flow, the input variable that the custom action passes the record’s id to. height the height in pixels of the action pane. iconname the name of the icon used for the action. if a custom icon is not used, this value isn’t set. icons array of icons. each icon is associated with a theme. iconurl the url of the icon used for the action. this icon url corresponds to the 32x32 icon used for the current salesforce theme, introduced in spring ’10, or the custom icon, if there is one. layout the section of the layout where the action resides. lightningcomponentbundleid if the custom action invokes a lightning component, the id of the lightning component bundle to which the component belongs. lightningcomponentbundlename if the custom action invokes a lightning component, the name of the lightning component bundle to which the component belongs. lightningcomponentqualifiedname the fully qualified name of the lightning component invoked by the custom action. miniiconurl the icon’s url. this icon url corresponds to the 16x16 icon used for the current salesforce theme, introduced in spring ’10, or the custom icon, if
there is one. showquickactionlcheader indicates whether the lightning component quick action header and footer are shown. if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. showquickactionvfheader indicates whether the visualforce quick action header and footer should be shown. if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. targetparentfield the parent object type of the action. links the target object to the parent object. for example, the value is account if the target object is contact and the parent object is account. targetrecordtypeid the record type of the target record. 2490apex reference guide describequickactionresult class targetsobjecttype the action’s target object type. visualforcepagename the name of the visualforce page associated with the custom action. visualforcepageurl the url of the visualforce page associated with the action. width the width in pixels of the action pane, for custom actions that call visualforce pages, canvas apps, or lightning components. canvasapplicationname the name of the canvas application invoked by the custom action. signature public string canvasapplicationname {get; set;} property value type: string colors array of color information. each color is associated with a theme. signature public list<schema.describecolorresult> colors {get; set;} property value type: list<schema.describecolorresult> on page 2660 contextsobjecttype the object used for the action. was getsourcesobjecttype() in api version 29.0 and earlier. signature public string contextsobjecttype {get; set;} property value type: string defaultvalues the action’s default values. 2491apex reference guide describequickactionresult class signature public list<quickaction.describequickactiondefaultvalue> defaultvalues {get; set;} property value type: list<quickaction.describequickactiondefaultvalue> flowdevname if the custom action invokes a flow, the fully qualified name of the flow. signature public string flowdevname {get; set;} property value type: string flowrecordidvar if the custom action invokes a flow, the input variable that the custom action passes the record’s id to. signature public string flowrecordidvar {get; set;} property value type: string valid values are null or recordid. height the height in pixels of the action pane. signature public integer height {get; set;} property value type: integer iconname the name of the icon used for the action. if a custom icon is not used, this value isn’t set. 2492apex reference guide describequickactionresult class signature public string iconname {get; set;} property value type: string icons array of icons. each icon is associated with a theme. signature public list<schema.describeiconresult> icons {get; set;} property value type: list<schema.describeiconresult on page 2684> if no custom icon was associated with the quick action and the quick action creates a specific object, the icons will correspond to the icons used for the created object. for example, if the quick action creates an account, the icon array will contain the icons used for account. if a custom icon was associated with the quick action, the array will contain that custom icon. iconurl the url of the icon used for the action. this icon url corresponds to the 32x32 icon used for the current salesforce theme, introduced in spring ’10, or the custom icon, if there is one. signature public string iconurl {get; set;} property value type: string layout the section of the layout where the action resides. signature public quickaction.describelayoutsection layout {get; set;} property value type: quickaction.describelayoutsection on page 2484 2493apex reference guide describequickactionresult class lightningcomponentbundleid if the custom action invokes a lightning component, the id of the lightning component bundle to which the component belongs. signature public string lightningcomponentbundleid {get; set;} property value type: string lightningcomponentbundlename if the custom action invokes a lightning component, the name of the lightning component bundle to which
the component belongs. signature public string lightningcomponentbundlename {get; set;} property value type: string lightningcomponentqualifiedname the fully qualified name of the lightning component invoked by the custom action. signature public string lightningcomponentqualifiedname {get; set;} property value type: string miniiconurl the icon’s url. this icon url corresponds to the 16x16 icon used for the current salesforce theme, introduced in spring ’10, or the custom icon, if there is one. signature public string miniiconurl {get; set;} property value type: string 2494apex reference guide describequickactionresult class showquickactionlcheader indicates whether the lightning component quick action header and footer are shown. if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. signature public boolean showquickactionlcheader {get; set;} property value type: boolean showquickactionvfheader indicates whether the visualforce quick action header and footer should be shown. if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. signature public boolean showquickactionvfheader {get; set;} property value type: boolean targetparentfield the parent object type of the action. links the target object to the parent object. for example, the value is account if the target object is contact and the parent object is account. signature public string targetparentfield {get; set;} property value type: string targetrecordtypeid the record type of the target record. signature public string targetrecordtypeid {get; set;} property value type: string 2495apex reference guide describequickactionresult class targetsobjecttype the action’s target object type. signature public string targetsobjecttype {get; set;} property value type: string visualforcepagename the name of the visualforce page associated with the custom action. signature public string visualforcepagename {get; set;} property value type: string visualforcepageurl the url of the visualforce page associated with the action. signature public string visualforcepageurl {get; set;} property value type: string width the width in pixels of the action pane, for custom actions that call visualforce pages, canvas apps, or lightning components. signature public integer width {get; set;} property value type: integer describequickactionresult methods the following are methods for describequickactionresult. all are instance methods. 2496apex reference guide describequickactionresult class in this section: getactionenumorid() returns the unique id for the action. if the action doesn’t have an id, its api name is used. getcanvasapplicationname() returns the name of the canvas application, if used. getcolors() returns an array of color information. each color is associated with a theme. getcontextsobjecttype() returns the object used for the action. replaces getsourcesobjecttype() in api version 30.0 and later. getdefaultvalues() returns the default values for a action. getflowdevname() if the custom action invokes a flow, returns the fully qualified name of the flow invoked by the custom action. getflowrecordidvar() if the custom action invokes a flow, returns the input variable that the custom action passes the record’s id to. getheight() returns the height in pixels of the action pane. geticonname() returns the actions’ icon name. geticonurl() returns the url of the 32x32 icon used for the action. geticons() returns a list of schema.describeiconresult objects that describe colors used in a tab. getlabel() returns the action label. getlayout() returns the layout sections that comprise an action. getlightningcomponentbundleid() if the custom action invokes a lightning component, returns the id of the lightning component bundle to which the component belongs. getlightningcomponentbundlename() if the custom action invokes a lightning component, returns the name of the lightning component bundle to which the component belongs. getlightningcomponentqualifiedname() if the custom action invokes a lightning component, returns the fully qualified name of the lightning component invoked by the custom action. get
miniiconurl() returns the 16x16 icon url. getname() returns the action name. 2497apex reference guide describequickactionresult class getshowquickactionlcheader() returns an indication of whether the lightning component quick action header and footer are shown. getshowquickactionvfheader() returns an indication of whether the visualforce quick action header and footer should be shown. getsourcesobjecttype() returns the object type used for the action. gettargetparentfield() returns the parent object’s type for the action. gettargetrecordtypeid() returns the record type of the targeted record. gettargetsobjecttype() returns the action’s target object type. gettype() returns a create or custom visualforce action. getvisualforcepagename() if visualforce is used, returns the name of the associated page for the action. getvisualforcepageurl() returns the url of the visualforce page associated with the action. getwidth() if a custom action is created, returns the width in pixels of the action pane. getactionenumorid() returns the unique id for the action. if the action doesn’t have an id, its api name is used. signature public string getactionenumorid() return value type: string getcanvasapplicationname() returns the name of the canvas application, if used. syntax public string getcanvasapplicationname() return value type: string 2498apex reference guide describequickactionresult class getcolors() returns an array of color information. each color is associated with a theme. signature public list<schema.describecolorresult> getcolors() return value type: list <schema.describecolorresult> getcontextsobjecttype() returns the object used for the action. replaces getsourcesobjecttype() in api version 30.0 and later. signature public string getcontextsobjecttype() return value type: string getdefaultvalues() returns the default values for a action. signature public list<quickaction.describequickactiondefaultvalue> getdefaultvalues() return value type: list<quickaction.describequickactiondefaultvalue> getflowdevname() if the custom action invokes a flow, returns the fully qualified name of the flow invoked by the custom action. signature public string getflowdevname() return value type: string getflowrecordidvar() if the custom action invokes a flow, returns the input variable that the custom action passes the record’s id to. 2499apex reference guide describequickactionresult class signature public string getflowrecordidvar() return value type: string getheight() returns the height in pixels of the action pane. signature public integer getheight() return value type: integer geticonname() returns the actions’ icon name. signature public string geticonname() return value type: string geticonurl() returns the url of the 32x32 icon used for the action. signature public string geticonurl() return value type: string geticons() returns a list of schema.describeiconresult objects that describe colors used in a tab. signature public list<schema.describeiconresult> geticons() 2500apex reference guide describequickactionresult class return value type: list<schema.describeiconresult> getlabel() returns the action label. signature public string getlabel() return value type: string getlayout() returns the layout sections that comprise an action. signature public quickaction.describelayoutsection getlayout() return value type: quickaction.describelayoutsection getlightningcomponentbundleid() if the custom action invokes a lightning component, returns the id of the lightning component bundle to which the component belongs. signature public string getlightningcomponentbundleid() return value type: string getlightningcomponentbundlename() if the custom action invokes a lightning component, returns the name of the lightning component bundle to which the component belongs. signature public string getlightningcomponentbundlename() 2501apex reference guide describequickactionresult class return value type: string getlightningcomponentqualifiedname() if the custom action invokes a lightning component, returns the fully qualified name of the lightning component invoked by the