text
stringlengths
24
5.1k
custom action. signature public string getlightningcomponentqualifiedname() return value type: string getminiiconurl() returns the 16x16 icon url. signature public string getminiiconurl() return value type: string getname() returns the action name. signature public string getname() return value type: string getshowquickactionlcheader() returns an indication of whether the lightning component quick action header and footer are shown. signature public boolean getshowquickactionlcheader() 2502apex reference guide describequickactionresult class return value type: boolean if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. getshowquickactionvfheader() returns an indication of whether the visualforce quick action header and footer should be shown. signature public boolean getshowquickactionvfheader() return value type: boolean if false, then both the header containing the quick action title and the footer containing the save and cancel buttons aren’t displayed. getsourcesobjecttype() returns the object type used for the action. signature public string getsourcesobjecttype() return value type: string gettargetparentfield() returns the parent object’s type for the action. signature public string gettargetparentfield() return value type: string gettargetrecordtypeid() returns the record type of the targeted record. signature public string gettargetrecordtypeid() 2503apex reference guide describequickactionresult class return value type: string gettargetsobjecttype() returns the action’s target object type. signature public string gettargetsobjecttype() return value type: string gettype() returns a create or custom visualforce action. signature public string gettype() return value type: string getvisualforcepagename() if visualforce is used, returns the name of the associated page for the action. signature public string getvisualforcepagename() return value type: string getvisualforcepageurl() returns the url of the visualforce page associated with the action. signature public string getvisualforcepageurl() return value type: string 2504apex reference guide quickactiondefaults class getwidth() if a custom action is created, returns the width in pixels of the action pane. signature public integer getwidth() return value type: integer 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. namespace quickaction usage note: you cannot extend this abstract class. you can use the getter methods when using it in the context of quickaction.quickactiondefaultshandler. salesforce provides a class that extends this class (see quickaction.sendemailquickactiondefaults.) in this section: quickactiondefaults methods quickactiondefaults methods the following are methods for quickactiondefaults. in this section: getactionname() returns the name of the standard email action on case feed (case.email). getactiontype() returns the type of the standard email action on case feed (email). getcontextid() the id of the context related to the standard email action on case feed (case id). gettargetsobject() the target object of the standard email action on case feed (emailmessage). 2505apex reference guide quickactiondefaults class getactionname() returns the name of the standard email action on case feed (case.email). signature public string getactionname() return value type: string getactiontype() returns the type of the standard email action on case feed (email). signature public string getactiontype() return value type: string getcontextid() the id of the context related to the standard email action on case feed (case id). signature public id getcontextid() return value type: id gettargetsobject() the target object of the standard email action on case feed (emailmessage). signature public sobject gettargetsobject() return value type: sobject 2506apex reference guide quickactiondefaultshandler interface 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. namespace quickaction usage to specify default values for the standard email action in the case feed, create a class that implements quickaction.quickactiondefaultshandler. the quickaction.quickactiondefaultshandler interface works in salesforce classic and lightning experience. when working in lightning experience, keep the following things in mind: • the interface overrides email values set up with predefined ids. • the interface works with the out-of-the-box email action provided on cases. you can also use the interface with custom email actions for the case object. • the interface in lightning experience doesn’t support: – email attachments – custom email fields – visualforce email templates, which are a type of email template available in salesforce classic • the from field determines the from address picklist. while you can’t customize this picklist in send email action types via the quickactiondefaultshandler interface, you can customize the from address field. to customize this field, remove the from field from the sendemail quick action layout and add the from address field instead. then provide a valid and verified from address in the quickactiondefaultshandler code. this address must be the current user’s address, an organization-wide email address that the current user has access to, or an email-to-case routing address. • if your apex interface adds content to the email body, merge fields display as unresolved. during preview and send, the merge fields resolve. when you implement this interface, provide an empty parameterless constructor. in this section: quickactiondefaultshandler methods quickactiondefaultshandler example implementations quickactiondefaultshandler methods the following are methods for quickactiondefaultshandler. 2507apex reference guide quickactiondefaultshandler interface in this section: oninitdefaults(actiondefaults) implement this method to provide default values for the standard email action in the case feed. oninitdefaults(actiondefaults) implement this method to provide default values for the standard email action in the case feed. signature public void oninitdefaults(quickaction.quickactiondefaults[] actiondefaults) parameters actiondefaults type: quickaction.quickactiondefaults[] this array contains only one item of type quickaction.sendemailquickactiondefaults. return value type: void quickactiondefaultshandler example implementations these examples are implementations of the quickaction.quickactiondefaultshandler interface. in this example, the oninitdefaults method checks whether the element passed in the array is for the standard email action in the case feed. then, it performs a query to retrieve the case that corresponds to the context id. next, it sets the value of the bcc address of the corresponding email message to a default value. the default value is based on the case reason. finally, it sets the default values of the email template properties. the oninitdefaults method determines the default values based on two criteria: first, whether a reply action on an email message initiated the call to the method, and second, whether any previous emails attached to the case are associated with the call. global class emailpublisherloader implements quickaction.quickactiondefaultshandler { // empty constructor global emailpublisherloader() { } // the main interface method global void oninitdefaults(quickaction.quickactiondefaults[] defaults) { quickaction.sendemailquickactiondefaults sendemaildefaults = null; // check if the quick action is the standard case feed send email action for (integer j = 0; j < defaults.size(); j++) { if (defaults.get(j) instanceof quickaction.sendemailquickactiondefaults && defaults.get(j).gettargetsobject().getsobjecttype() == emailmessage.sobjecttype && defaults.get(j).getactionname().equals('case.email') && defaults.get(j).getactiontype().equals('email')) { sendemaildefaults = 2508apex reference guide quickactiondefaultshandler interface (quickaction.sendemailquickactiondefaults)defaults.get(j); break; } } if (sendemaildefaults != null) { case c = [select status, reason
from case where id=:sendemaildefaults.getcontextid()]; emailmessage emailmessage = (emailmessage)sendemaildefaults.gettargetsobject(); // set bcc address to make sure each email goes for audit emailmessage.bccaddress = getbccaddress(c.reason); /* set template related fields when the in reply to id field is null we know the interface is called on page load. here we check if there are any previous emails attached to the case and load the 'new_case_created' or 'automatic_response' template. when the in reply to id field is not null we know that the interface is called on click of reply/reply all of an email and we load the 'default_reply_template' template */ if (sendemaildefaults.getinreplytoid() == null) { integer emailcount = [select count() from emailmessage where parentid=:sendemaildefaults.getcontextid()]; if (emailcount!= null && emailcount > 0) { sendemaildefaults.settemplateid( gettemplateidhelper('automatic_response')); } else { sendemaildefaults.settemplateid( gettemplateidhelper('new_case_created')); } sendemaildefaults.setinserttemplatebody(false); sendemaildefaults.setignoretemplatesubject(false); } else { sendemaildefaults.settemplateid( gettemplateidhelper('default_reply_template')); sendemaildefaults.setinserttemplatebody(false); sendemaildefaults.setignoretemplatesubject(true); } } } private id gettemplateidhelper(string templateapiname) { id templateid = null; try { templateid = [select id, name from emailtemplate where developername = : templateapiname].id; } catch (exception e) { system.debug('unble to locate emailtemplate using name: ' + templateapiname + ' refer to setup | communications templates ' + templateapiname); 2509apex reference guide quickactiondefaultshandler interface } return templateid; } private string getbccaddress(string reason) { if (reason != null && reason.equals('technical')) { return '[email protected]'; } else if (reason != null && reason.equals('billing')) { return '[email protected]'; } else { return '[email protected]'; } } } in this example, the oninitdefaults method checks whether the element passed in the array is for the standard email action in the case feed. then it performs a query to determine if the case priority is set to high. if the priority is set to high, the email address [email protected] is appended to the bcc field. global class emailpublisherforhighprioritycases implements quickaction.quickactiondefaultshandler { // empty constructor global emailpublisherforhighprioritycases() { } // the main interface method global void oninitdefaults(quickaction.quickactiondefaults[] defaults) { quickaction.sendemailquickactiondefaults sendemaildefaults = (quickaction.sendemailquickactiondefaults)defaults.get(0); emailmessage emailmessage = (emailmessage)sendemaildefaults.gettargetsobject(); case c = [select casenumber, priority from case where id=:sendemaildefaults.getcontextid()]; // if case severity is “high,” append “[email protected]” to the existing (and possibly blank) bcc field if (c.priority != null && c.priority.equals('high')) { // priority is 'high' emailmessage.bccaddress = '[email protected]'; } } } in this example, the oninitdefaults method checks whether the element passed in the array is for the standard email action in the case feed. then it performs a query to determine if the case type is set to problem. if the type is set to problem, the first response email template is inserted into the body of the email. global class emailpublisherforcasetype implements quickaction.quickactiondefaultshandler { // empty constructor global emailpublisherforcasetype() { } // the main interface method global void oninitdefaults(quickaction.quickactiondefaults[] defaults) { quickaction.sendemailquickactiondef
aults sendemaildefaults = (quickaction.sendemailquickactiondefaults)defaults.get(0); 2510apex reference guide quickactiondefaultshandler interface emailmessage emailmessage = (emailmessage)sendemaildefaults.gettargetsobject(); case c = [select casenumber, type from case where id=:sendemaildefaults.getcontextid()]; // if case type is “problem,” insert the “first response” email template if (c.casenumber != null && c.type.equals('problem')) { sendemaildefaults.settemplateid('insert email template id here'); // set the template id corresponding to first response sendemaildefaults.setinserttemplatebody(true); sendemaildefaults.setignoretemplatesubject(false); } } in this example, the oninitdefaults method checks whether the element passed in the array is for the standard email action in the case feed. then it performs a query to determine if the email is a reply or reply all email. if email is a reply or reply all email, the corresponding email templates for these emails are inserted into the body of the email. global class emailpublisherforreplyandreplyall implements quickaction.quickactiondefaultshandler { // empty constructor global emailpublisherforreplyandreplyall() { } // the main interface method global void oninitdefaults(quickaction.quickactiondefaults[] defaults) { quickaction.sendemailquickactiondefaults sendemaildefaults = (quickaction.sendemailquickactiondefaults)defaults.get(0); emailmessage emailmessage = (emailmessage)sendemaildefaults.gettargetsobject(); // if the email is a “reply” email, insert the “reply email template” to the email body if (sendemaildefaults.getactionname().equals('emailmessage._reply')) { sendemaildefaults.settemplateid('insert reply email template id here'); sendemaildefaults.setinserttemplatebody(true); sendemaildefaults.setignoretemplatesubject(false); // if the email is a “reply all” email, insert the “reply all email template” to the email body } else if (sendemaildefaults.getactionname().equals('emailmessage._replyall')) { sendemaildefaults.settemplateid('insert reply all email template id here'); sendemaildefaults.setinserttemplatebody(true); sendemaildefaults.setignoretemplatesubject(false); } 2511apex reference guide quickactionrequest class 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. namespace quickaction usage for apex saved using salesforce api version 28.0, a parent id is associated with the quickactionrequest instead of the context id. the constructor of this class takes no arguments: quickaction.quickactionrequest qar = new quickaction.quickactionrequest(); example in this sample, a new quick action is created to create a contact and assign a record to it. quickaction.quickactionrequest req = new quickaction.quickactionrequest(); // some quick action name req.quickactionname = schema.account.quickaction.accountcreatecontact; // define a record for the quick action to create contact c = new contact(); c.lastname = 'last name'; req.record = c; // provide the context id (or parent id). in this case, it is an account record. req.contextid = '001xx000003dgco'; quickaction.quickactionresult res = quickaction.performquickaction(req); in this section: quickactionrequest constructors quickactionrequest methods see also: quickaction class quickactionrequest constructors the following are constructors for quickactionrequest. 2512apex reference guide quickactionrequest class in this section: quickactionrequest() creates a new instance of the quickaction.quickactionrequest class. quickactionrequest() creates a new instance of the quickaction.quickactionrequest class. signature public quickactionrequest() quickactionrequest methods the following are methods for quickactionrequest. all are instance methods. in this section: getcontextid() returns this quickaction’s context record id. getquickactionname() returns this quickaction’s name. getrecord
() returns the quickaction’s associated record. setcontextid(contextid) sets this quickaction’s context id. returned by getcontextid. setquickactionname(name) sets this quickaction’s name. returned by getquickactionname. setrecord(record) sets a record for this quickaction. returned by getrecord. getcontextid() returns this quickaction’s context record id. signature public id getcontextid() return value type: id getquickactionname() returns this quickaction’s name. 2513apex reference guide quickactionrequest class signature public string getquickactionname() return value type: string getrecord() returns the quickaction’s associated record. signature public sobject getrecord() return value type: sobject setcontextid(contextid) sets this quickaction’s context id. returned by getcontextid. signature public void setcontextid(id contextid) parameters contextid type: id return value type: void usage for apex saved using salesforce api version 28.0, sets this quickaction’s parent id and is returned by getparentid. setquickactionname(name) sets this quickaction’s name. returned by getquickactionname. signature public void setquickactionname(string name) 2514apex reference guide quickactionresult class parameters name type: string return value type: void setrecord(record) sets a record for this quickaction. returned by getrecord. signature public void setrecord(sobject record) parameters record type: sobject return value type: void quickactionresult class after you initiate a quick action with the quickaction class, use the quickactionresult class for processing action results. namespace quickaction see also: quickaction class quickactionresult methods the following are methods for quickactionresult. all are instance methods. in this section: geterrors() if an error occurs, an array of one or more database error objects, along with error codes and descriptions, is returned. getids() the ids of the quickactions being processed. getsuccessmessage() returns the success message associated with the quick action. 2515apex reference guide quickactionresult class iscreated() returns true if the action is created; otherwise, false. issuccess() returns true if the action completes successfully; otherwise, false. geterrors() if an error occurs, an array of one or more database error objects, along with error codes and descriptions, is returned. signature public list<database.error> geterrors() return value type: list<database.error> getids() the ids of the quickactions being processed. signature public list<id> getids() return value type: list<id> getsuccessmessage() returns the success message associated with the quick action. signature public string getsuccessmessage() return value type: string iscreated() returns true if the action is created; otherwise, false. signature public boolean iscreated() 2516apex reference guide sendemailquickactiondefaults class return value type: boolean issuccess() returns true if the action completes successfully; otherwise, false. signature public boolean issuccess() return value type: boolean 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. namespace quickaction usage note: you cannot instantiate this class. one can use the getters/setters when using it in the context of quickaction.quickactiondefaultshandler. in this section: sendemailquickactiondefaults methods sendemailquickactiondefaults methods the following are methods for sendemailquickactiondefaults. in this section: getfromaddresslist() returns a list of email addresses that are available in the from: address drop-down menu for the standard email action. getinreplytoid() returns the email message id of the email to which the reply/reply all action has been invoked. setignoretemplatesubject(useoriginalsubject) specifies whether the template
subject should be ignored (true), thus using the original subject, or whether the template subject should replace the original subject (false). 2517apex reference guide sendemailquickactiondefaults class setinserttemplatebody(keeporiginalbodycontent) specifies whether the template body should be inserted above the original body content (true) or whether it should replace the entire content with the template body (false). settemplateid(templateid) sets the email template id to load into the email body. getfromaddresslist() returns a list of email addresses that are available in the from: address drop-down menu for the standard email action. signature public list<string> getfromaddresslist() return value type: list<string> getinreplytoid() returns the email message id of the email to which the reply/reply all action has been invoked. signature public id getinreplytoid() return value type: id setignoretemplatesubject(useoriginalsubject) specifies whether the template subject should be ignored (true), thus using the original subject, or whether the template subject should replace the original subject (false). signature public void setignoretemplatesubject(boolean useoriginalsubject) parameters useoriginalsubject type: boolean return value type: void 2518apex reference guide reports namespace setinserttemplatebody(keeporiginalbodycontent) specifies whether the template body should be inserted above the original body content (true) or whether it should replace the entire content with the template body (false). signature public void setinserttemplatebody(boolean keeporiginalbodycontent) parameters keeporiginalbodycontent type: boolean return value type: void settemplateid(templateid) sets the email template id to load into the email body. signature public void settemplateid(id templateid) parameters templateid type: id the template id. return value type: void reports namespace the reports namespace provides classes for accessing the same data as is available in the salesforce reports and dashboards rest api. the following are the classes in the reports namespace. in this section: aggregatecolumn class contains methods for describing summary fields such as record count, sum, average, max, min, and custom summary formulas. includes name, label, data type, and grouping context. 2519apex reference guide reports namespace bucketfield class contains methods and constructors to work with information about a bucket field, including bucket type, name, and bucketed values. bucketfieldvalue class contains information about the report values included in a bucket field. buckettype enum the types of values included in a bucket. columndatatype enum the reports.columndatatype enum describes the type of data in a column. it is returned by the getdatatype method. columnsortorder enum the reports.columnsortorder enum describes the order that the grouping column uses to sort data. crossfilter class contains methods and constructors used to work with information about a cross filter. csfgrouptype enum the group level at which the custom summary format aggregate is displayed in a report. dategranularity enum the reports.dategranularity enum describes the date interval that is used for grouping. detailcolumn class contains methods for describing fields that contain detailed data. detailed data fields are also listed in the report metadata. dimension class contains information for each row or column grouping. evaluatedcondition class contains the individual components of an evaluated condition for a report notification, such as the aggregate name and label, the operator, and the value that the aggregate is compared to. evaluatedconditionoperator enum the reports.evaluatedconditionoperator enum describes the type of operator used to compare an aggregate to a value. it is returned by the getoperator method. filteroperator class contains information about a filter operator, such as display name and api name. filtervalue class contains information about a filter value, such as the display name and api name. formulatype enum the format of the numbers in a custom summary formula. groupingcolumn class contains methods for describing fields that are used for column grouping. groupinginfo class contains methods for describing fields that are used for grouping. groupingvalue class contains grouping values for a row or column, including the key, label, and value. notificationaction interface implement this interface to trigger a custom apex class when the conditions for a report notification are met. 2520apex
reference guide reports namespace notificationactioncontext class contains information about the report instance and condition threshold for a report notification. reportcsf class contains methods and constructors for working with information about a custom summary formula (csf). reportcurrency class contains information about a currency value, including the amount and currency code. reportdatacell class contains the data for a cell in the report, including the display label and value. reportdescriberesult class contains report, report type, and extended metadata for a tabular, summary, or matrix report. reportdetailrow class contains data cells for a detail row of a report. reportdivisioninfo class contains information about the divisions that can be used to filter a report. reportextendedmetadata class contains report extended metadata for a tabular, summary, or matrix report. reportfact class contains the fact map for the report, which represents the report’s data values. reportfactwithdetails class contains the detailed fact map for the report, which represents the report’s data values. reportfactwithsummaries class contains the fact map for the report, which represents the report’s data values, and includes summarized fields. reportfilter class contains information about a report filter, including column, operator, and value. reportformat enum contains the possible report format types. reportfiltertype enum the types of values included in a report filter type. reportinstance class returns an instance of a report that was run asynchronously. retrieves the results for that instance. reportmanager class runs a report synchronously or asynchronously and with or without details. reportmetadata class contains report metadata for a tabular, summary, or matrix report. reportresults class contains the results of running a report. reportscopeinfo class contains information about possible scope values that you can choose. scope values depend on the report type. for example, you can set the scope for opportunity reports to all opportunities, my team’s opportunities, or my opportunities. 2521apex reference guide reports namespace reportscopevalue class contains information about a possible scope value. scope values depend on the report type. for example, you can set the scope for opportunity reports to all opportunities, my team’s opportunities, or my opportunities. reporttype class contains the unique api name and display name for the report type. reporttypecolumn class contains detailed report type metadata about a field, including data type, display name, and filter values. reporttypecolumncategory class information about categories of fields in a report type. reporttypemetadata class contains report type metadata, which gives you information about the fields that are available in each section of the report type, plus filter information for those fields. sortcolumn class contains information about the sort column used in the report. standarddatefilter class contains information about standard date filter available in the report—for example, the api name, start date, and end date of the standard date filter duration as well as the api name of the date field on which the filter is placed. standarddatefilterduration class contains information about each standard date filter—also referred to as a relative date filter. it contains the api name and display label of the standard date filter duration as well as the start and end dates. standarddatefilterdurationgroup class contains information about the standard date filter groupings, such as the grouping display label and all standard date filters that fall under the grouping. groupings include calendar year, calendar quarter, calendar month, calendar week, fiscal year, fiscal quarter, day, and custom values based on user-defined date ranges. standardfilter class contains information about the standard filter defined in the report, such as the filter field api name and filter value. standardfilterinfo class is an abstract base class for an object that provides standard filter information. standardfilterinfopicklist class contains information about the standard filter picklist, such as the display name and type of the filter field, the default picklist value, and a list of all possible picklist values. standardfiltertype enum the standardfiltertype enum describes the type of standard filters in a report. the gettype() method returns a reports.standardfiltertype enum value. summaryvalue class contains summary data for a cell of the report. thresholdinformation class contains a list of evaluated conditions for a report notification. toprows class contains methods and constructors for working with information about a row limit filter. reports exceptions the reports namespace contains exception classes.
2522apex reference guide aggregatecolumn class aggregatecolumn class contains methods for describing summary fields such as record count, sum, average, max, min, and custom summary formulas. includes name, label, data type, and grouping context. namespace reports aggregatecolumn methods the following are methods for aggregatecolumn. all are instance methods. in this section: getname() returns the unique api name of the summary field. getlabel() returns the localized display name for the summarized or custom summary formula field. getdatatype() returns the data type of the summarized or custom summary formula field. getacrossgroupingcontext() returns the column grouping in the report where the summary field is displayed. getdowngroupingcontext() returns the row grouping in the report where the summary field is displayed. getname() returns the unique api name of the summary field. syntax public string getname() return value type: string getlabel() returns the localized display name for the summarized or custom summary formula field. syntax public string getlabel() 2523apex reference guide bucketfield class return value type: string getdatatype() returns the data type of the summarized or custom summary formula field. syntax public reports.columndatatype getdatatype() return value type: reports.columndatatype getacrossgroupingcontext() returns the column grouping in the report where the summary field is displayed. syntax public string getacrossgroupingcontext() return value type: string getdowngroupingcontext() returns the row grouping in the report where the summary field is displayed. syntax public string getdowngroupingcontext() return value type: string bucketfield class contains methods and constructors to work with information about a bucket field, including bucket type, name, and bucketed values. namespace reports in this section: bucketfield constructors 2524apex reference guide bucketfield class bucketfield methods bucketfield constructors the following are constructors for bucketfield. in this section: bucketfield(buckettype, devlopername, label, nulltreatedaszero, otherbucketlabel, sourcecolumnname, values) creates an instance of the reports.bucketfield class using the specified parameters. bucketfield() creates an instance of the reports.bucketfield class. you can then set values by using the class’s set methods. bucketfield(buckettype, devlopername, label, nulltreatedaszero, otherbucketlabel, sourcecolumnname, values) creates an instance of the reports.bucketfield class using the specified parameters. signature public bucketfield(reports.buckettype buckettype, string devlopername, string label, boolean nulltreatedaszero, string otherbucketlabel, string sourcecolumnname, list<reports.bucketfieldvalue> values) parameters buckettype type: reports.buckettype the type of bucket. devlopername type: string api name of the bucket. label type: string user-facing name of the bucket. nulltreatedaszero type: boolean specifies whether null values are converted to zero (true) or not (false). otherbucketlabel type: string name of the fields grouped as other (in buckets of buckettype picklist). sourcecolumnname type: string name of the bucketed field. 2525apex reference guide bucketfield class values type: list<reports.buckettype> types of the values included in the bucket. bucketfield() creates an instance of the reports.bucketfield class. you can then set values by using the class’s set methods. signature public bucketfield() bucketfield methods the following are methods for bucketfield. in this section: getbuckettype() returns the bucket type. getdevlopername() returns the bucket’s api name. getlabel() returns the user-facing name of the bucket. getnulltreatedaszero() returns true if null values are converted to the number zero, otherwise returns false. getotherbucketlabel() returns the name of fields grouped as other in buckets of type picklist. getsourcecolumnname() returns the api name of the bucketed field. getvalues() returns the report values grouped by the bucket field. setbuckettype(value) sets the buckettype of the bucket. setb
uckettype(buckettype) sets the buckettype of the bucket. setdevlopername(devlopername) sets the api name of the bucket. setlabel(label) sets the user-facing name of the bucket. setnulltreatedaszero(nulltreatedaszero) specifies whether null values in the bucket are converted to zero (true) or not (false). 2526apex reference guide bucketfield class setotherbucketlabel(otherbucketlabel) sets the name of the fields grouped as other (in buckets of buckettype picklist). setsourcecolumnname(sourcecolumnname) specifies the name of the bucketed field. setvalues(values) specifies which type of values are included in the bucket. tostring() returns a string. getbuckettype() returns the bucket type. signature public reports.buckettype getbuckettype() return value type: reports.buckettype getdevlopername() returns the bucket’s api name. signature public string getdevlopername() return value type: string getlabel() returns the user-facing name of the bucket. signature public string getlabel() return value type: string getnulltreatedaszero() returns true if null values are converted to the number zero, otherwise returns false. 2527apex reference guide bucketfield class signature public boolean getnulltreatedaszero() return value type: boolean getotherbucketlabel() returns the name of fields grouped as other in buckets of type picklist. signature public string getotherbucketlabel() return value type: string getsourcecolumnname() returns the api name of the bucketed field. signature public string getsourcecolumnname() return value type: string getvalues() returns the report values grouped by the bucket field. signature public list<reports.bucketfieldvalue> getvalues() return value type: list on page 3123<reports.bucketfieldvalue> setbuckettype(value) sets the buckettype of the bucket. signature public void setbuckettype(string value) 2528apex reference guide bucketfield class parameters value type: string see the reports.buckettype enum for valid values. return value type: void setbuckettype(buckettype) sets the buckettype of the bucket. signature public void setbuckettype(reports.buckettype buckettype) parameters buckettype type: reports.buckettype return value type: void setdevlopername(devlopername) sets the api name of the bucket. signature public void setdevlopername(string devlopername) parameters devlopername type: string the api name to assign to the bucket. return value type: void setlabel(label) sets the user-facing name of the bucket. 2529apex reference guide bucketfield class signature public void setlabel(string label) parameters label type: string return value type: void setnulltreatedaszero(nulltreatedaszero) specifies whether null values in the bucket are converted to zero (true) or not (false). signature public void setnulltreatedaszero(boolean nulltreatedaszero) parameters nulltreatedaszero type: boolean return value type: void setotherbucketlabel(otherbucketlabel) sets the name of the fields grouped as other (in buckets of buckettype picklist). signature public void setotherbucketlabel(string otherbucketlabel) parameters otherbucketlabel type: string return value type: void setsourcecolumnname(sourcecolumnname) specifies the name of the bucketed field. 2530apex reference guide bucketfieldvalue class signature public void setsourcecolumnname(string sourcecolumnname) parameters sourcecolumnname type: string return value type: void setvalues(values) specifies which type of values are included in the bucket. signature public void setvalues(list<reports.bucketfieldvalue> values) parameters values type: list on page 3123<reports.bucketfieldvalue> return value type: void tostring() returns a string. signature public string tostring() return value type
: string bucketfieldvalue class contains information about the report values included in a bucket field. namespace reports 2531apex reference guide bucketfieldvalue class in this section: bucketfieldvalue constructors bucketfieldvalue methods bucketfieldvalue constructors the following are constructors for bucketfieldvalue. in this section: bucketfieldvalue(label, sourcedimensionvalues, rangeupperbound) creates an instance of the reports.bucketfieldvalue class using the specified parameters. bucketfieldvalue() creates an instance of the reports.bucketfieldvalue class. you can then set values by using the class’s set methods. bucketfieldvalue(label, sourcedimensionvalues, rangeupperbound) creates an instance of the reports.bucketfieldvalue class using the specified parameters. signature public bucketfieldvalue(string label, list<string> sourcedimensionvalues, double rangeupperbound) parameters label type: string the user-facing name of the bucket. sourcedimensionvalues type: list on page 3123<string> a list of the values from the source field included in this bucket category (in buckets of type picklist and buckets of type text). rangeupperbound type: double the greatest range limit under which values are included in this bucket category (in buckets of type number). bucketfieldvalue() creates an instance of the reports.bucketfieldvalue class. you can then set values by using the class’s set methods. signature public bucketfieldvalue() bucketfieldvalue methods the following are methods for bucketfieldvalue. 2532
apex reference guide bucketfieldvalue class in this section: getlabel() returns the user-facing name of the bucket category. getrangeupperbound() returns the greatest range limit under which values are included in this bucket category (in buckets of type number). getsourcedimensionvalues() returns a list of the values from the source field included in this bucket category (in buckets of type picklist and buckets of type text). setlabel(label) set the user-facing name of the bucket category. setrangeupperbound(rangeupperbound) sets the greatest limit of a range under which values are included in this bucket category (in buckets of type number). setsourcedimensionvalues(sourcedimensionvalues) specifies the values from the source field included in this bucket category (in buckets of type picklist and buckets of type text). tostring() returns a string. getlabel() returns the user-facing name of the bucket category. signature public string getlabel() return value type: string getrangeupperbound() returns the greatest range limit under which values are included in this bucket category (in buckets of type number). signature public double getrangeupperbound() return value type: double getsourcedimensionvalues() returns a list of the values from the source field included in this bucket category (in buckets of type picklist and buckets of type text). 2533apex reference guide bucketfieldvalue class signature public list<string> getsourcedimensionvalues() return value type: list<string> setlabel(label) set the user-facing name of the bucket category. signature public void setlabel(string label) parameters label type: string return value type: void setrangeupperbound(rangeupperbound) sets the greatest limit of a range under which values are included in this bucket category (in buckets of type number). signature public void setrangeupperbound(double rangeupperbound) parameters rangeupperbound type: double return value type: void setsourcedimensionvalues(sourcedimensionvalues) specifies the values from the source field included in this bucket category (in buckets of type picklist and buckets of type text). signature public void setsourcedimensionvalues(list<string> sourcedimensionvalues) 2534apex reference guide buckettype enum parameters sourcedimensionvalues type: list<string> return value type: void tostring() returns a string. signature public string tostring() return value type: string buckettype enum the types of values included in a bucket. enum values the following are the values of the reports.buckettype enum. value description number numeric values picklist picklist values text string values columndatatype enum the reports.columndatatype enum describes the type of data in a column. it is returned by the getdatatype method. namespace reports enum values the following are the values of the reports.columndatatype enum. 2535apex reference guide columnsortorder enum value description boolean_data boolean (true or false) values combobox_data comboboxes, which provide a set of enumerated values and enable the user to specify a value that is not in the list currency_data currency values datetime_data datetime values date_data date values double_data double values email_data email addresses id_data an object’s salesforce id int_data integer values multipicklist_data multi-select picklists, which provide a set of enumerated values from which multiple values can be selected percent_data percent values phone_data phone numbers. values can include alphabetic characters. client applications are responsible for phone number formatting. picklist_data single-select picklists, which provide a set of enumerated values from which only one value can be selected reference_data cross-references to another object, analogous to a foreign key field string_data string values textarea_data string values that are displayed as multiline text fields time_data time values url_data url values that are displayed as hyperlinks columnsortorder enum the reports.columnsortorder enum describes the order that the grouping column uses to sort data. namespace reports usage the groupinginfo.getcolumn
sortorder() method returns a reports.columnsortorder enum value. the groupinginfo.setcolumnsortorder() method takes the enum value as an argument. 2536apex reference guide crossfilter class enum values the following are the values of the reports.columnsortorder enum. value description ascending sort data in ascending order (a–z) descending sort data in descending order (z–a) crossfilter class contains methods and constructors used to work with information about a cross filter. namespace reports in this section: crossfilter constructors crossfilter methods crossfilter constructors the following are constructors for crossfilter. in this section: crossfilter(criteria, includesobject, primaryentityfield, relatedentity, relatedentityjoinfield) creates an instance of the reports.crossfilter class using the specified parameters. crossfilter() creates an instance of the reports.crossfilter class. you can then set values by using the class’s set methods. crossfilter(criteria, includesobject, primaryentityfield, relatedentity, relatedentityjoinfield) creates an instance of the reports.crossfilter class using the specified parameters. signature public crossfilter(list<reports.reportfilter> criteria, boolean includesobject, string primaryentityfield, string relatedentity, string relatedentityjoinfield) parameters criteria type: list<reports.reportfilter> 2537apex reference guide crossfilter class information about how to filter the relatedentity. relates the primary entity with a subset of the relatedentity. includesobject type: boolean specifies whether objects returned have a relationship with the relatedentity (true) or not (false). primaryentityfield type: string the name of the object on which the cross filter is evaluated. relatedentity type: string the name of the object that the primaryentityfield is evaluated against—the right-hand side of the cross filter. relatedentityjoinfield type: string the name of the field used to join the primaryentityfield and relatedentity. crossfilter() creates an instance of the reports.crossfilter class. you can then set values by using the class’s set methods. signature public crossfilter() crossfilter methods the following are methods for crossfilter. in this section: getcriteria() returns information about how to filter the relatedentity. describes the subset of the relatedentity which the primary entity is evaluated against. getincludesobject() returns true if primary object has a relationship with the relatedentity, otherwise returns false. getprimaryentityfield() returns the name of the object on which the cross filter is evaluated. getrelatedentity() returns name of the object that the primaryentityfield is evaluated against—the right-hand side of the cross filter. getrelatedentityjoinfield() returns the name of the field used to join the primaryentityfield and relatedentity. setcriteria(criteria) specifis how to filter the relatedentity. relates the primary entity with a subset of the relatedentity. setincludesobject(includesobject) specifies whether objects returned have a relationship with the relatedentity (true) or not (false). 2538apex reference guide crossfilter class setprimaryentityfield(primaryentityfield) specifies the name of the object on which the cross filter is evaluated. setrelatedentity(relatedentity) specifies the name of the object that the primaryentityfield is evaluated against—the right-hand side of the cross filter. setrelatedentityjoinfield(relatedentityjoinfield) specifies the name of the field used to join the primaryentityfield and relatedentity. tostring() returns a string. getcriteria() returns information about how to filter the relatedentity. describes the subset of the relatedentity which the primary entity is evaluated against. signature public list<reports.reportfilter> getcriteria() return value type: list<reports.reportfilter> getincludesobject() returns true if primary object has a relationship with the relatedentity, otherwise returns false. signature public boolean getincludesobject() return value type: boolean getprimaryentityfield() returns the name of the object on which the cross filter is evaluated. signature public string getprimaryentityfield() return value type: string getrelatedentity() returns name of the object that the primaryentityfield is evaluated against—the right-hand side of the cross filter. 2539apex reference guide crossfilter class signature public string getrelatedentity() return value type: string getrelatedentityjoin
field() returns the name of the field used to join the primaryentityfield and relatedentity. signature public string getrelatedentityjoinfield() return value type: string setcriteria(criteria) specifis how to filter the relatedentity. relates the primary entity with a subset of the relatedentity. signature public void setcriteria(list<reports.reportfilter> criteria) parameters criteria type: list<reports.reportfilter> return value type: void setincludesobject(includesobject) specifies whether objects returned have a relationship with the relatedentity (true) or not (false). signature public void setincludesobject(boolean includesobject) parameters includesobject type: boolean 2540apex reference guide crossfilter class return value type: void setprimaryentityfield(primaryentityfield) specifies the name of the object on which the cross filter is evaluated. signature public void setprimaryentityfield(string primaryentityfield) parameters primaryentityfield type: string return value type: void setrelatedentity(relatedentity) specifies the name of the object that the primaryentityfield is evaluated against—the right-hand side of the cross filter. signature public void setrelatedentity(string relatedentity) parameters relatedentity type: string return value type: void setrelatedentityjoinfield(relatedentityjoinfield) specifies the name of the field used to join the primaryentityfield and relatedentity. signature public void setrelatedentityjoinfield(string relatedentityjoinfield) parameters relatedentityjoinfield type: string 2541apex reference guide csfgrouptype enum return value type: void tostring() returns a string. signature public string tostring() return value type: string csfgrouptype enum the group level at which the custom summary format aggregate is displayed in a report. enum values the following are the values of the reports.csfgrouptype enum. value description all the aggregate is displayed at the end of every summary row. custom the aggregate is displayed at specified grouping levels. grand_total the aggregate is displayed only at the grand total level. dategranularity enum the reports.dategranularity enum describes the date interval that is used for grouping. namespace reports usage the groupinginfo.getdategranularity method returns a reports.dategranularity enum value. the groupinginfo.setdategranularity method takes the enum value as an argument. enum values the following are the values of the reports.dategranularity enum. 2542apex reference guide detailcolumn class value description day the day of the week (monday–sunday) day_in_month the day of the month (1–31) fiscal_period the fiscal period fiscal_quarter the fiscal quarter fiscal_week the fiscal week fiscal_year the fiscal year month the month (january–december) month_in_year the month number (1–12) none no date grouping quarter the quarter number (1–4) week the week number (1–52) year the year number (####) detailcolumn class contains methods for describing fields that contain detailed data. detailed data fields are also listed in the report metadata. namespace reports detailcolumn instance methods the following are instance methods for detailcolumn. all are instance methods. in this section: getname() returns the unique api name of the detail column field. getlabel() returns the localized display name of a standard field, the id of a custom field, or the api name of a bucket field that has detailed data. getdatatype() returns the data type of a detail column field. getname() returns the unique api name of the detail column field. 2543apex reference guide dimension class syntax public string getname() return value type: string getlabel() returns the localized display name of a standard field, the id of a custom field, or the api name of a bucket field that has detailed data. syntax public string getlabel() return value type: string getdatatype() returns the data type of a detail column field. syntax public reports.columndatatype getdatatype() return value type: reports.columndatatype dimension class contains information for each row or column grouping.
namespace reports dimension methods the following are methods for dimension. all are instance methods. in this section: getgroupings() returns information for each row or column grouping as a list. 2544apex reference guide evaluatedcondition class getgroupings() returns information for each row or column grouping as a list. syntax public list<reports.groupingvalue> getgroupings() return value type: list<reports.groupingvalue> evaluatedcondition class contains the individual components of an evaluated condition for a report notification, such as the aggregate name and label, the operator, and the value that the aggregate is compared to. namespace reports in this section: evaluatedcondition constructors evaluatedcondition methods evaluatedcondition constructors the following are constructors for evaluatedcondition. in this section: evaluatedcondition(aggregatename, aggregatelabel, comparetovalue, aggregatevalue, displaycompareto, displayvalue, operator) creates a new instance of the reports.evaluatedconditions class using the specified parameters. evaluatedcondition(aggregatename, aggregatelabel, comparetovalue, aggregatevalue, displaycompareto, displayvalue, operator) creates a new instance of the reports.evaluatedconditions class using the specified parameters. signature public evaluatedcondition(string aggregatename, string aggregatelabel, double comparetovalue, double aggregatevalue, string displaycompareto, string displayvalue, reports.evaluatedconditionoperator operator) 2545apex reference guide evaluatedcondition class parameters aggregatename type: string the unique api name of the aggregate. aggregatelabel type: string the localized display name of the aggregate. comparetovalue type: double the value that the aggregate is compared to in the condition. aggregatevalue type: double the actual value of the aggregate when the report is run. displaycompareto type: string the value that the aggregate is compared to in the condition, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. displayvalue type: string the value of the aggregate when the report is run, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. operator type: reports.evaluatedconditionoperator the operator used in the condition. evaluatedcondition methods the following are methods for evaluatedcondition. in this section: getaggregatelabel() returns the localized display name of the aggregate. getaggregatename() returns the unique api name of the aggregate. getcompareto() returns the value that the aggregate is compared to in the condition. getdisplaycompareto() returns the value that the aggregate is compared to in the condition, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. getdisplayvalue() returns the value of the aggregate when the report is run, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. 2546apex reference guide evaluatedcondition class getoperator() returns the operator used in the condition. getvalue() returns the actual value of the aggregate when the report is run. getaggregatelabel() returns the localized display name of the aggregate. signature public string getaggregatelabel() return value type: string getaggregatename() returns the unique api name of the aggregate. signature public string getaggregatename() return value type: string getcompareto() returns the value that the aggregate is compared to in the condition. signature public double getcompareto() return value type: double getdisplaycompareto() returns the value that the aggregate is compared to in the condition, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. signature public string getdisplaycompareto() 2547apex reference guide evaluatedconditionoperator enum return value type: string getdisplayvalue() returns the value of the aggregate when the report is run, formatted for display. for example, a display value for a currency is $20.00 or usd20.00 instead of 20.00. signature public string getdisplayvalue() return value type: string getoperator()
returns the operator used in the condition. signature public reports.evaluatedconditionoperator getoperator() return value type: reports.evaluatedconditionoperator getvalue() returns the actual value of the aggregate when the report is run. signature public double getvalue() return value type: double evaluatedconditionoperator enum the reports.evaluatedconditionoperator enum describes the type of operator used to compare an aggregate to a value. it is returned by the getoperator method. namespace reports 2548apex reference guide filteroperator class enum values the following are the values of the reports.evaluatedconditionoperator enum. value description equal equality operator. greater_than greater than operator. greater_than_equal greater than or equal to operator. less_than less than operator. less_than_equal less than or equal to operator. not_equal inequality operator. filteroperator class contains information about a filter operator, such as display name and api name. namespace reports filteroperator methods the following are methods for filteroperator. all are instance methods. in this section: getlabel() returns the localized display name of the filter operator. possible values for this name are restricted based on the data type of the column being filtered. getname() returns the unique api name of the filter operator. possible values for this name are restricted based on the data type of the column being filtered. for example multipicklist fields can use the following filter operators: “equals,” “not equal to,” “includes,” and “excludes.” bucket fields are considered to be of the string type. getlabel() returns the localized display name of the filter operator. possible values for this name are restricted based on the data type of the column being filtered. syntax public string getlabel() 2549apex reference guide filtervalue class return value type: string getname() returns the unique api name of the filter operator. possible values for this name are restricted based on the data type of the column being filtered. for example multipicklist fields can use the following filter operators: “equals,” “not equal to,” “includes,” and “excludes.” bucket fields are considered to be of the string type. syntax public string getname() return value type: string filtervalue class contains information about a filter value, such as the display name and api name. namespace reports filtervalue methods the following are methods for filtervalue. all are instance methods. in this section: getlabel() returns the localized display name of the filter value. possible values for this name are restricted based on the data type of the column being filtered. getname() returns the unique api name of the filter value. possible values for this name are restricted based on the data type of the column being filtered. getlabel() returns the localized display name of the filter value. possible values for this name are restricted based on the data type of the column being filtered. syntax public string getlabel() 2550apex reference guide formulatype enum return value type: string getname() returns the unique api name of the filter value. possible values for this name are restricted based on the data type of the column being filtered. syntax public string getname() return value type: string formulatype enum the format of the numbers in a custom summary formula. enum values the following are the values of the reports.formulatype enum. value description currency formatted as currency. for example, $100.00. number formatted as numbers. for example, 100. percent formatted as percentages. for example, 100%. groupingcolumn class contains methods for describing fields that are used for column grouping. namespace reports the groupingcolumn class provides basic information about column grouping fields. the groupinginfo class includes additional methods for describing and updating grouping fields. groupingcolumn methods the following are methods for groupingcolumn. all are instance methods. 2551apex reference guide groupingcolumn class in this section: getname() returns the unique api name of the field or bucket field that is used for column grouping. getlabel() returns the localized display name of the field that is used for column grouping. getdata
type() returns the data type of the field that is used for column grouping. getgroupinglevel() returns the level of grouping for the column. getname() returns the unique api name of the field or bucket field that is used for column grouping. syntax public string getname() return value type: string getlabel() returns the localized display name of the field that is used for column grouping. syntax public string getlabel() return value type: string getdatatype() returns the data type of the field that is used for column grouping. syntax public reports.columndatatype getdatatype() return value type: reports.columndatatype getgroupinglevel() returns the level of grouping for the column. 2552apex reference guide groupinginfo class syntax public integer getgroupinglevel() return value type: integer usage • in a summary report, 0, 1, or 2 indicates grouping at the first, second, or third row level. • in a matrix report, 0 or 1 indicates grouping at the first or second row or column level. groupinginfo class contains methods for describing fields that are used for grouping. namespace reports groupinginfo methods the following are methods for groupinginfo. all are instance methods. in this section: getname() returns the unique api name of the field or bucket field that is used for row or column grouping. getsortorder() returns the order that is used to sort data in a row or column grouping (ascending or descending). getdategranularity() returns the date interval that is used for row or column grouping. getsortaggregate() returns the summary field that is used to sort data within a grouping in a summary report. the value is null when data within a grouping is not sorted by a summary field. getname() returns the unique api name of the field or bucket field that is used for row or column grouping. syntax public string getname() return value type: string 2553apex reference guide groupingvalue class getsortorder() returns the order that is used to sort data in a row or column grouping (ascending or descending). syntax public reports.columnsortorder getsortorder() return value type: reports.columnsortorder getdategranularity() returns the date interval that is used for row or column grouping. syntax public reports.dategranularity getdategranularity() return value type: reports.dategranularity getsortaggregate() returns the summary field that is used to sort data within a grouping in a summary report. the value is null when data within a grouping is not sorted by a summary field. syntax public string getsortaggregate() return value type: string groupingvalue class contains grouping values for a row or column, including the key, label, and value. namespace reports groupingvalue methods the following are methods for groupingvalue. all are instance methods. 2554apex reference guide groupingvalue class in this section: getgroupings() returns a list of second- or third-level row or column groupings. if there are none, the value is an empty array. getkey() returns the unique identifier for a row or column grouping. the identifier is used by the fact map to specify data values within each grouping. getlabel() returns the localized display name of a row or column grouping. for date and time fields, the label is the localized date or time. getvalue() returns the value of the field that is used as a row or column grouping. getgroupings() returns a list of second- or third-level row or column groupings. if there are none, the value is an empty array. syntax public list<reports.groupingvalue> getgroupings() return value type: list<reports.groupingvalue> getkey() returns the unique identifier for a row or column grouping. the identifier is used by the fact map to specify data values within each grouping. syntax public string getkey() return value type: string getlabel() returns the localized display name of a row or column grouping. for date and time fields, the label is the localized date or time. syntax public string getlabel() return value type: string 2555apex reference guide notificationaction interface getvalue() returns the value of the field that is used as a row or column grouping. syntax public object get
value() return value type: object usage the value depends on the field’s data type. • currency fields: – amount: of type currency. a data cell’s value. – currency: of type picklist. the iso 4217 currency code, if available; for example, usd for us dollars or cny for chinese yuan. (if the grouping is on the converted currency, this value is the currency code for the report and not for the record.) • picklist fields: api name. for example, a custom picklist field—type of business with values 1, 2, and 3 for consulting, services, and add-on business respectively—has 1, 2, or 3 as the grouping value. • id fields: api name. • record type fields: api name. • date and time fields: date or time in iso-8601 format. • lookup fields: unique api name. for example, for the opportunity owner lookup field, the id of each opportunity owner’s chatter profile page can be a grouping value. notificationaction interface implement this interface to trigger a custom apex class when the conditions for a report notification are met. namespace reports usage report notifications for reports that users have subscribed to can trigger a custom apex class, which must implement the reports.notificationaction interface. the execute method in this interface receives a notificationactioncontext object as a parameter, which contains information about the report instance and the conditions that must be met for a notification to be triggered. in this section: notificationaction methods notificationaction example implementation 2556apex reference guide notificationaction interface notificationaction methods the following are methods for notificationaction. in this section: execute(context) executes the custom apex action specified in the context parameter of the context object, notificationactioncontext. the object contains information about the report instance and the conditions that must be met for a notification to be triggered. the method executes whenever the specified conditions are met. execute(context) executes the custom apex action specified in the context parameter of the context object, notificationactioncontext. the object contains information about the report instance and the conditions that must be met for a notification to be triggered. the method executes whenever the specified conditions are met. signature public void execute(reports.notificationactioncontext context) parameters context type: reports.notificationactioncontext return value type: void notificationaction example implementation this is an example implementation of the reports.notificationaction interface. public class alertowners implements reports.notificationaction { public void execute(reports.notificationactioncontext context) { reports.reportresults results = context.getreportinstance().getreportresults(); for(reports.groupingvalue g: results.getgroupingsdown().getgroupings()) { feeditem t = new feeditem(); t.parentid = (id)g.getvalue(); t.body = 'this record needs attention. please view the report.'; t.title = 'needs attention: '+ results.getreportmetadata().getname(); t.linkurl = '/' + results.getreportmetadata().getid(); insert t; } } } 2557apex reference guide notificationactioncontext class notificationactioncontext class contains information about the report instance and condition threshold for a report notification. namespace reports in this section: notificationactioncontext constructors notificationactioncontext methods notificationactioncontext constructors the following are constructors for notificationactioncontext. in this section: notificationactioncontext(reportinstance, thresholdinformation) creates a new instance of the reports.notificationactioncontext class using the specified parameters. notificationactioncontext(reportinstance, thresholdinformation) creates a new instance of the reports.notificationactioncontext class using the specified parameters. signature public notificationactioncontext(reports.reportinstance reportinstance, reports.thresholdinformation thresholdinformation) parameters reportinstance type: reports.reportinstance an instance of a report. thresholdinformation type: reports.thresholdinformation the evaluated conditions for the notification. notificationactioncontext methods the following are methods for notificationactioncontext. in this section: getreportinstance() returns the report instance associated with the notification. 2558apex reference guide reportcsf class getthresholdinformation() returns the threshold information associated with the notification. getreportinstance() returns the report instance associated with the notification. signature public reports.reportinstance getreportinstance() return value type: reports.reportinstance getth
resholdinformation() returns the threshold information associated with the notification. signature public reports.thresholdinformation getthresholdinformation() return value type: reports.thresholdinformation reportcsf class contains methods and constructors for working with information about a custom summary formula (csf). namespace reports in this section: reportcsf constructors reportcsf methods reportcsf constructors the following are constructors for reportcsf. in this section: reportcsf(label, description, formulatype, decimalplaces, downgroup, downgrouptype, acrossgroup, acrossgrouptype, formula) creates an instance of the reports.reportcsf class using the specified parameters. 2559apex reference guide reportcsf class reportcsf() creates an instance of the reports.reportcsf class. you can then set values by using the class’s set methods. reportcsf(label, description, formulatype, decimalplaces, downgroup, downgrouptype, acrossgroup, acrossgrouptype, formula) creates an instance of the reports.reportcsf class using the specified parameters. signature public reportcsf(string label, string description, reports.formulatype formulatype, integer decimalplaces, string downgroup, reports.csfgrouptype downgrouptype, string acrossgroup, reports.csfgrouptype acrossgrouptype, string formula) parameters label type: string the user-facing name of the custom summary formula. description type: string the user-facing description of the custom summary formula. formulatype type: reports.formulatype the format of the numbers in the custom summary formula. decimalplaces type: integer the number of decimal places to include in numbers. downgroup type: string the name of a row grouping when the downgrouptype is custom; null otherwise. downgrouptype type: reports.csfgrouptype where to display the aggregate of the custom summary formula. acrossgroup type: string the name of a column grouping when the accrossgrouptype is custom; null otherwise. acrossgrouptype type: reports.csfgrouptype where to display the aggregate of the custom summary formula. formula type: string the operations performed on values in the custom summary formula. 2560apex reference guide reportcsf class reportcsf() creates an instance of the reports.reportcsf class. you can then set values by using the class’s set methods. signature public reportcsf() reportcsf methods the following are methods for reportcsf. in this section: getacrossgroup() returns the name of a column grouping when the acrossgrouptype is custom. otherwise, returns null. getacrossgrouptype() returns where to display the aggregate. getdecimalplaces() returns the number of decimal places that numbers in the custom summary formula have. getdescription() returns the user-facing description of a custom summary formula. getdowngroup() returns the name of a row grouping when the downgrouptype is custom. otherwise, returns null. getdowngrouptype() returns where to display the aggregate of the custom summary formula. getformula() returns the operations performed on values in the custom summary formula. getformulatype() returns the formula type. getlabel() returns the user-facing name of the custom summary formula. setacrossgroup(acrossgroup) specifies the column for the across grouping. setacrossgrouptype(value) sets where to display the aggregate. setacrossgrouptype(acrossgrouptype) sets where to display the aggregate. setdecimalplaces(decimalplaces) sets the number of decimal places in numbers. setdescription(description) sets the user-facing description of the custom summary formula. setdowngroup(downgroup) sets the name of a row grouping when the downgrouptype is custom. 2561apex reference guide reportcsf class setdowngrouptype(value) sets where to display the aggregate. setdowngrouptype(downgrouptype) sets where to display the aggregate. setformula(formula) sets the operations to perform on values in the custom summary formula. setformulatype(value) sets the format of the numbers in the custom summary formula. setformulatype(formulatype) sets the format of numbers used in the custom summary formula. setlabel(label) sets
the user-facing name of the custom summary formula. tostring() returns a string. getacrossgroup() returns the name of a column grouping when the acrossgrouptype is custom. otherwise, returns null. signature public string getacrossgroup() return value type: string getacrossgrouptype() returns where to display the aggregate. signature public reports.csfgrouptype getacrossgrouptype() return value type: reports.csfgrouptype getdecimalplaces() returns the number of decimal places that numbers in the custom summary formula have. signature public integer getdecimalplaces() 2562apex reference guide reportcsf class return value type: integer getdescription() returns the user-facing description of a custom summary formula. signature public string getdescription() return value type: string getdowngroup() returns the name of a row grouping when the downgrouptype is custom. otherwise, returns null. signature public string getdowngroup() return value type: string getdowngrouptype() returns where to display the aggregate of the custom summary formula. signature public reports.csfgrouptype getdowngrouptype() return value type: reports.csfgrouptype getformula() returns the operations performed on values in the custom summary formula. signature public string getformula() return value type: string 2563apex reference guide reportcsf class getformulatype() returns the formula type. signature public reports.formulatype getformulatype() return value type: reports.formulatype getlabel() returns the user-facing name of the custom summary formula. signature public string getlabel() return value type: string setacrossgroup(acrossgroup) specifies the column for the across grouping. signature public void setacrossgroup(string acrossgroup) parameters acrossgroup type: string return value type: void setacrossgrouptype(value) sets where to display the aggregate. signature public void setacrossgrouptype(string value) 2564apex reference guide reportcsf class parameters value type: string for possible values, see reports.csfgrouptype. return value type: void setacrossgrouptype(acrossgrouptype) sets where to display the aggregate. signature public void setacrossgrouptype(reports.csfgrouptype acrossgrouptype) parameters acrossgrouptype type: reports.csfgrouptype return value type: void setdecimalplaces(decimalplaces) sets the number of decimal places in numbers. signature public void setdecimalplaces(integer decimalplaces) parameters decimalplaces type: integer return value type: void setdescription(description) sets the user-facing description of the custom summary formula. signature public void setdescription(string description) 2565apex reference guide reportcsf class parameters description type: string return value type: void setdowngroup(downgroup) sets the name of a row grouping when the downgrouptype is custom. signature public void setdowngroup(string downgroup) parameters downgroup type: string return value type: void setdowngrouptype(value) sets where to display the aggregate. signature public void setdowngrouptype(string value) parameters value type: string for valid values, see reports.csfgrouptype. return value type: void setdowngrouptype(downgrouptype) sets where to display the aggregate. signature public void setdowngrouptype(reports.csfgrouptype downgrouptype) 2566apex reference guide reportcsf class parameters downgrouptype type: reports.csfgrouptype return value type: void setformula(formula) sets the operations to perform on values in the custom summary formula. signature public void setformula(string formula) parameters formula type: string return value type: void setformulatype(value) sets the format of the numbers in the custom summary formula. signature public void setformulatype(string value) parameters value type: string for valid values, see reports.formulatype. return value type: void setformulatype(formulatype) sets the format of numbers used
in the custom summary formula. signature public void setformulatype(reports.formulatype formulatype) 2567apex reference guide reportcurrency class parameters formulatype type: reports.formulatype return value type: void setlabel(label) sets the user-facing name of the custom summary formula. signature public void setlabel(string label) parameters label type: string return value type: void tostring() returns a string. signature public string tostring() return value type: string reportcurrency class contains information about a currency value, including the amount and currency code. namespace reports reportcurrency methods the following are methods for reportcurrency. all are instance methods. 2568apex reference guide reportdatacell class in this section: getamount() returns the amount of the currency value. getcurrencycode() returns the report currency code, such as usd, eur, or gbp, for an organization that has multicurrency enabled. the value is null if the organization does not have multicurrency enabled. getamount() returns the amount of the currency value. syntax public decimal getamount() return value type: decimal getcurrencycode() returns the report currency code, such as usd, eur, or gbp, for an organization that has multicurrency enabled. the value is null if the organization does not have multicurrency enabled. syntax public string getcurrencycode() return value type: string reportdatacell class contains the data for a cell in the report, including the display label and value. namespace reports reportdatacell methods the following are methods for reportdatacell. all are instance methods. in this section: getlabel() returns the localized display name of the value of a specified cell in the report. 2569apex reference guide reportdescriberesult class getvalue() returns the value of a specified cell of a detail row of a report. getlabel() returns the localized display name of the value of a specified cell in the report. syntax public string getlabel() return value type: string getvalue() returns the value of a specified cell of a detail row of a report. syntax public object getvalue() return value type: object reportdescriberesult class contains report, report type, and extended metadata for a tabular, summary, or matrix report. namespace reports reportdescriberesult methods the following are methods for reportdescriberesult. all are instance methods. in this section: getreportextendedmetadata() returns additional information about grouping and summaries. getreportmetadata() returns unique identifiers for groupings and summaries. getreporttypemetadata() returns the fields in each section of a report type, plus filtering information for those fields. 2570apex reference guide reportdetailrow class getreportextendedmetadata() returns additional information about grouping and summaries. syntax public reports.reportextendedmetadata getreportextendedmetadata() return value type: reports.reportextendedmetadata getreportmetadata() returns unique identifiers for groupings and summaries. syntax public reports.reportmetadata getreportmetadata() return value type: reports.reportmetadata getreporttypemetadata() returns the fields in each section of a report type, plus filtering information for those fields. syntax public reports.reporttypemetadata getreporttypemetadata() return value type: reports.reporttypemetadata reportdetailrow class contains data cells for a detail row of a report. namespace reports reportdetailrow methods the following are methods for reportdetailrow. all are instance methods. 2571apex reference guide reportdivisioninfo class in this section: getdatacells() returns a list of data cells for a detail row. getdatacells() returns a list of data cells for a detail row. syntax public list<reports.reportdatacell> getdatacells() return value type: list<reports.reportdatacell> reportdivisioninfo class contains information about the divisions that can be used to filter a report. available only if your organization uses divisions to segment data and you have the “affected by divisions” permission. if you do not have the “affected by divisions” permission, your reports include records in all divisions. namespace reports usage use
to filter records in the report based on a division, like west coast and east coast. reportdivisioninfo methods the following are methods for reportdivisioninfo. getdefaultvalue() returns the default division for the report. signature public string getdefaultvalue() return value type: string getvalues() returns a list of all possible divisions for the report. 2572apex reference guide reportextendedmetadata class signature public list<reports.filtervalue> getvalues() return value type: list<reports.filtervalue> reportextendedmetadata class contains report extended metadata for a tabular, summary, or matrix report. namespace reports report extended metadata provides additional, detailed metadata about summary and grouping fields, including data type and label information. reportextendedmetadata methods the following are methods for reportextendedmetadata. all are instance methods. in this section: getaggregatecolumninfo() returns all report summaries such as record count, sum, average, max, min, and custom summary formulas. contains values for each summary that is listed in the report metadata. getdetailcolumninfo() returns a map of two properties for each field that has detailed data identified by its unique api name. the detailed data fields are also listed in the report metadata. getgroupingcolumninfo() returns a map of each row or column grouping to its metadata. contains values for each grouping that is identified in the groupingsdown and groupingsacross lists. getaggregatecolumninfo() returns all report summaries such as record count, sum, average, max, min, and custom summary formulas. contains values for each summary that is listed in the report metadata. syntax public map<string,reports.aggregatecolumn> getaggregatecolumninfo() return value type: map<string,reports.aggregatecolumn> 2573apex reference guide reportfact class getdetailcolumninfo() returns a map of two properties for each field that has detailed data identified by its unique api name. the detailed data fields are also listed in the report metadata. syntax public map<string,reports.detailcolumn> getdetailcolumninfo() return value type: map<string,reports.detailcolumn> getgroupingcolumninfo() returns a map of each row or column grouping to its metadata. contains values for each grouping that is identified in the groupingsdown and groupingsacross lists. syntax public map<string,reports.groupingcolumn> getgroupingcolumninfo() return value type: map<string,reports.groupingcolumn> reportfact class contains the fact map for the report, which represents the report’s data values. namespace reports usage reportfact is the parent class of reportfactwithdetails and reportfactwithsummaries. if includedetails is true when the report is run, the fact map is a reportfactwithdetails object. if includedetails is false when the report is run, the fact map is a reportfactwithsummaries object. reportfact methods the following are methods for reportfact. all are instance methods. in this section: getaggregates() returns summary-level data for a report, including the record count. 2574apex reference guide reportfactwithdetails class getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. getaggregates() returns summary-level data for a report, including the record count. syntax public list<reports.summaryvalue> getaggregates() return value type: list<reports.summaryvalue> getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. syntax public string getkey() return value type: string reportfactwithdetails class contains the detailed fact map for the report, which represents the report’s data values. namespace reports usage the reportfactwithdetails class extends the reportfact class. a reportfactwithdetails object is returned if includedetails is set to true when the report is run. to access the detail values, you’ll need to cast the return value of the reportresults.getfactmap method to a reportfactwithdetails object. reportfactwithdetails methods the following are methods for reportfactwithdetails. all are instance methods. 2575apex reference guide reportfactwithsummaries class in this section: getaggregates() returns summary-level data for a report, including
the record count. getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. getrows() returns a list of detailed report data in the order of the detail columns that are provided by the report metadata. getaggregates() returns summary-level data for a report, including the record count. syntax public list<reports.summaryvalue> getaggregates() return value type: list<reports.summaryvalue> getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. syntax public string getkey() return value type: string getrows() returns a list of detailed report data in the order of the detail columns that are provided by the report metadata. syntax public list<reports.reportdetailrow> getrows() return value type: list<reports.reportdetailrow> reportfactwithsummaries class contains the fact map for the report, which represents the report’s data values, and includes summarized fields. 2576apex reference guide reportfactwithsummaries class namespace reports usage the reportfactwithsummaries class extends the reportfact class. a reportfactwithsummaries object is returned if includedetails is set to false when the report is run. reportfactwithsummaries methods the following are methods for reportfactwithsummaries. all are instance methods. in this section: getaggregates() returns summary-level data for a report, including the record count. getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. tostring() returns a string. getaggregates() returns summary-level data for a report, including the record count. syntax public list<reports.summaryvalue> getaggregates() return value type: list<reports.summaryvalue> getkey() returns the unique identifier for a row or column grouping. this identifier can be used to index specific data values within each grouping. syntax public string getkey() return value type: string 2577apex reference guide reportfilter class tostring() returns a string. signature public string tostring() return value type: string reportfilter class contains information about a report filter, including column, operator, and value. namespace reports in this section: reportfilter constructors reportfilter methods reportfilter constructors the following are constructors for reportfilter. in this section: reportfilter() creates a new instance of the reports.reportfilter class. you can then set values by using the “set” methods. reportfilter(column, operator, value) creates a new instance of the reports.reportfilter class by using the specified parameters. reportfilter(column, operator, value, filtertype) creates a new instance of the reports.reportfilter class by using the specified parameters. reportfilter() creates a new instance of the reports.reportfilter class. you can then set values by using the “set” methods. signature public reportfilter() reportfilter(column, operator, value) creates a new instance of the reports.reportfilter class by using the specified parameters. 2578apex reference guide reportfilter class signature public reportfilter(string column, string operator, string value) parameters column type: string operator type: string value type: string reportfilter(column, operator, value, filtertype) creates a new instance of the reports.reportfilter class by using the specified parameters. syntax public reportfiltertype(string column, string operator, string value, reports.reportfiltertype filtertype) parameters column type: string operator type: string value type: string filtertype type: reportfiltertype enum on page 2583 reportfilter methods the following are methods for reportfilter. all are instance methods. in this section: getcolumn() returns the unique api name for the field that’s being filtered. getfiltertype() returns the type of report filter. getoperator() returns the unique api name for the condition that is used to filter a field, such as “greater than” or “not equal to.” filter conditions depend on the data type of the field. 2579apex reference guide reportfilter class
getvalue() returns the value that the field is being filtered by. for example, the field age can be filtered by a numeric value. setcolumn(column) sets the unique api name for the field that’s being filtered. setfiltertype() sets the type of report filter. setoperator(operator) sets the unique api name for the condition that is used to filter a field, such as “greater than” or “not equal to.” filter conditions depend on the data type of the field. setvalue(value) sets the value by which a field can be filtered. for example, the field age can be filtered by a numeric value. tostring(column) returns a string representation of the filter. getcolumn() returns the unique api name for the field that’s being filtered. syntax public string getcolumn() return value type: string getfiltertype() returns the type of report filter. syntax public string getfiltertype() return value type: reportfiltertype enum on page 2583 getoperator() returns the unique api name for the condition that is used to filter a field, such as “greater than” or “not equal to.” filter conditions depend on the data type of the field. syntax public string getoperator() 2580apex reference guide reportfilter class return value type: string getvalue() returns the value that the field is being filtered by. for example, the field age can be filtered by a numeric value. syntax public string getvalue() return value type: string setcolumn(column) sets the unique api name for the field that’s being filtered. syntax public void setcolumn(string column) parameters column type: string return value type: void setfiltertype() sets the type of report filter. syntax public void setfiltertype(string column) parameters column type: string return value type: void 2581apex reference guide reportformat enum setoperator(operator) sets the unique api name for the condition that is used to filter a field, such as “greater than” or “not equal to.” filter conditions depend on the data type of the field. syntax public void setoperator(string operator) parameters operator type: string return value type: void setvalue(value) sets the value by which a field can be filtered. for example, the field age can be filtered by a numeric value. syntax public void setvalue(string value) parameters value type: string return value type: void tostring(column) returns a string representation of the filter. signature public string tostring() return value type: string reportformat enum contains the possible report format types. 2582
apex reference guide reportfiltertype enum namespace reports enum values the following are the values of the reports.reportformat enum. value description matrix matrix report format summary summary report format tabular tabular report format reportfiltertype enum the types of values included in a report filter type. enum values the following are the values of the reports.reportfiltertype enum. value description fieldtofield field-to-field filter fieldvalue field-to-value filter reportinstance class returns an instance of a report that was run asynchronously. retrieves the results for that instance. namespace reports reportinstance methods the following are methods for reportinstance. all are instance methods. in this section: getcompletiondate() returns the date and time when the instance of the report finished running. the completion date is available only if the report instance ran successfully or couldn’t be run because of an error. date and time information is in iso-8601 format. getid() returns the unique id for an instance of a report that was run asynchronously. 2583apex reference guide reportinstance class getownerid() returns the id of the user who created the report instance. getreportid() returns the unique id of the report this instance is based on. getreportresults() retrieves results for an instance of an asynchronous report. when you request your report, you can specify whether to summarize data or include details. getrequestdate() returns the date and time when an instance of the report was run. date and time information is in iso-8601 format. getstatus() returns the status of a report. getcompletiondate() returns the date and time when the instance of the report finished running. the completion date is available only if the report instance ran successfully or couldn’t be run because of an error. date and time information is in iso-8601 format. syntax public datetime getcompletiondate() return value type: datetime getid() returns the unique id for an instance of a report that was run asynchronously. syntax public id getid() return value type: id getownerid() returns the id of the user who created the report instance. syntax public id getownerid() return value type: id 2584apex reference guide reportinstance class getreportid() returns the unique id of the report this instance is based on. syntax public id getreportid() return value type: id getreportresults() retrieves results for an instance of an asynchronous report. when you request your report, you can specify whether to summarize data or include details. syntax public reports.reportresults getreportresults() return value type: reports.reportresults getrequestdate() returns the date and time when an instance of the report was run. date and time information is in iso-8601 format. syntax public datetime getrequestdate() return value type: datetime getstatus() returns the status of a report. syntax public string getstatus() return value type: string 2585apex reference guide reportmanager class usage • new if the report run was recently triggered through a request. • success if the report ran. • running if the report is being run. • error if the report run failed. the instance of a report run can return an error if, for example, your permission to access the report was removed after you requested the run. reportmanager class runs a report synchronously or asynchronously and with or without details. namespace reports usage gets instances of reports and describes the metadata of reports. reportmanager methods the following are methods for reportmanager. all methods are static. in this section: describereport(reportid) retrieves report, report type, and extended metadata for a tabular, summary, or matrix report. getdatatypefilteroperatormap() lists the field data types that you can use to filter the report. getreportinstance(instanceid) retrieves results for an instance of a report that has been run asynchronously. the settings you use when you run your asynchronous report determine whether you can retrieve summary data or detailed data. getreportinstances(reportid) returns a list of instances for a report that was run asynchronously. each item in the list represents a separate instance of the report, with metadata for the time at which the report was run. runasyncreport(report
id, reportmetadata, includedetails) runs a report asynchronously with the report id. includes details if includedetails is set to true. filters the report based on the report metadata in reportmetadata. runasyncreport(reportid, includedetails) runs a report asynchronously with the report id. includes details if includedetails is set to true. runasyncreport(reportid, reportmetadata) runs a report asynchronously with the report id. filters the results based on the report metadata in reportmetadata. runasyncreport(reportid) runs a report asynchronously with the report id. 2586apex reference guide reportmanager class runreport(reportid, reportmetadata, includedetails) runs a report immediately with the report id. includes details if includedetails is set to true. filters the results based on the report metadata in reportmetadata. runreport(reportid, includedetails) runs a report immediately with the report id. includes details if includedetails is set to true. runreport(reportid, reportmetadata) runs a report immediately with the report id. filters the results based on the report metadata in rmdata. runreport(reportid) runs a report immediately with the report id. describereport(reportid) retrieves report, report type, and extended metadata for a tabular, summary, or matrix report. syntax public static reports.reportdescriberesult describereport(id reportid) parameters reportid type: id return value type: reports.reportdescriberesult getdatatypefilteroperatormap() lists the field data types that you can use to filter the report. syntax public static map<string,list<reports.filteroperator>> getdatatypefilteroperatormap() return value type: map<string, list<reports.filteroperator>> getreportinstance(instanceid) retrieves results for an instance of a report that has been run asynchronously. the settings you use when you run your asynchronous report determine whether you can retrieve summary data or detailed data. syntax public static reports.reportinstance getreportinstance(id instanceid) 2587apex reference guide reportmanager class parameters instanceid type: id return value type: reports.reportinstance getreportinstances(reportid) returns a list of instances for a report that was run asynchronously. each item in the list represents a separate instance of the report, with metadata for the time at which the report was run. syntax public static list<reports.reportinstance> getreportinstances(id reportid) parameters reportid type: id return value type: list<reports.reportinstance> runasyncreport(reportid, reportmetadata, includedetails) runs a report asynchronously with the report id. includes details if includedetails is set to true. filters the report based on the report metadata in reportmetadata. syntax public static reports.reportinstance runasyncreport(id reportid, reports.reportmetadata reportmetadata, boolean includedetails) parameters reportid type: id reportmetadata type: reports.reportmetadata includedetails type: boolean return value type: reports.reportinstance 2588apex reference guide reportmanager class runasyncreport(reportid, includedetails) runs a report asynchronously with the report id. includes details if includedetails is set to true. syntax public static reports.reportinstance runasyncreport(id reportid, boolean includedetails) parameters reportid type: id includedetails type: boolean return value type: reports.reportinstance runasyncreport(reportid, reportmetadata) runs a report asynchronously with the report id. filters the results based on the report metadata in reportmetadata. syntax public static reports.reportinstance runasyncreport(id reportid, reports.reportmetadata reportmetadata) parameters reportid type: id reportmetadata type: reports.reportmetadata return value type: reports.reportinstance runasyncreport(reportid) runs a report asynchronously with the report id. syntax public static reports.reportinstance runasyncreport(id reportid) 2589apex reference guide reportmanager class parameters reportid type: id return value type: reports.reportinstance runreport(reportid, reportmetadata, includedetails) runs a report immediately with the report id.
includes details if includedetails is set to true. filters the results based on the report metadata in reportmetadata. syntax public static reports.reportresults runreport(id reportid, reports.reportmetadata reportmetadata, boolean includedetails) parameters reportid type: id reportmetadata type: reports.reportmetadata includedetails type: boolean return value type: reports.reportresults runreport(reportid, includedetails) runs a report immediately with the report id. includes details if includedetails is set to true. syntax public static reports.reportresults runreport(id reportid, boolean includedetails) parameters reportid type: id includedetails type: boolean return value type: reports.reportresults 2590apex reference guide reportmetadata class runreport(reportid, reportmetadata) runs a report immediately with the report id. filters the results based on the report metadata in rmdata. syntax public static reports.reportresults runreport(id reportid, reports.reportmetadata reportmetadata) parameters reportid type: id reportmetadata type: reports.reportmetadatareports.reportmetadata return value type: reports.reportresults runreport(reportid) runs a report immediately with the report id. syntax public static reports.reportresults runreport(id reportid) parameters reportid type: id return value type: reports.reportresults reportmetadata class contains report metadata for a tabular, summary, or matrix report. namespace reports usage report metadata gives information about the report as a whole, such as the report type, format, summary fields, row or column groupings, and filters that are saved to the report. you can use the reportmetadata class to retrieve report metadata and to set metadata that can be used to filter a report. 2591apex reference guide reportmetadata class reportmetadata methods the following are methods for reportmetadata. all are instance methods. in this section: getaggregates() returns unique identifiers for summary or custom summary formula fields in the report. getbuckets() returns a list of bucket fields in the report. getcrossfilters() returns information about cross filters applied to a report. getcurrencycode() returns report currency, such as usd, eur, or gbp, for an organization that has multicurrency enabled. the value is null if the organization does not have multicurrency enabled. getcustomsummaryformula() returns information about custom summary formulas in a report. getdescription() returns the description of the report. getdetailcolumns() returns unique api names (column names) for the fields that contain detailed data. for example, the method might return the following values: “opportunity_name, type, lead_source, amount.” getdevelopername() returns the report api name. for example, the method might return the following value: “closed_sales_this_quarter.” getdivision() returns the division specified in the report. getgroupingsacross() returns column groupings in a report. getgroupingsdown() returns row groupings for a report. gethasdetailrows() indicates whether the report has detail rows. gethasrecordcount() indicates whether the report shows the total number of records. gethistoricalsnapshotdates() returns a list of historical snapshot dates. getid() returns the unique report id. getname() returns the report name. getreportbooleanfilter() returns logic to parse custom field filters. the value is null when filter logic is not specified. 2592apex reference guide reportmetadata class getreportfilters() returns a list of each custom filter in the report along with the field name, filter operator, and filter value. getreportformat() returns the format of the report. getreporttype() returns the unique api name and display name for the report type. getscope() returns the api name for the scope defined for the report. scope values depend on the report type. getshowgrandtotal() indicates whether the report shows the grand total. getshowsubtotals() indicates whether the report shows subtotals, such as column or row totals. getsortby() returns the list of columns on which the report is sorted. currently, you can sort on only one column. getstandarddatefilter() returns information about the standard date filter for the report,
such as the start date, end date, date range, and date field api name. getstandardfilters() returns a list of standard filters for the report. gettoprows() returns information about a row limit filter, including the number of rows returned and the sort order. setaggregates(aggregates) sets unique identifiers for standard or custom summary formula fields in the report. setbuckets(buckets) creates bucket fields in a report. setcrossfilters(crossfilters) applies cross filters to a report. setcurrencycode(currencycode) sets the currency, such as usd, eur, or gbp, for report summary fields in an organization that has multicurrency enabled. setcustomsummaryformula(customsummaryformula) adds a custom summary formula to a report. setdescription(description) sets the description of the report. setdetailcolumns(detailcolumns) sets the unique api names for the fields that contain detailed data—for example, opportunity_name, type, lead_source, or amount. setdevelopername(developername) sets the report api name—for example, closed_sales_this_quarter. setdivision(division) sets the division of the report. 2593apex reference guide reportmetadata class setgroupingsacross(groupinginfo) sets column groupings in a report. setgroupingsdown(groupinginfo) sets row groupings for a report. sethasdetailrows(hasdetailrows) specifies whether the report has detail rows. sethasrecordcount(hasrecordcount) specifies whether the report is configured to show the total number of records. sethistoricalsnapshotdates(historicalsnapshot) sets a list of historical snapshot dates. setid(id) sets the unique report id. setname(name) sets the report name. setreportbooleanfilter(reportbooleanfilter) sets logic to parse custom field filters. setreportfilters(reportfilters) sets a list of each custom filter in the report along with the field name, filter operator, and filter value. setreportformat(format) sets the format of the report. setreporttype(reporttype) sets the unique api name and display name for the report type. setscope(scopename) sets the api name for the scope defined for the report. scope values depend on the report type. setshowgrandtotal(showgrandtotal) specifies whether the report shows the grand total. setshowsubtotals(showsubtotals) specifies whether the report shows subtotals, such as column or row totals. setsortby(column) sets the list of columns on which the report is sorted. currently, you can only sort on one column. setstandarddatefilter(datefilter) sets the standard date filter—which includes the start date, end date, date range, and date field api name—for the report. setstandardfilters(filters) sets one or more standard filters on the report. settoprows(toprows) applies a row limit filter to a report. getaggregates() returns unique identifiers for summary or custom summary formula fields in the report. 2594apex reference guide reportmetadata class syntax public list<string> getaggregates() return value type: list<string> usage for example: • a!amount represents the average for the amount column. • s!amount represents the sum of the amount column. • m!amount represents the minimum value of the amount column. • x!amount represents the maximum value of the amount column. • s!<customfieldid> represents the sum of a custom field column. for custom fields and custom report types, the identifier is a combination of the summary type and the field id. getbuckets() returns a list of bucket fields in the report. signature public list<reports.bucketfield> getbuckets() return value type: list<reports.bucketfield> getcrossfilters() returns information about cross filters applied to a report. signature public reports.crossfilter getcrossfilters() return value type: list<reports.crossfilter> getcurrencycode() returns report currency, such as usd, eur, or gbp, for an organization that has multicurrency enabled. the value is null if the organ
ization does not have multicurrency enabled. syntax public string getcurrencycode() 2595apex reference guide reportmetadata class return value type: string getcustomsummaryformula() returns information about custom summary formulas in a report. signature public map<string,reports.reportcsf> getcustomsummaryformula() return value type: map<string,reports.reportcsf> getdescription() returns the description of the report. signature public string getdescription() return value type: string getdetailcolumns() returns unique api names (column names) for the fields that contain detailed data. for example, the method might return the following values: “opportunity_name, type, lead_source, amount.” syntax public list<string> getdetailcolumns() return value type: list<string> getdevelopername() returns the report api name. for example, the method might return the following value: “closed_sales_this_quarter.” syntax public string getdevelopername() 2596apex reference guide reportmetadata class return value type: string getdivision() returns the division specified in the report. note: reports that use standard filters (such as my cases or my team’s accounts) show records in all divisions. these reports can’t be further limited to a specific division. signature public string getdivision() return value type: string getgroupingsacross() returns column groupings in a report. syntax public list<reports.groupinginfo> getgroupingsacross() return value type: list<reports.groupinginfo> usage the identifier is: • an empty array for reports in summary format, because summary reports don't include column groupings • bucketfield_(id) for bucket fields • the id of a custom field when the custom field is used for a column grouping getgroupingsdown() returns row groupings for a report. syntax public list<reports.groupinginfo> getgroupingsdown() return value type: list<reports.groupinginfo> 2597apex reference guide reportmetadata class usage the identifier is: • bucketfield_(id) for bucket fields • the id of a custom field when the custom field is used for grouping gethasdetailrows() indicates whether the report has detail rows. signature public boolean gethasdetailrows() return value type: boolean gethasrecordcount() indicates whether the report shows the total number of records. signature public boolean gethasrecordcount() return value type: boolean gethistoricalsnapshotdates() returns a list of historical snapshot dates. syntax public list<string> gethistoricalsnapshotdates() return value type: list<string> getid() returns the unique report id. syntax public id getid() 2598apex reference guide reportmetadata class return value type: id getname() returns the report name. syntax public string getname() return value type: string getreportbooleanfilter() returns logic to parse custom field filters. the value is null when filter logic is not specified. syntax public string getreportbooleanfilter() return value type: string getreportfilters() returns a list of each custom filter in the report along with the field name, filter operator, and filter value. syntax public list<reports.reportfilter> getreportfilters() return value type: list<reports.reportfilter> getreportformat() returns the format of the report. syntax public reports.reportformat getreportformat() return value type: reports.reportformat 2599apex reference guide reportmetadata class usage this value can be: • tabular • summary • matrix getreporttype() returns the unique api name and display name for the report type. syntax public reports.reporttype getreporttype() return value type: reports.reporttype getscope() returns the api name for the scope defined for the report. scope values depend on the report type. signature public string getscope() return value type: string getshowgrandtotal() indicates whether the report shows the grand total. signature public boolean getshowgrandtotal() return value type: boolean getshowsubtotals() indicates whether
the report shows subtotals, such as column or row totals. signature public boolean getshowsubtotals() 2600apex reference guide reportmetadata class return value type: boolean getsortby() returns the list of columns on which the report is sorted. currently, you can sort on only one column. signature public list<reports.sortcolumn> getsortby() return value type: list<reports.sortcolumn> getstandarddatefilter() returns information about the standard date filter for the report, such as the start date, end date, date range, and date field api name. signature public reports.standarddatefilter getstandarddatefilter() return value type: reports.standarddatefilter getstandardfilters() returns a list of standard filters for the report. signature public list<reports.standardfilter> getstandardfilters() return value type: list<reports.standardfilter> gettoprows() returns information about a row limit filter, including the number of rows returned and the sort order. signature public reports.toprows gettoprows() return value type: reports.toprows 2601apex reference guide reportmetadata class setaggregates(aggregates) sets unique identifiers for standard or custom summary formula fields in the report. signature public void setaggregates(list<string> aggregates) parameters aggregates type: list<string> return value type: void setbuckets(buckets) creates bucket fields in a report. signature public void setbuckets(list<reports.bucketfield> buckets) parameters buckets type: list<reports.bucketfield> return value type: void setcrossfilters(crossfilters) applies cross filters to a report. signature public void setcrossfilters(list<reports.crossfilter> crossfilters) parameters crossfilter type: list<reports.crossfilter> return value type: void 2602apex reference guide reportmetadata class setcurrencycode(currencycode) sets the currency, such as usd, eur, or gbp, for report summary fields in an organization that has multicurrency enabled. signature public void setcurrencycode(string currencycode) parameters currencycode type: string return value type: void setcustomsummaryformula(customsummaryformula) adds a custom summary formula to a report. signature public void setcustomsummaryformula(map<string,reports.reportcsf> customsummaryformula) parameters customsummaryformula type: map<string, reports.reportcsf> return value type: void setdescription(description) sets the description of the report. signature public void setdescription(string description) parameters description type: string return value type: void 2603apex reference guide reportmetadata class setdetailcolumns(detailcolumns) sets the unique api names for the fields that contain detailed data—for example, opportunity_name, type, lead_source, or amount. signature public void setdetailcolumns(list<string> detailcolumns) parameters detailcolumns type: list<string> return value type: void setdevelopername(developername) sets the report api name—for example, closed_sales_this_quarter. signature public void setdevelopername(string developername) parameters developername type: string return value type: void setdivision(division) sets the division of the report. note: reports that use standard filters (such as my cases or my team’s accounts) show records in all divisions. these reports can’t be further limited to a specific division. signature public void setdivision(string division) parameters division type: string 2604apex reference guide reportmetadata class return value type: void setgroupingsacross(groupinginfo) sets column groupings in a report. signature public void setgroupingsacross(list<reports.groupinginfo> groupinginfo) parameters groupinginfo type: list<reports.groupinginfo> return value type: void setgroupingsdown(groupinginfo) sets row groupings for a report. signature public void setgroupingsdown(list<reports.groupinginfo>
groupinginfo) parameters groupinginfo type: list<reports.groupinginfo> return value type: void sethasdetailrows(hasdetailrows) specifies whether the report has detail rows. signature public void sethasdetailrows(boolean hasdetailrows) parameters hasdetailrows type: boolean 2605apex reference guide reportmetadata class return value type: void sethasrecordcount(hasrecordcount) specifies whether the report is configured to show the total number of records. signature public void sethasrecordcount(boolean hasrecordcount) parameters hasrecordcount type: boolean return value type: void sethistoricalsnapshotdates(historicalsnapshot) sets a list of historical snapshot dates. syntax public void sethistoricalsnapshotdates(list<string> historicalsnapshot) parameters historicalsnapshot type: list<string> return value type: void setid(id) sets the unique report id. signature public void setid(id id) parameters id type: id 2606apex reference guide reportmetadata class return value type: void setname(name) sets the report name. signature public void setname(string name) parameters name type: string return value type: void setreportbooleanfilter(reportbooleanfilter) sets logic to parse custom field filters. syntax public void setreportbooleanfilter(string reportbooleanfilter) parameters reportbooleanfilter type: string return value type: void setreportfilters(reportfilters) sets a list of each custom filter in the report along with the field name, filter operator, and filter value. syntax public void setreportfilters(list<reports.reportfilter> reportfilters) parameters reportfilters type: list<reports.reportfilter> 2607apex reference guide reportmetadata class return value type: void setreportformat(format) sets the format of the report. signature public void setreportformat(reports.reportformat format) parameters format type: reports.reportformat return value type: void setreporttype(reporttype) sets the unique api name and display name for the report type. signature public void setreporttype(reports.reporttype reporttype) parameters reporttype type: reports.reporttype return value type: void setscope(scopename) sets the api name for the scope defined for the report. scope values depend on the report type. signature public void setscope(string scopename) parameters scopename type: string 2608apex reference guide reportmetadata class return value type: void setshowgrandtotal(showgrandtotal) specifies whether the report shows the grand total. signature public void setshowgrandtotal(boolean showgrandtotal) parameters showgrandtotal type: boolean return value type: void setshowsubtotals(showsubtotals) specifies whether the report shows subtotals, such as column or row totals. signature public void setshowsubtotals(boolean showsubtotals) parameters showsubtotals type: boolean return value type: void setsortby(column) sets the list of columns on which the report is sorted. currently, you can only sort on one column. signature public void setsortby(list<reports.sortcolumn> column) parameters column type: list<reports.sortcolumn> 2609apex reference guide reportmetadata class return value type: void setstandarddatefilter(datefilter) sets the standard date filter—which includes the start date, end date, date range, and date field api name—for the report. signature public void setstandarddatefilter(reports.standarddatefilter datefilter) parameters datefilter type: reports.standarddatefilter return value type: void setstandardfilters(filters) sets one or more standard filters on the report. signature public void setstandardfilters(list<reports.standardfilter> filters) parameters filters type: list<reports.standardfilter> return value type: void settoprows(toprows) applies a row limit filter to a report. signature public
reports.toprows settoprows(reports.toprows toprows) parameters toprows type: reports.toprows 2610apex reference guide reportresults class return value type: void reportresults class contains the results of running a report. namespace reports reportresults methods the following are methods for reportresults. all are instance methods. in this section: getalldata() returns all report data. getfactmap() returns summary-level data or summary and detailed data for each row or column grouping. detailed data is available if the includedetails parameter is set to true when the report is run. getgroupingsacross() returns a collection of column groupings, keys, and values. getgroupingsdown() returns a collection of row groupings, keys, and values. gethasdetailrows() returns information about whether the fact map has detail rows. getreportextendedmetadata() returns additional, detailed metadata about the report, including data type and label information for groupings and summaries. getreportmetadata() returns metadata about the report, including grouping and summary information. getalldata() returns all report data. syntax public boolean getalldata() return value type: boolean 2611apex reference guide reportresults class usage when true, indicates that all report results are returned. when false, indicates that results are returned for the same number of rows as in a report run in salesforce. note: for reports that contain too many records, use filters to refine results. getfactmap() returns summary-level data or summary and detailed data for each row or column grouping. detailed data is available if the includedetails parameter is set to true when the report is run. syntax public map<string,reports.reportfact> getfactmap() return value type: map<string,reports.reportfact> getgroupingsacross() returns a collection of column groupings, keys, and values. syntax public reports.dimension getgroupingsacross() return value type: reports.dimension getgroupingsdown() returns a collection of row groupings, keys, and values. syntax public reports.dimension getgroupingsdown() return value type: reports.dimension gethasdetailrows() returns information about whether the fact map has detail rows. syntax public boolean gethasdetailrows() 2612apex reference guide reportscopeinfo class return value type: boolean usage • when true, indicates that the fact map returns values for summary-level and record-level data. • when false, indicates that the fact map returns summary values. getreportextendedmetadata() returns additional, detailed metadata about the report, including data type and label information for groupings and summaries. syntax public reports.reportextendedmetadata getreportextendedmetadata() return value type: reports.reportextendedmetadata getreportmetadata() returns metadata about the report, including grouping and summary information. syntax public reports.reportmetadata getreportmetadata() return value type: reports.reportmetadata reportscopeinfo class contains information about possible scope values that you can choose. scope values depend on the report type. for example, you can set the scope for opportunity reports to all opportunities, my team’s opportunities, or my opportunities. namespace reports in this section: reportscopeinfo methods reportscopeinfo methods the following are methods for reportscopeinfo. 2613apex reference guide reportscopevalue class in this section: getdefaultvalue() returns the default scope of the data to display in the report. getvalues() returns a list of scope values specified for the report. getdefaultvalue() returns the default scope of the data to display in the report. signature public string getdefaultvalue() return value type: string getvalues() returns a list of scope values specified for the report. signature public list<reports.reportscopevalue> getvalues() return value type: list<reports.reportscopevalue> reportscopevalue class contains information about a possible scope value. scope values depend on the report type. for example, you can set the scope for opportunity reports to all opportunities, my team’s opportunities, or my opportunities. namespace reports in this section: reportscopevalue methods reportscopevalue methods the following are methods for reportscopevalue. 2614apex reference guide reporttype class in this
section: getallowsdivision() returns a boolean value that indicates whether you can segment the report by this scope. getlabel() returns the display name of the scope of the report. getvalue() returns the scope value for the report. getallowsdivision() returns a boolean value that indicates whether you can segment the report by this scope. signature public boolean getallowsdivision() return value type: boolean getlabel() returns the display name of the scope of the report. signature public string getlabel() return value type: string getvalue() returns the scope value for the report. signature public string getvalue() return value type: string reporttype class contains the unique api name and display name for the report type. 2615apex reference guide reporttypecolumn class namespace reports reporttype methods the following are methods for reporttype. all are instance methods. in this section: getlabel() returns the localized display name of the report type. gettype() returns the unique identifier of the report type. getlabel() returns the localized display name of the report type. syntax public string getlabel() return value type: string gettype() returns the unique identifier of the report type. syntax public string gettype() return value type: string reporttypecolumn class contains detailed report type metadata about a field, including data type, display name, and filter values. namespace reports 2616apex reference guide reporttypecolumn class reporttypecolumn methods the following are methods for reporttypecolumn. all are instance methods. in this section: getdatatype() returns the data type of the field. getfiltervalues() if the field data type is picklist, multi-select picklist, boolean, or checkbox, returns all filter values for a field. for example, checkbox fields always have a value of true or false. for fields of other data types, the filter value is an empty array, because their values can’t be determined. getfilterable() if the field is of a type that can’t be filtered, returns false. for example, fields of the type encrypted text can’t be filtered. getlabel() returns the localized display name of the field. getname() returns the unique api name of the field. getdatatype() returns the data type of the field. syntax public reports.columndatatype getdatatype() return value type: reports.columndatatype getfiltervalues() if the field data type is picklist, multi-select picklist, boolean, or checkbox, returns all filter values for a field. for example, checkbox fields always have a value of true or false. for fields of other data types, the filter value is an empty array, because their values can’t be determined. syntax public list<reports.filtervalue> getfiltervalues() return value type: list<reports.filtervalue> getfilterable() if the field is of a type that can’t be filtered, returns false. for example, fields of the type encrypted text can’t be filtered. 2617apex reference guide reporttypecolumncategory class syntax public boolean getfilterable() return value type: boolean getlabel() returns the localized display name of the field. syntax public string getlabel() return value type: string getname() returns the unique api name of the field. syntax public string getname() return value type: string reporttypecolumncategory class information about categories of fields in a report type. namespace reports usage a report type column category is a set of fields that the report type grants access to. for example, an opportunity report has categories like opportunity information and primary contact. the opportunity information category has fields like amount, probability, and close date. get category information about a report by first getting the report metadata: // get the report id list <report> reportlist = [select id,developername from report where developername = 'q1_opportunities2']; 2618apex reference guide reporttypecolumncategory class string reportid = (string)reportlist.get(0).get('id'); // describe the report reports.reportdescriberesult describeresults = reports.reportmanager.describereport(reportid); // get report type metadata reports.reporttypemetadata reporttypemetadata = describeresults.getreporttypemetadata(); //
get report type column categories list<reports.reporttypecolumncategory> reporttypecolumncategories = reporttypemetadata.getcategories(); system.debug('reporttypecolumncategories: ' + reporttypecolumncategories); reporttypecolumncategory methods the following are methods for reporttypecolumncategory. all are instance methods. in this section: getcolumns() returns information for all fields in the report type. the information is organized by each section’s unique api name. getlabel() returns the localized display name of a section in the report type under which fields are organized. for example, in an accounts with contacts custom report type, account general is the display name of the section that contains fields on general account information. getcolumns() returns information for all fields in the report type. the information is organized by each section’s unique api name. syntax public map<string,reports.reporttypecolumn> getcolumns() return value type: map<string,reports.reporttypecolumn> getlabel() returns the localized display name of a section in the report type under which fields are organized. for example, in an accounts with contacts custom report type, account general is the display name of the section that contains fields on general account information. syntax public string getlabel() 2619apex reference guide reporttypemetadata class return value type: string reporttypemetadata class contains report type metadata, which gives you information about the fields that are available in each section of the report type, plus filter information for those fields. namespace reports in this section: reporttypemetadata methods reporttypemetadata methods the following are methods for reporttypemetadata. all are instance methods. in this section: getcategories() returns all fields in the report type. the fields are organized by section. getdivisioninfo() returns the default division and a list of all possible divisions that can be applied to this type of report. getscopeinfo() returns information about the scopes that can be applied to this type of report. getstandarddatefilterdurationgroups() returns information about the standard date filter groupings that can be applied to this type of report. standard date filter groupings include calendar year, calendar quarter, calendar month, calendar week, fiscal year, fiscal quarter, day and a custom value based on a user-defined date range. getstandardfilterinfos() returns information about standard date filters that can be applied to this type of report. getcategories() returns all fields in the report type. the fields are organized by section. syntax public list<reports.reporttypecolumncategory> getcategories() return value type: list<reports.reporttypecolumncategory> 2620apex reference guide reporttypemetadata class getdivisioninfo() returns the default division and a list of all possible divisions that can be applied to this type of report. signature public reports.reportdivisioninfo getdivisioninfo() return value type: reports.reportdivisioninfo getscopeinfo() returns information about the scopes that can be applied to this type of report. signature public reports.reportscopeinfo getscopeinfo() return value type: reports.reportscopeinfo getstandarddatefilterdurationgroups() returns information about the standard date filter groupings that can be applied to this type of report. standard date filter groupings include calendar year, calendar quarter, calendar month, calendar week, fiscal year, fiscal quarter, day and a custom value based on a user-defined date range. signature public list<reports.standarddatefilterdurationgroup> getstandarddatefilterdurationgroups() return value type: list<reports.standarddatefilterdurationgroup> getstandardfilterinfos() returns information about standard date filters that can be applied to this type of report. signature public map<string,reports.standardfilterinfo> getstandardfilterinfos() return value type: map<string,reports.standardfilterinfo> 2621apex reference guide sortcolumn class sortcolumn class contains information about the sort column used in the report. namespace reports in this section: sortcolumn methods sortcolumn methods the following are methods for sortcolumn. in this section: getsortcolumn() returns the column used to sort the records in the report. getsortorder() returns the the sort order— ascending or descending—for the sort column. setsortcolumn(sortcolumn) sets the column used to sort the records in the report. setsortorder(sortorder) s
ets the sort order— ascending or descending—for the sort column. getsortcolumn() returns the column used to sort the records in the report. signature public string getsortcolumn() return value type: string getsortorder() returns the the sort order— ascending or descending—for the sort column. signature public reports.columnsortorder getsortorder() 2622apex reference guide standarddatefilter class return value type: reports.columnsortorder setsortcolumn(sortcolumn) sets the column used to sort the records in the report. signature public void setsortcolumn(string sortcolumn) parameters sortcolumn type: string return value type: void setsortorder(sortorder) sets the sort order— ascending or descending—for the sort column. signature public void setsortorder(reports.columnsortorder sortorder) parameters sortorder type: reports.columnsortorder return value type: void standarddatefilter class contains information about standard date filter available in the report—for example, the api name, start date, and end date of the standard date filter duration as well as the api name of the date field on which the filter is placed. namespace reports in this section: standarddatefilter methods 2623apex reference guide standarddatefilter class standarddatefilter methods the following are methods for standarddatefilter. in this section: getcolumn() returns the api name of the standard date filter column. getdurationvalue() returns duration information about a standard date filter, such as start date, end date, and display name and api name of the date filter. getenddate() returns the end date of the standard date filter. getstartdate() returns the start date for the standard date filter. setcolumn(standarddatefiltercolumnname) sets the api name of the standard date filter column. setdurationvalue(durationname) sets the api name of the standard date filter. setenddate(enddate) sets the end date for the standard date filter. setstartdate(startdate) sets the start date for the standard date filter. getcolumn() returns the api name of the standard date filter column. signature public string getcolumn() return value type: string getdurationvalue() returns duration information about a standard date filter, such as start date, end date, and display name and api name of the date filter. signature public string getdurationvalue() return value type: string 2624apex reference guide standarddatefilter class getenddate() returns the end date of the standard date filter. signature public string getenddate() return value type: string getstartdate() returns the start date for the standard date filter. signature public string getstartdate() return value type: string setcolumn(standarddatefiltercolumnname) sets the api name of the standard date filter column. signature public void setcolumn(string standarddatefiltercolumnname) parameters standarddatefiltercolumnname type: string return value type: void setdurationvalue(durationname) sets the api name of the standard date filter. signature public void setdurationvalue(string durationname) 2625apex reference guide standarddatefilterduration class parameters durationname type: string return value type: void setenddate(enddate) sets the end date for the standard date filter. signature public void setenddate(string enddate) parameters enddate type: string return value type: void setstartdate(startdate) sets the start date for the standard date filter. signature public void setstartdate(string startdate) parameters startdate type: string return value type: void standarddatefilterduration class contains information about each standard date filter—also referred to as a relative date filter. it contains the api name and display label of the standard date filter duration as well as the start and end dates. namespace reports 2626apex reference guide standarddatefilterduration class in this section: standarddatefilterduration methods standarddatefilterduration methods the following are methods for standarddatefilterduration. in this section: getenddate() returns the end date of the date filter. getlabel() returns the display name of the date filter. possible values are relative date filters—like current fy and current fq—and custom date filters. getstartdate() returns the
start date of the date filter. getvalue() returns the api name of the date filter. possible values are relative date filters—like this_fiscal_year and next_fiscal_quarter—and custom date filters. getenddate() returns the end date of the date filter. signature public string getenddate() return value type: string getlabel() returns the display name of the date filter. possible values are relative date filters—like current fy and current fq—and custom date filters. signature public string getlabel() return value type: string getstartdate() returns the start date of the date filter. 2627apex reference guide standarddatefilterdurationgroup class signature public string getstartdate() return value type: string getvalue() returns the api name of the date filter. possible values are relative date filters—like this_fiscal_year and next_fiscal_quarter—and custom date filters. signature public string getvalue() return value type: string standarddatefilterdurationgroup class contains information about the standard date filter groupings, such as the grouping display label and all standard date filters that fall under the grouping. groupings include calendar year, calendar quarter, calendar month, calendar week, fiscal year, fiscal quarter, day, and custom values based on user-defined date ranges. namespace reports in this section: standarddatefilterdurationgroup methods standarddatefilterdurationgroup methods the following are methods for standarddatefilterdurationgroup. in this section: getlabel() returns the display label for the standard date filter grouping. getstandarddatefilterdurations() returns the standard date filter groupings. getlabel() returns the display label for the standard date filter grouping. 2628apex reference guide standardfilter class signature public string getlabel() return value type: string getstandarddatefilterdurations() returns the standard date filter groupings. signature public list<reports.standarddatefilterduration> getstandarddatefilterdurations() return value type: list<reports.standarddatefilterduration> for example, a standard filter date grouping might look like this: reports.standarddatefilterduration[enddate=2015-12-31, label=current fy, startdate=2015-01-01, value=this_fiscal_year], reports.standarddatefilterduration[enddate=2014-12-31, label=previous fy, startdate=2014-01-01, value=last_fiscal_year], reports.standarddatefilterduration[enddate=2014-12-31, label=previous 2 fy, startdate=2013-01-01, value=last_n_fiscal_years:2] standardfilter class contains information about the standard filter defined in the report, such as the filter field api name and filter value. namespace reports usage use to get or set standard filters on a report. standard filters vary by report type. for example, standard filters for reports on the opportunity object are show, opportunity status, and probability. in this section: standardfilter methods standardfilter methods the following are methods for standardfilter. 2629apex reference guide standardfilter class in this section: getname() return the api name of the standard filter. getvalue() returns the standard filter value. setname(name) sets the api name of the standard filter. setvalue(value) sets the standard filter value. getname() return the api name of the standard filter. signature public string getname() return value type: string getvalue() returns the standard filter value. signature public string getvalue() return value type: string setname(name) sets the api name of the standard filter. signature public void setname(string name) parameters name type: string 2630apex reference guide standardfilterinfo class return value type: void setvalue(value) sets the standard filter value. signature public void setvalue(string value) parameters value type: string return value type: void standardfilterinfo class is an abstract base class for an object that provides standard filter information. namespace reports in this section: standardfilterinfo methods standardfilterinfo methods the following are methods for standardfilterinfo. in this section: getlabel() returns the
display label of the standard filter. gettype() returns the type of standard filter. getlabel() returns the display label of the standard filter. 2631apex reference guide standardfilterinfopicklist class signature public string getlabel() return value type: string gettype() returns the type of standard filter. signature public reports.standardfiltertype gettype() return value type: reports.standardfiltertype standardfilterinfopicklist class contains information about the standard filter picklist, such as the display name and type of the filter field, the default picklist value, and a list of all possible picklist values. namespace reports in this section: standardfilterinfopicklist methods standardfilterinfopicklist methods the following are methods for standardfilterinfopicklist. in this section: getdefaultvalue() returns the default value for the standard filter picklist. getfiltervalues() returns a list of standard filter picklist values. getlabel() returns the display name of the standard filter picklist. gettype() returns the type of the standard filter picklist. 2632
apex reference guide standardfilterinfopicklist class getdefaultvalue() returns the default value for the standard filter picklist. signature public string getdefaultvalue() return value type: string getfiltervalues() returns a list of standard filter picklist values. signature public list<reports.filtervalue> getfiltervalues() return value type: list<reports.filtervalue> getlabel() returns the display name of the standard filter picklist. signature public string getlabel() return value type: string gettype() returns the type of the standard filter picklist. signature public reports.standardfiltertype gettype() return value type: reports.standardfiltertype 2633apex reference guide standardfiltertype enum standardfiltertype enum the standardfiltertype enum describes the type of standard filters in a report. the gettype() method returns a reports.standardfiltertype enum value. namespace reports enum values the following are the values of the reports.standardfiltertype enum. value description picklist values for the standard filter type. string string values. summaryvalue class contains summary data for a cell of the report. namespace reports summaryvalue methods the following are methods for summaryvalue. all are instance methods. in this section: getlabel() returns the formatted summary data for a specified cell. getvalue() returns the numeric value of the summary data for a specified cell. getlabel() returns the formatted summary data for a specified cell. syntax public string getlabel() return value type: string 2634apex reference guide thresholdinformation class getvalue() returns the numeric value of the summary data for a specified cell. syntax public object getvalue() return value type: object thresholdinformation class contains a list of evaluated conditions for a report notification. namespace reports in this section: thresholdinformation constructors thresholdinformation methods thresholdinformation constructors the following are constructors for thresholdinformation. in this section: thresholdinformation(evaluatedconditions) creates a new instance of the reports.evaluatedcondition class. thresholdinformation(evaluatedconditions) creates a new instance of the reports.evaluatedcondition class. signature public thresholdinformation(list<reports.evaluatedcondition> evaluatedconditions) parameters evaluatedconditions type: list<reports.evaluatedcondition> a list of reports.evaluatedcondition objects. 2635apex reference guide toprows class thresholdinformation methods the following are methods for thresholdinformation. in this section: getevaluatedconditions() returns a list of evaluated conditions for a report notification. getevaluatedconditions() returns a list of evaluated conditions for a report notification. signature public list<reports.evaluatedcondition> getevaluatedconditions() return value type: list<reports.evaluatedcondition> toprows class contains methods and constructors for working with information about a row limit filter. namespace reports in this section: toprows constructors toprows methods toprows constructors the following are constructors for toprows. in this section: toprows(rowlimit, direction) creates an instance of the reports.toprows class using the specified parameters. toprows() creates an instance of the reports.toprows class. you can then set values by using the class’s set methods. toprows(rowlimit, direction) creates an instance of the reports.toprows class using the specified parameters. 2636apex reference guide toprows class signature public toprows(integer rowlimit, reports.columnsortorder direction) parameters rowlimit type: integer the number of rows returned in the report. direction type: reports.columnsortorder the sort order of the report rows. toprows() creates an instance of the reports.toprows class. you can then set values by using the class’s set methods. signature public toprows() toprows methods the following are methods for toprows. in this section: getdirection() returns the sort order of the report rows. getrowlimit() returns the maximum number of rows shown in the report. setdirection(value) sets the sort order of the report’s rows. setdirection
(direction) sets the sort order of the report’s rows. setrowlimit(rowlimit) sets the maximum number of rows included in the report. tostring() returns a string. getdirection() returns the sort order of the report rows. signature public reports.columnsortorder getdirection() 2637apex reference guide toprows class return value type: reports.columnsortorder getrowlimit() returns the maximum number of rows shown in the report. signature public integer getrowlimit() return value type: integer setdirection(value) sets the sort order of the report’s rows. signature public void setdirection(string value) parameters value type: string for possible values, see reports.columnsortorder. return value type: void setdirection(direction) sets the sort order of the report’s rows. signature public void setdirection(reports.columnsortorder direction) parameters direction type: reports.columnsortorder return value type: void 2638apex reference guide reports exceptions setrowlimit(rowlimit) sets the maximum number of rows included in the report. signature public void setrowlimit(integer rowlimit) parameters rowlimit type: integer return value type: void tostring() returns a string. signature public string tostring() return value type: string reports exceptions the reports namespace contains exception classes. all exception classes support built-in methods for returning the error message and exception type. see exception class and built-in exceptions on page 3021. the reports namespace contains these exceptions: exception description methods reports.featurenotsupportedexception invalid report format reports.instanceaccessexception unable to access report instance reports.invalidfilterexception filter validation error list<string> getfiltererrors() returns a list of filter errors reports.invalidreportmetadataexception missing metadata for list<string> getreportmetadataerrors() filters returns a list of metadata errors reports.invalidsnapshotdateexception invalid historical report list<string> getsnapshotdateerrors() returns format a list of snapshot date errors 2639apex reference guide richmessaging namespace exception description methods reports.metadataexception no selected report columns reports.reportrunexception error running report reports.unsupportedoperationexception missing permissions for running reports richmessaging namespace provides objects and methods for handling rich messaging content. the following are the classes in the richmessaging namespace. in this section: authrequesthandler interface use this interface to handle authorization request responses. authrequestresponse class this class contains authorization request response data. authrequestresult class this class contains the result from handling the authorization request response. authrequestresultstatus enum this enum describes the authentication result status. messagedefinitioninputparameter class represents a messaging component parameter value. this class is used to provide parameter payloads that can be translated to structured content payloads in rich content messages. timeslotoption class represents a complex time slot option type. this class is used to provide time option payloads that can be translated to structured content payloads in rich content messages. authrequesthandler interface use this interface to handle authorization request responses. namespace richmessaging on page 2640 usage when using this interface, the following limits are overridden. see execution governors and limits in the apex developer guide. 2640apex reference guide authrequesthandler interface table 1: overridden limits limit name overridden value total number of soql queries issued 2 total number of records retrieved by a single sosl query 2 total number of dml statements issued 1 total number of records processed as a result of dml statements 1 total number of callouts (http requests or web services calls) in a 2 transaction in this section: authrequesthandler methods authrequesthandler example implementation authrequesthandler methods the following are methods for authrequesthandler. in this section: handleauthrequest(var1) handles authorization request response. handleauthrequest(var1) handles authorization request response. signature public richmessaging.authrequestresult handleauthrequest(richmessaging.authrequestresponse var1) parameters var1 type: richmessaging.authrequestresponse on page 2643 the authorization response. return value type: richmessaging.authrequestresult on page 2645 2641apex reference guide authrequesthandler interface authrequesthandler example implementation
this is an example implementation of the richmessaging.authrequesthandler interface. global class sampleauthrequesthandler implements richmessaging.authrequesthandler { global richmessaging.authrequestresult handleauthrequest(richmessaging.authrequestresponse authreqresponse) { // get contact email from messaging session string sessionid = authreqresponse.getcontextrecordid(); string contactemail = [select messagingsession.endusercontact.email from messagingsession where id = :sessionid].endusercontact.email; richmessaging.authrequestresultstatus authrequeststatus = richmessaging.authrequestresultstatus.declined; datetime dt = datetime.now(); // get user info if there's a valid contact email if (!string.isblank(contactemail)) { string userinfourl = 'https://api.my_auth_domain.com/v1/'; httprequest req = new httprequest(); req.setendpoint(userinfourl); req.setheader('content-type','application/json'); req.setmethod('get'); req.setheader('authorization', 'bearer '+authreqresponse.getaccesstoken()); http http = new http(); httpresponse res = http.send(req); string responsebody = res.getbody(); userwrapper userinfo = (userwrapper)system.json.deserialize(responsebody, userwrapper.class); if (userinfo.email == contactemail) { authrequeststatus = richmessaging.authrequestresultstatus.authenticated; dt = dt.addhours(6); } } return new richmessaging.authrequestresult( null, authrequeststatus, dt); } public class userwrapper{ public string href; public string display_name; public string type; public string country; public string product; public string email; 2642apex reference guide authrequestresponse class } } authrequestresponse class this class contains authorization request response data. namespace richmessaging in this section: authrequestresponse constructors authrequestresponse methods authrequestresponse constructors the following are constructors for authrequestresponse. in this section: authrequestresponse(accesstoken, contextrecordid, authprovidername) creates a new instance of the richmessaging.authrequestresponse class. authrequestresponse(accesstoken, contextrecordid, authprovidername) creates a new instance of the richmessaging.authrequestresponse class. signature public authrequestresponse(string accesstoken, string contextrecordid, string authprovidername) parameters accesstoken type: string the authorization access token. contextrecordid type: string the context record id. authprovidername type: string the provider name. 2643apex reference guide authrequestresponse class authrequestresponse methods the following are methods for authrequestresponse. in this section: getaccesstoken() gets the authorization access token. getauthprovidername() get the authorization provider name. getcontextrecordid() gets the context record id. getaccesstoken() gets the authorization access token. signature public string getaccesstoken() return value type: string the access token. getauthprovidername() get the authorization provider name. signature public string getauthprovidername() return value type: string the authorization provider name. getcontextrecordid() gets the context record id. signature public string getcontextrecordid() 2644apex reference guide authrequestresult class return value type: string the context record id. authrequestresult class this class contains the result from handling the authorization request response. namespace richmessaging in this section: authrequestresult constructors authrequestresult properties authrequestresult constructors the following are constructors for authrequestresult. in this section: authrequestresult(redirectpagereference, resultstatus, expirationdatetime) creates a new instance of the richmessaging.authrequestresult class. authrequestresult(redirectpagereference, resultstatus, expirationdatetime) creates a new instance of the richmessaging.authrequestresult class. signature public authrequestresult(system.pagereference redirectpagereference, richmessaging.authrequestresultstatus resultstatus, datetime expirationdatetime) parameters redirectpagereference type: system.pagereference on page 3214
the reference to the redirect page. resultstatus type: richmessaging.authrequestresultstatus on page 2647 the result status value. expirationdatetime type: datetime the expiration time. 2645apex reference guide authrequestresult class authrequestresult properties the following are properties for authrequestresult. in this section: expirationdatetime the expiration date and time. redirectpagereference the reference to the redirect page. resultstatus the result status value. expirationdatetime the expiration date and time. signature public datetime expirationdatetime {get; set;} property value type: datetime redirectpagereference the reference to the redirect page. signature public system.pagereference redirectpagereference {get; set;} property value type: system.pagereference on page 3214 resultstatus the result status value. signature public richmessaging.authrequestresultstatus resultstatus {get; set;} property value type: richmessaging.authrequestresultstatus on page 2647 2646apex reference guide authrequestresultstatus enum authrequestresultstatus enum this enum describes the authentication result status. enum values the following are the values of the richmessaging.authrequestresultstatus enum. value description authenticated authenticated result. declined declined result. messagedefinitioninputparameter class represents a messaging component parameter value. this class is used to provide parameter payloads that can be translated to structured content payloads in rich content messages. namespace richmessaging in this section: messagedefinitioninputparameter properties messagedefinitioninputparameter properties the following are properties for messagedefinitioninputparameter. in this section: booleanvalue a boolean input parameter. booleanvalues a list of boolean parameters. datetimevalue a datetime input parameter. datetimevalues a list of datetime input parameters. datevalue a date input parameter. datevalues a list of date input parameters. 2647apex reference guide messagedefinitioninputparameter class name a name input parameter. numbervalue a number input parameter. numbervalues a list of number input parameters. recordidvalue a record id input parameter. recordidvalues a list of record id input parameters. textvalue a text input parameter. textvalues a list of text input parameters. booleanvalue a boolean input parameter. signature public boolean booleanvalue {get; set;} property value type: boolean booleanvalues a list of boolean parameters. signature public list<boolean> booleanvalues {get; set;} property value type: list on page 3123<boolean> datetimevalue a datetime input parameter. signature public datetime datetimevalue {get; set;} 2648apex reference guide messagedefinitioninputparameter class property value type: datetime datetimevalues a list of datetime input parameters. signature public list<datetime> datetimevalues {get; set;} property value type: list on page 3123<datetime> datevalue a date input parameter. signature public date datevalue {get; set;} property value type: date datevalues a list of date input parameters. signature public list<date> datevalues {get; set;} property value type: list on page 3123<date> name a name input parameter. signature public string name {get; set;} property value type: string 2649apex reference guide messagedefinitioninputparameter class numbervalue a number input parameter. signature public double numbervalue {get; set;} property value type: double numbervalues a list of number input parameters. signature public list<double> numbervalues {get; set;} property value type: list on page 3123<double> recordidvalue a record id input parameter. signature public string recordidvalue {get; set;} property value type: string recordidvalues a list of record id input parameters. signature public list<string> recordidvalues {get; set;} property value type: list on page 3123<string> textvalue a text input parameter. 2650apex reference guide timeslotoption class signature public string textvalue {get; set;} property value type: string textvalues a list of text input parameters. signature public list<string> textvalues {get; set
;} property value type: list on page 3123<string> timeslotoption class represents a complex time slot option type. this class is used to provide time option payloads that can be translated to structured content payloads in rich content messages. namespace richmessaging in this section: timeslotoption constructors timeslotoption properties timeslotoption constructors the following are constructors for timeslotoption. in this section: timeslotoption(starttime, endtime) creates a timeslotoption object with a start and end time. timeslotoption(starttime, duration) creates a timeslotoption object with a start time and a duration. timeslotoption() creates a timeslotoption object. 2651apex reference guide timeslotoption class timeslotoption(starttime, endtime) creates a timeslotoption object with a start and end time. signature public timeslotoption(datetime starttime, datetime endtime) parameters starttime type: datetime start time. endtime type: datetime end time. timeslotoption(starttime, duration) creates a timeslotoption object with a start time and a duration. signature public timeslotoption(datetime starttime, integer duration) parameters starttime type: datetime start time. duration type: integer duration in seconds. timeslotoption() creates a timeslotoption object. signature public timeslotoption() timeslotoption properties the following are properties for timeslotoption. 2652apex reference guide schema namespace in this section: duration the duration in seconds. starttime the start time. duration the duration in seconds. signature public integer duration {get; set;} property value type: integer starttime the start time. signature public datetime starttime {get; set;} property value type: datetime schema namespace the schema namespace provides classes and methods for schema metadata information. the following are the classes in the schema namespace. in this section: childrelationship class contains methods for accessing the child relationship as well as the child sobject for a parent sobject. datacategory class represents the categories within a category group. datacategorygroupsobjecttypepair class specifies a category group and an associated object. describecolorresult class contains color metadata information for a tab. 2653apex reference guide childrelationship class describedatacategorygroupresult class contains the list of the category groups associated with knowledgearticleversion and question. describedatacategorygroupstructureresult class contains the category groups and categories associated with knowledgearticleversion and question. describefieldresult class contains methods for describing sobject fields. describeiconresult class contains icon metadata information for a tab. describesobjectresult class contains methods for describing sobjects. none of the methods take an argument. describetabresult class contains tab metadata information for a tab in a standard or custom app available in the salesforce user interface. describetabsetresult class contains metadata information about a salesforce classic standard or custom app available in the salesforce user interface. displaytype enum a schema.displaytype enum value is returned by the field describe result's gettype method. fielddescribeoptions enum a schema.fielddescribeoptions enum value is a parameter in the sobjecttype.getdescribe method. fieldset class contains methods for discovering and retrieving the details of field sets created on sobjects. fieldsetmember class contains methods for accessing the metadata for field set member fields. picklistentry class represents a picklist entry. recordtypeinfo class contains methods for accessing record type information for an sobject with associated record types. soaptype enum a schema.soaptype enum value is returned by the field describe result getsoaptype method. sobjectdescribeoptions enum a schema.sobjectdescribeoptions enum value is a parameter in the sobjecttype.getdescribe method. sobjectfield class a schema.sobjectfield object is returned from the field describe result using the getcontroller and getsobjectfield methods. sobjecttype class a schema.sobjecttype object is returned from the field describe result using the getreferenceto method, or from the sobject describe result using the getsobjecttype method. childrelationship class contains methods for accessing the child relationship
as well as the child sobject for a parent sobject. 2654apex reference guide childrelationship class namespace schema example a childrelationship object is returned from the sobject describe result using the getchildrelationship method. for example: schema.describesobjectresult r = account.sobjecttype.getdescribe(); list<schema.childrelationship> c = r.getchildrelationships(); childrelationship methods the following are methods for childrelationship. all are instance methods. in this section: getchildsobject() returns the token of the child sobject on which there is a foreign key back to the parent sobject. getfield() returns the token of the field that has a foreign key back to the parent sobject. getrelationshipname() returns the name of the relationship. iscascadedelete() returns true if the child object is deleted when the parent object is deleted, false otherwise. isdeprecatedandhidden() reserved for future use. isrestricteddelete() returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise. getchildsobject() returns the token of the child sobject on which there is a foreign key back to the parent sobject. signature public schema.sobjecttype getchildsobject() return value type: schema.sobjecttype getfield() returns the token of the field that has a foreign key back to the parent sobject. 2655apex reference guide childrelationship class signature public schema.sobjectfield getfield() return value type: schema.sobjectfield getrelationshipname() returns the name of the relationship. signature public string getrelationshipname() return value type: string iscascadedelete() returns true if the child object is deleted when the parent object is deleted, false otherwise. signature public boolean iscascadedelete() return value type: boolean isdeprecatedandhidden() reserved for future use. signature public boolean isdeprecatedandhidden() return value type: boolean isrestricteddelete() returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise. signature public boolean isrestricteddelete() 2656apex reference guide datacategory class return value type: boolean datacategory class represents the categories within a category group. namespace schema usage the schema.datacategory object is returned by the gettopcategories method. datacategory methods the following are methods for datacategory. all are instance methods. in this section: getchildcategories() returns a recursive object that contains the visible sub categories in the data category. getlabel() returns the label for the data category used in the salesforce user interface. getname() returns the unique name used by the api to access to the data category. getchildcategories() returns a recursive object that contains the visible sub categories in the data category. signature public schema.datacategory getchildcategories() return value type: list<schema.datacategory> getlabel() returns the label for the data category used in the salesforce user interface. signature public string getlabel() 2657apex reference guide datacategorygroupsobjecttypepair class return value type: string getname() returns the unique name used by the api to access to the data category. signature public string getname() return value type: string datacategorygroupsobjecttypepair class specifies a category group and an associated object. namespace schema usage schema.datacategorygroupsobjecttypepair is used by the describedatacategory groupstructures method to return the categories available to this object. in this section: datacategorygroupsobjecttypepair constructors datacategorygroupsobjecttypepair methods datacategorygroupsobjecttypepair constructors the following are constructors for datacategorygroupsobjecttypepair. in this section: datacategorygroupsobjecttypepair() creates a new instance of the schema.datacategorygroupsobjecttypepair class. datacategorygroupsobjecttypepair() creates a new instance of the schema.datacategorygroupsobjecttypepair class. signature public datacategorygroupsobjecttypepair() 2658apex reference guide datacategorygroupsobjecttypepair class datacategorygroupsobjecttypepair methods
the following are methods for datacategorygroupsobjecttypepair. all are instance methods. in this section: getdatacategorygroupname() returns the unique name used by the api to access the data category group. getsobject() returns the object name associated with the data category group. setdatacategorygroupname(name) specifies the unique name used by the api to access the data category group. setsobject(sobjectname) sets the sobject associated with the data category group. getdatacategorygroupname() returns the unique name used by the api to access the data category group. signature public string getdatacategorygroupname() return value type: string getsobject() returns the object name associated with the data category group. signature public string getsobject() return value type: string setdatacategorygroupname(name) specifies the unique name used by the api to access the data category group. signature public string setdatacategorygroupname(string name) 2659apex reference guide describecolorresult class parameters name type: string return value type: void setsobject(sobjectname) sets the sobject associated with the data category group. signature public void setsobject(string sobjectname) parameters sobjectname type: string the sobjectname is the object name associated with the data category group. valid values are: • knowledgearticleversion—for article types. • question—for questions from answers. return value type: void describecolorresult class contains color metadata information for a tab. namespace schema usage the getcolors method of the schema.describetabresult class returns a list of schema.describecolorresult objects that describe colors used in a tab. the methods in the schema.describecolorresult class can be called using their property counterparts. for each method starting with get, you can omit the get prefix and the ending parentheses () to call the property counterpart. for example, colorresultobj.color is equivalent to colorresultobj.getcolor(). 2660apex reference guide describecolorresult class example this sample shows how to get the color information in the sales app for the first tab’s first color. // get tab set describes for each app list<schema.describetabsetresult> tabsetdesc = schema.describetabs(); // iterate through each tab set describe for each app and display the info for(schema.describetabsetresult tsr : tabsetdesc) { // display tab info for the sales app if (tsr.getlabel() == 'sales') { // get color information for the first tab list<schema.describecolorresult> colordesc = tsr.gettabs()[0].getcolors(); // display the icon color, theme, and context of the first color returned system.debug('color: ' + colordesc[0].getcolor()); system.debug('theme: ' + colordesc[0].gettheme()); system.debug('context: ' + colordesc[0].getcontext()); } } // example debug statement output // debug|color: 1797c0 // debug|theme: theme4 // debug|context: primary describecolorresult methods the following are methods for describecolorresult. all are instance methods. in this section: getcolor() returns the web rgb color code, such as 00ff00. getcontext() returns the color context. the context determines whether the color is the main color for the tab or not. gettheme() returns the color theme. getcolor() returns the web rgb color code, such as 00ff00. signature public string getcolor() return value type: string 2661apex reference guide describedatacategorygroupresult class getcontext() returns the color context. the context determines whether the color is the main color for the tab or not. signature public string getcontext() return value type: string gettheme() returns the color theme. signature public string gettheme() return value type: string possible theme values include theme3, theme4, and custom. • theme3 is the salesforce theme introduced during spring ‘10. • theme4 is the salesforce theme introduced in winter ‘14 for the mobile touchscreen version of salesforce. • custom is the theme name associated with a custom icon. describedatacategorygroupresult class contains the list of the
category groups associated with knowledgearticleversion and question. namespace schema usage the describedatacategorygroups method returns a schema.describedatacategorygroupresult object containing the list of the category groups associated with the specified object. for additional information and code examples using describedatacategorygroups, see accessing all data categories associated with an sobject. example the following is an example of how to instantiate a data category group describe result object: list <string> objtype = new list<string>(); objtype.add('knowledgearticleversion'); 2662apex reference guide describedatacategorygroupresult class objtype.add('question'); list<schema.describedatacategorygroupresult> describecategoryresult = schema.describedatacategorygroups(objtype); describedatacategorygroupresult methods the following are methods for describedatacategorygroupresult. all are instance methods. in this section: getcategorycount() returns the number of visible data categories in the data category group. getdescription() returns the description of the data category group. getlabel() returns the label for the data category group used in the salesforce user interface. getname() returns the unique name used by the api to access to the data category group. getsobject() returns the object name associated with the data category group. getcategorycount() returns the number of visible data categories in the data category group. signature public integer getcategorycount() return value type: integer getdescription() returns the description of the data category group. signature public string getdescription() return value type: string 2663apex reference guide describedatacategorygroupstructureresult class getlabel() returns the label for the data category group used in the salesforce user interface. signature public string getlabel() return value type: string getname() returns the unique name used by the api to access to the data category group. signature public string getname() return value type: string getsobject() returns the object name associated with the data category group. signature public string getsobject() return value type: string describedatacategorygroupstructureresult class contains the category groups and categories associated with knowledgearticleversion and question. namespace schema usage the describedatacategorygroupstructures method returns a list of schema.describe datacategorygroupstructureresult objects containing the category groups and categories associated with the specified object. for additional information and code examples, see accessing all data categories associated with an sobject. 2664apex reference guide describedatacategorygroupstructureresult class example the following is an example of how to instantiate a data category group structure describe result object: list <datacategorygroupsobjecttypepair> pairs = new list<datacategorygroupsobjecttypepair>(); datacategorygroupsobjecttypepair pair1 = new datacategorygroupsobjecttypepair(); pair1.setsobject('knowledgearticleversion'); pair1.setdatacategorygroupname('regions'); datacategorygroupsobjecttypepair pair2 = new datacategorygroupsobjecttypepair(); pair2.setsobject('questions'); pair2.setdatacategorygroupname('regions'); pairs.add(pair1); pairs.add(pair2); list<schema.describedatacategorygroupstructureresult>results = schema.describedatacategorygroupstructures(pairs, true); describedatacategorygroupstructureresult methods the following are methods for describedatacategorygroupstructureresult. all are instance methods. in this section: getdescription() returns the description of the data category group. getlabel() returns the label for the data category group used in the salesforce user interface. getname() returns the unique name used by the api to access to the data category group. getsobject() returns the name of object associated with the data category group. gettopcategories() returns a schema.datacategory object, that contains the top categories visible depending on the user's data category group visibility settings. getdescription() returns the description of the data category group. signature public string getdescription() 2665apex reference guide describedatacategorygroupstructureresult class return value type: string getlabel() returns the label for the data category group used in the salesforce user interface. signature public string getlabel() return value type: string
getname() returns the unique name used by the api to access to the data category group. signature public string getname() return value type: string getsobject() returns the name of object associated with the data category group. signature public string getsobject() return value type: string gettopcategories() returns a schema.datacategory object, that contains the top categories visible depending on the user's data category group visibility settings. signature public list<schema.datacategory> gettopcategories() 2666apex reference guide describefieldresult class return value type: list<schema.datacategory> usage for more information on data category group visibility, see “data category visibility” in the salesforce online help. describefieldresult class contains methods for describing sobject fields. namespace schema usage instances of field describe results on the same describefieldresult aren’t guaranteed to be equal because the state and behavior of a describe object is determined by various factors including the api version used. to compare describe results, call the getsobjectfield() method on the field describe results and use the equality operator (==) to compare the sobjectfield values. example the following is an example of how to instantiate a field describe result object: schema.describefieldresult dfr = account.description.getdescribe(); describefieldresult methods the following are methods for describefieldresult. all are instance methods. in this section: getbytelength() for variable-length fields (including binary fields), returns the maximum size of the field, in bytes. getcalculatedformula() returns the formula specified for this field. getcontroller() returns the token of the controlling field. getdefaultvalue() returns the default value for this field. getdefaultvalueformula() returns the default value specified for this field if a formula is not used. getdigits() returns the maximum number of digits specified for the field. this method is only valid with integer fields. 2667apex reference guide describefieldresult class getinlinehelptext() returns the content of the field-level help. getlabel() returns the text label that is displayed next to the field in the salesforce user interface. this label can be localized. getlength() returns the maximum size of the field for the describefieldresult object in unicode characters (not bytes). getlocalname() returns the name of the field, similar to the getname method. however, if the field is part of the current namespace, the namespace portion of the name is omitted. getname() returns the field name used in apex. getpicklistvalues() returns a list of picklistentry objects. a runtime error is returned if the field is not a picklist. getprecision() for fields of type double, returns the maximum number of digits that can be stored, including all numbers to the left and to the right of the decimal point (but excluding the decimal point character). getreferencetargetfield() returns the name of the custom field on the parent standard or custom object whose values are matched against the values of the child external object's indirect lookup relationship field. the match is done to determine which records are related to each other. getreferenceto() returns a list of schema.sobjecttype objects for the parent objects of this field. if the isnamepointing method returns true, there is more than one entry in the list, otherwise there is only one. getrelationshipname() returns the name of the relationship. getrelationshiporder() returns 1 if the field is a child, 0 otherwise. getscale() for fields of type double, returns the number of digits to the right of the decimal point. any extra digits to the right of the decimal point are truncated. getsoaptype() returns one of the soaptype enum values, depending on the type of field. getsobjectfield() returns the token for this field. getsobjecttype() returns the salesforce object type from which this field originates. gettype() returns one of the displaytype enum values, depending on the type of field. isaccessible() returns true if the current user can see this field, false otherwise. isaipredictionfield() (beta) returns true if the current field is enabled to display einstein prediction data, false otherwise. 2668apex reference guide describefieldresult class isautonumber() returns true if the field is an auto number field, false otherwise. iscalculated
() returns true if the field is a custom formula field, false otherwise. note that custom formula fields are always read-only. iscascadedelete() returns true if the child object is deleted when the parent object is deleted, false otherwise. iscasesensitive() returns true if the field is case sensitive, false otherwise. iscreateable() returns true if the field can be created by the current user, false otherwise. iscustom() returns true if the field is a custom field, false if it is a standard field, such as name. isdefaultedoncreate() returns true if the field receives a default value when created, false otherwise. isdependentpicklist() returns true if the picklist is a dependent picklist, false otherwise. isdeprecatedandhidden() reserved for future use. isencrypted() returns true if the field is encrypted with shield platform encryption, false otherwise. isexternalid() returns true if the field is used as an external id, false otherwise. isfilterable() returns true if the field can be used as part of the filter criteria of a where statement, false otherwise. isformulatreatnullnumberaszero() returns true if null is treated as zero in a formula field, false otherwise. isgroupable() returns true if the field can be included in the group by clause of a soql query, false otherwise. this method is only available for apex classes and triggers saved using api version 18.0 and higher. ishtmlformatted() returns true if the field has been formatted for html and should be encoded for display in html, false otherwise. one example of a field that returns true for this method is a hyperlink custom formula field. another example is a custom formula field that has an image text function. isidlookup() returns true if the field can be used to specify a record in an upsert method, false otherwise. isnamefield() returns true if the field is a name field, false otherwise. isnamepointing() returns true if the field can have multiple types of objects as parents. for example, a task can have both the contact/lead id (whoid) field and the opportunity/account id (whatid) field return true for this method. because either of those objects can be the parent of a particular task record. this method returns false otherwise. 2669apex reference guide describefieldresult class isnillable() returns true if the field is nillable, false otherwise. a nillable field can have empty content. a non-nillable field must have a value for the object to be created or saved. ispermissionable() returns true if field permissions can be specified for the field, false otherwise. isrestricteddelete() returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise. isrestrictedpicklist() returns true if the field is a restricted picklist, false otherwise issearchprefilterable() returns true if a foreign key can be included in prefiltering when used in a sosl where clause, false otherwise. issortable() returns true if a query can sort on the field, false otherwise isunique() returns true if the value for the field must be unique, false otherwise isupdateable() returns true if the field can be edited by the current user, or child records in a master-detail relationship field on a custom object can be reparented to different parent records; false otherwise. iswriterequiresmasterread() returns true if writing to the detail object requires read sharing instead of read/write sharing of the parent. getbytelength() for variable-length fields (including binary fields), returns the maximum size of the field, in bytes. signature public integer getbytelength() return value type: integer getcalculatedformula() returns the formula specified for this field. signature public string getcalculatedformula() return value type: string 2670apex reference guide describefieldresult class getcontroller() returns the token of the controlling field. signature public schema.sobjectfield getcontroller() return value type: schema.sobjectfield getdefaultvalue() returns the default value for this field. signature public object getdefaultvalue() return value type: object getdefaultvalueformula() returns the default value specified for this field if a formula is not used. signature public string getdefaultvalueformula() return value type: string getdigits() returns the maximum number of digits specified for the field. this
method is only valid with integer fields. signature public integer getdigits() return value type: integer getinlinehelptext() returns the content of the field-level help. 2671apex reference guide describefieldresult class signature public string getinlinehelptext() return value type: string usage for more information, see “define field-level help” in the salesforce online help. getlabel() returns the text label that is displayed next to the field in the salesforce user interface. this label can be localized. signature public string getlabel() return value type: string usage note: for the type field on standard objects, getlabel returns a label different from the default label. it returns a label of the form object type, where object is the standard object label. for example, for the type field on account, getlabel returns account type instead of the default label type. if the type label is renamed, getlabel returns the new label. you can check or change the labels of all standard object fields from setup by entering rename tabs and labels in the quick find box, then selecting rename tabs and labels. getlength() returns the maximum size of the field for the describefieldresult object in unicode characters (not bytes). signature public integer getlength() return value type: integer getlocalname() returns the name of the field, similar to the getname method. however, if the field is part of the current namespace, the namespace portion of the name is omitted. 2672apex reference guide describefieldresult class signature public string getlocalname() return value type: string getname() returns the field name used in apex. signature public string getname() return value type: string getpicklistvalues() returns a list of picklistentry objects. a runtime error is returned if the field is not a picklist. signature public list<schema.picklistentry> getpicklistvalues() return value type: list<schema.picklistentry> getprecision() for fields of type double, returns the maximum number of digits that can be stored, including all numbers to the left and to the right of the decimal point (but excluding the decimal point character). signature public integer getprecision() return value type: integer getreferencetargetfield() returns the name of the custom field on the parent standard or custom object whose values are matched against the values of the child external object's indirect lookup relationship field. the match is done to determine which records are related to each other. 2673apex reference guide describefieldresult class signature public string getreferencetargetfield() return value type: string usage for information about indirect lookup relationships, see “indirect lookup relationship fields on external objects” in the salesforce help. getreferenceto() returns a list of schema.sobjecttype objects for the parent objects of this field. if the isnamepointing method returns true, there is more than one entry in the list, otherwise there is only one. signature public list <schema.sobjecttype> getreferenceto() return value type: list<schema.sobjecttype> versioned behavior changes in api version 51.0 and later, the getreferenceto() method returns referenced objects that aren’t accessible to the context user. if the context user has access to an object’s field that references another object, irrespective of the context user’s access to the cross-referenced object, the method returns references. in api version 50.0 and earlier, if the context user doesn’t have access to the cross-referenced object, the method returns an empty list. getrelationshipname() returns the name of the relationship. signature public string getrelationshipname() return value type: string usage for more information about relationships and relationship names, see understanding relationship names in the soql and sosl reference. getrelationshiporder() returns 1 if the field is a child, 0 otherwise. 2674apex reference guide describefieldresult class signature public integer getrelationshiporder() return value type: integer usage for more information about relationships and relationship names, see understanding relationship names in the soql and sosl reference. getscale() for fields of type double, returns the number of digits to the right of the decimal point. any extra digits to the right of the decimal point are truncated. signature public integer
getscale() return value type: integer usage this method returns a fault response if the number has too many digits to the left of the decimal point. getsoaptype() returns one of the soaptype enum values, depending on the type of field. signature public schema.soaptype getsoaptype() return value type: schema.soaptype getsobjectfield() returns the token for this field. signature public schema.sobjectfield getsobjectfield() return value type: schema.sobjectfield 2675apex reference guide describefieldresult class getsobjecttype() returns the salesforce object type from which this field originates. signature public schema.sobjecttype getsobjecttype() return value type: schema.sobjecttype example schema.describefieldresult f = account.industry.getdescribe(); schema.sobjecttype sourcetype = f.getsobjecttype(); assert.areequal(account.sobjecttype, sourcetype); gettype() returns one of the displaytype enum values, depending on the type of field. signature public schema.displaytype gettype() return value type: schema.displaytype isaccessible() returns true if the current user can see this field, false otherwise. signature public boolean isaccessible() return value type: boolean isaipredictionfield() (beta) returns true if the current field is enabled to display einstein prediction data, false otherwise. signature public boolean isaipredictionfield() 2676apex reference guide describefieldresult class return value type: boolean usage custom number fields can be set to display einstein prediction values. if you are participating in the einstein prediction builder beta program, use einstein prediction builder to set up the value to display. use this method to find out if a field is enabled to display an einstein prediction value. isautonumber() returns true if the field is an auto number field, false otherwise. signature public boolean isautonumber() return value type: boolean usage analogous to a sql identity type, auto number fields are read-only, non-createable text fields with a maximum length of 30 characters. auto number fields are used to provide a unique id that is independent of the internal object id (such as a purchase order number or invoice number). auto number fields are configured entirely in the salesforce user interface. iscalculated() returns true if the field is a custom formula field, false otherwise. note that custom formula fields are always read-only. signature public boolean iscalculated() return value type: boolean iscascadedelete() returns true if the child object is deleted when the parent object is deleted, false otherwise. signature public boolean iscascadedelete() return value type: boolean 2677apex reference guide describefieldresult class iscasesensitive() returns true if the field is case sensitive, false otherwise. signature public boolean iscasesensitive() return value type: boolean iscreateable() returns true if the field can be created by the current user, false otherwise. signature public boolean iscreateable() return value type: boolean iscustom() returns true if the field is a custom field, false if it is a standard field, such as name. signature public boolean iscustom() return value type: boolean isdefaultedoncreate() returns true if the field receives a default value when created, false otherwise. signature public boolean isdefaultedoncreate() return value type: boolean 2678apex reference guide describefieldresult class usage if this method returns true, salesforce implicitly assigns a value for this field when the object is created, even if a value for this field is not passed in on the create call. for example, in the opportunity object, the probability field has this attribute because its value is derived from the stage field. similarly, the owner has this attribute on most objects because its value is derived from the current user (if the owner field is not specified). isdependentpicklist() returns true if the picklist is a dependent picklist, false otherwise. signature public boolean isdependentpicklist() return value type: boolean isdeprecatedandhidden() reserved for future use. signature public boolean isdeprecatedandhidden() return value type: boolean isencrypted() returns true if the field is encrypted
with shield platform encryption, false otherwise. signature public boolean isencrypted() return value type: boolean isexternalid() returns true if the field is used as an external id, false otherwise. signature public boolean isexternalid() 2679apex reference guide describefieldresult class return value type: boolean isfilterable() returns true if the field can be used as part of the filter criteria of a where statement, false otherwise. signature public boolean isfilterable() return value type: boolean isformulatreatnullnumberaszero() returns true if null is treated as zero in a formula field, false otherwise. signature public boolean isformulatreatnullnumberaszero() return value type: boolean isgroupable() returns true if the field can be included in the group by clause of a soql query, false otherwise. this method is only available for apex classes and triggers saved using api version 18.0 and higher. signature public boolean isgroupable() return value type: boolean ishtmlformatted() returns true if the field has been formatted for html and should be encoded for display in html, false otherwise. one example of a field that returns true for this method is a hyperlink custom formula field. another example is a custom formula field that has an image text function. signature public boolean ishtmlformatted() 2680apex reference guide describefieldresult class return value type: boolean isidlookup() returns true if the field can be used to specify a record in an upsert method, false otherwise. signature public boolean isidlookup() return value type: boolean isnamefield() returns true if the field is a name field, false otherwise. signature public boolean isnamefield() return value type: boolean usage this method is used to identify the name field for standard objects (such as accountname for an account object) and custom objects. objects can only have one name field, except where the firstname and lastname fields are used instead (such as on the contact object). if a compound name is present, for example, the name field on a person account, isnamefield is set to true for that record. isnamepointing() returns true if the field can have multiple types of objects as parents. for example, a task can have both the contact/lead id (whoid) field and the opportunity/account id (whatid) field return true for this method. because either of those objects can be the parent of a particular task record. this method returns false otherwise. signature public boolean isnamepointing() return value type: boolean 2681apex reference guide describefieldresult class isnillable() returns true if the field is nillable, false otherwise. a nillable field can have empty content. a non-nillable field must have a value for the object to be created or saved. signature public boolean isnillable() return value type: boolean ispermissionable() returns true if field permissions can be specified for the field, false otherwise. signature public boolean ispermissionable() return value type: boolean isrestricteddelete() returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise. signature public boolean isrestricteddelete() return value type: boolean isrestrictedpicklist() returns true if the field is a restricted picklist, false otherwise signature public boolean isrestrictedpicklist() return value type: boolean 2682
apex reference guide describefieldresult class issearchprefilterable() returns true if a foreign key can be included in prefiltering when used in a sosl where clause, false otherwise. signature public boolean issearchprefilterable() return value type: boolean usage prefiltering means to filter by a specific field value before executing the full search query. prefiltering is supported only in where clauses with the equals (=) operator. issortable() returns true if a query can sort on the field, false otherwise signature public boolean issortable() return value type: boolean isunique() returns true if the value for the field must be unique, false otherwise signature public boolean isunique() return value type: boolean isupdateable() returns true if the field can be edited by the current user, or child records in a master-detail relationship field on a custom object can be reparented to different parent records; false otherwise. 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 boolean isupdateable() 2683apex reference guide describeiconresult class return value type: boolean iswriterequiresmasterread() returns true if writing to the detail object requires read sharing instead of read/write sharing of the parent. signature public boolean iswriterequiresmasterread() return value type: boolean describeiconresult class contains icon metadata information for a tab. namespace schema usage the geticons method of the schema.describetabresult class returns a list of schema.describeiconresult objects that describe colors used in a tab. the methods in the schema.describeiconresult class can be called using their property counterparts. for each method starting with get, you can omit the get prefix and the ending parentheses () to call the property counterpart. for example, iconresultobj.url is equivalent to iconresultobj.geturl(). example this sample shows how to get the icon information in the sales app for the first tab’s first icon. // get tab set describes for each app list<schema.describetabsetresult> tabsetdesc = schema.describetabs(); // iterate through each tab set for(schema.describetabsetresult tsr : tabsetdesc) { // get tab info for the sales app if (tsr.getlabel() == 'sales') { // get icon information for the first tab list<schema.describeiconresult> icondesc = tsr.gettabs()[0].geticons(); // display the icon height and width of the first icon system.debug('height: ' + icondesc[0].getheight()); system.debug('width: ' + icondesc[0].getwidth()); } } 2684apex reference guide describeiconresult class // example debug statement output // debug|height: 32 // debug|width: 32 describeiconresult methods the following are methods for describeiconresult. all are instance methods. in this section: getcontenttype() returns the tab icon’s content type, such as image/png. getheight() returns the tab icon’s height in pixels. gettheme() returns the tab’s icon theme. geturl() returns the tab’s icon fully qualified url. getwidth() returns the tab’s icon width in pixels. getcontenttype() returns the tab icon’s content type, such as image/png. signature public string getcontenttype() return value type: string getheight() returns the tab icon’s height in pixels. signature public integer getheight() return value type: integer usage note: if the icon content type is svg, the icon won’t have a size and its height is zero. 2685apex reference guide describesobjectresult class gettheme() returns the tab’s icon theme. signature public string gettheme() return value type: string possible theme values include theme3, theme4, and custom. • theme3 is the salesforce theme introduced during spring ‘10. • theme4 is the salesforce theme introduced in winter ‘14 for the mobile touchscreen version of salesforce. • custom is the theme name associated with a custom icon. geturl() returns the tab’s icon fully qualified url.
signature public string geturl() return value type: string getwidth() returns the tab’s icon width in pixels. signature public integer getwidth() return value type: integer usage note: if the icon content type is svg, the icon won’t have a size and its width is zero. describesobjectresult class contains methods for describing sobjects. none of the methods take an argument. 2686apex reference guide describesobjectresult class namespace schema usage instances of describe results on the same describesobjectresult aren’t guaranteed to be equal because the state and behavior of a describe object is determined by various factors including the api version used. to compare describe results, call the getsobjecttype() method on the sobject describe results and use the equality operator (==) to compare the sobjecttype values. describesobjectresult properties the following are properties for describesobjectresult. associateentitytype the type of associated object. for example, history or share. signature public string associateentitytype {get; set;} property value type: string associateparententity the parent object of an associated object. signature public string associateparententity {get; set;} property value type: string describesobjectresult methods the following are methods for describesobjectresult. all are instance methods. in this section: fields follow fields with a field member variable name or with the getmap method. fieldsets follow fieldsets with a field set name or with the getmap method. 2687apex reference guide describesobjectresult class getassociateentitytype() returns additional metadata for an associated object of a specified parent but only if it's a specific associated object type. used in combination with the getassociateparententity() method to get the parent object. for example, invoking the method on accounthistory returns the parent object as account and the type of associated object as history. getassociateparententity() returns additional metadata for an associated object but only if it's associated to a specific parent object. used in combination with the getassociateentitytype() method to get the type of associated object. for example, invoking the method on accounthistory returns the parent object as account and the type of associated object as history. getchildrelationships() returns a list of child relationships, which are the names of the sobjects that have a foreign key to the sobject being described. getdefaultimplementation() reserved for future use. gethassubtypes() reserved for future use. getimplementedby() reserved for future use. getimplementsinterfaces() reserved for future use. getisinterface() reserved for future use. getkeyprefix() returns the three-character prefix code for the object. record ids are prefixed with three-character codes that specify the type of the object (for example, accounts have a prefix of 001 and opportunities have a prefix of 006). getlabel() returns the object's label, which may or may not match the object name. getlabelplural() returns the object's plural label, which may or may not match the object name. getlocalname() returns the name of the object, similar to the getname method. however, if the object is part of the current namespace, the namespace portion of the name is omitted. getname() returns the name of the object. getrecordtypeinfos() returns a list of the record types supported by this object. the current user is not required to have access to a record type to see it in this list. getrecordtypeinfosbydevelopername() returns a map that matches developer names to their associated record type. the current user is not required to have access to a record type to see it in this map. getrecordtypeinfosbyid() returns a map that matches record ids to their associated record types. the current user is not required to have access to a record type to see it in this map. 2688apex reference guide describesobjectresult class getrecordtypeinfosbyname() returns a map that matches record labels to their associated record type. the current user is not required to have access to a record type to see it in this map. getsobjectdescribeoption() returns the effective describe option used by the system for the sobject. getsobjecttype() returns the schema.sobjecttype object for the sobject. you can use this to create a similar sobject.
isaccessible() returns true if the current user can see this object, false otherwise. iscreateable() returns true if the object can be created by the current user, false otherwise. iscustom() returns true if the object is a custom object, false if it is a standard object. iscustomsetting() returns true if the object is a custom setting, false otherwise. isdeletable() returns true if the object can be deleted by the current user, false otherwise. isdeprecatedandhidden() reserved for future use. isfeedenabled() returns true if chatter feeds are enabled for the object, false otherwise. this method is only available for apex classes and triggers saved using salesforceapi version 19.0 and later. ismergeable() returns true if the object can be merged with other objects of its type by the current user, false otherwise. true is returned for leads, contacts, and accounts. ismruenabled() returns true if most recently used (mru) list functionality is enabled for the object, false otherwise. isqueryable() returns true if the object can be queried by the current user, false otherwise issearchable() returns true if the object can be searched by the current user, false otherwise. isundeletable() returns true if the object can be undeleted by the current user, false otherwise. isupdateable() returns true if the object can be updated by the current user, false otherwise. fields follow fields with a field member variable name or with the getmap method. 2689apex reference guide describesobjectresult class signature public schema.sobjecttypefields fields() return value type: the return value is a special data type. see the example to learn how to use fields. usage note: when you describe sobjects and their fields from within an apex class, custom fields of new field types are returned regardless of the api version that the class is saved in. if a field type, such as the geolocation field type, is available only in a recent api version, components of a geolocation field are returned even if the class is saved in an earlier api version. example schema.describefieldresult dfr = schema.sobjecttype.account.fields.name; to get a custom field name, specify the custom field name. see also: apex developer guide: using field tokens apex developer guide: describing sobjects using schema method apex developer guide: understanding apex describe information fieldsets follow fieldsets with a field set name or with the getmap method. signature public schema.sobjecttypefields fieldsets() return value type: the return value is a special data type. see the example to learn how to use fieldsets. example schema.describesobjectresult d = account.sobjecttype.getdescribe(); map<string, schema.fieldset> fsmap = d.fieldsets.getmap(); see also: apex developer guide: using field tokens apex developer guide: describing sobjects using schema method apex developer guide: understanding apex describe information 2690apex reference guide describesobjectresult class getassociateentitytype() returns additional metadata for an associated object of a specified parent but only if it's a specific associated object type. used in combination with the getassociateparententity() method to get the parent object. for example, invoking the method on accounthistory returns the parent object as account and the type of associated object as history. signature public string associateentitytype {get; set;} return value type: string see also: describesobjectresult properties getassociateparententity() returns additional metadata for an associated object but only if it's associated to a specific parent object. used in combination with the getassociateentitytype() method to get the type of associated object. for example, invoking the method on accounthistory returns the parent object as account and the type of associated object as history. signature public string getassociateparententity() return value type: string see also: describesobjectresult properties getchildrelationships() returns a list of child relationships, which are the names of the sobjects that have a foreign key to the sobject being described. signature public schema.childrelationship getchildrelationships() return value type: list<schema.childrelationship> example for example, the account object includes contacts and opportunities
as child relationships. 2691apex reference guide describesobjectresult class getdefaultimplementation() reserved for future use. signature public string getdefaultimplementation() return value type: string gethassubtypes() reserved for future use. to check if person accounts are enabled for the current org, use this code snippet: schema.sobjecttype.account.fields.getmap().containskey( 'ispersonaccount' ); signature public boolean gethassubtypes() return value type: boolean getimplementedby() reserved for future use. signature public string getimplementedby() return value type: string getimplementsinterfaces() reserved for future use. signature public string getimplementsinterfaces() return value type: string 2692apex reference guide describesobjectresult class getisinterface() reserved for future use. signature public boolean getisinterface() return value type: boolean getkeyprefix() returns the three-character prefix code for the object. record ids are prefixed with three-character codes that specify the type of the object (for example, accounts have a prefix of 001 and opportunities have a prefix of 006). signature public string getkeyprefix() return value type: string usage the describesobjectresult object returns a value for objects that have a stable prefix. for object types that do not have a stable or predictable prefix, this field is blank. client applications that rely on these codes can use this way of determining object type to ensure forward compatibility. getlabel() returns the object's label, which may or may not match the object name. signature public string getlabel() return value type: string usage the object's label might not always match the object name. for example, an organization in the medical industry might change the label for account to patient. this label is then used in the salesforce user interface. see the salesforce online help for more information. getlabelplural() returns the object's plural label, which may or may not match the object name. 2693apex reference guide describesobjectresult class signature public string getlabelplural() return value type: string usage the object's plural label might not always match the object name. for example, an organization in the medical industry might change the plural label for account to patients. this label is then used in the salesforce user interface. see the salesforce online help for more information. getlocalname() returns the name of the object, similar to the getname method. however, if the object is part of the current namespace, the namespace portion of the name is omitted. signature public string getlocalname() return value type: string getname() returns the name of the object. signature public string getname() return value type: string getrecordtypeinfos() returns a list of the record types supported by this object. the current user is not required to have access to a record type to see it in this list. signature public list<schema.recordtypeinfo> getrecordtypeinfos() return value type: list<schema.recordtypeinfo> 2694apex reference guide describesobjectresult class getrecordtypeinfosbydevelopername() returns a map that matches developer names to their associated record type. the current user is not required to have access to a record type to see it in this map. signature public map<string, schema.recordtypeinfo> getrecordtypeinfosbydevelopername() return value type: map<string, schema.recordtypeinfo> getrecordtypeinfosbyid() returns a map that matches record ids to their associated record types. the current user is not required to have access to a record type to see it in this map. signature public schema.recordtypeinfo getrecordtypeinfosbyid() return value type: map<id, schema.recordtypeinfo> getrecordtypeinfosbyname() returns a map that matches record labels to their associated record type. the current user is not required to have access to a record type to see it in this map. signature public schema.recordtypeinfo getrecordtypeinfosbyname() return value type: map<string, schema.recordtypeinfo> getsobjectdescribeoption() returns the effective describe option used by the system for the sobject. signature
public schema.sobjectdescribeoptions getsobjectdescribeoption() return value type: schema.sobjectdescribeoptions valid values are: 2695apex reference guide describesobjectresult class • sobjectdescribeoptions.full: indicates eager-load all elements of the describe, including child relationships, up-front at the time of method invocation. • sobjectdescribeoptions.deferred: indicates lazy-load child relationships. this means that all child relationships will not be loaded at the time of first invocation of the method. getsobjecttype() returns the schema.sobjecttype object for the sobject. you can use this to create a similar sobject. signature public schema.sobjecttype getsobjecttype() return value type: schema.sobjecttype isaccessible() returns true if the current user can see this object, false otherwise. signature public boolean isaccessible() return value type: boolean versioned behavior changes in api version 54.0 and later, for custom settings and custom metadata type objects, describesobjectresult.isaccessible() returns false if the user doesn’t have permissions to access the queried objects. in api version 53.0 and earlier, the method returns true even if the user doesn't have the required permissions. iscreateable() returns true if the object can be created by the current user, false otherwise. signature public boolean iscreateable() return value type: boolean iscustom() returns true if the object is a custom object, false if it is a standard object. 2696apex reference guide describesobjectresult class signature public boolean iscustom() return value type: boolean iscustomsetting() returns true if the object is a custom setting, false otherwise. signature public boolean iscustomsetting() return value type: boolean isdeletable() returns true if the object can be deleted by the current user, false otherwise. signature public boolean isdeletable() return value type: boolean isdeprecatedandhidden() reserved for future use. signature public boolean isdeprecatedandhidden() return value type: boolean isfeedenabled() returns true if chatter feeds are enabled for the object, false otherwise. this method is only available for apex classes and triggers saved using salesforceapi version 19.0 and later. 2697apex reference guide describesobjectresult class signature public boolean isfeedenabled() return value type: boolean ismergeable() returns true if the object can be merged with other objects of its type by the current user, false otherwise. true is returned for leads, contacts, and accounts. signature public boolean ismergeable() return value type: boolean ismruenabled() returns true if most recently used (mru) list functionality is enabled for the object, false otherwise. signature public boolean ismruenabled() return value type: boolean isqueryable() returns true if the object can be queried by the current user, false otherwise signature public boolean isqueryable() return value type: boolean issearchable() returns true if the object can be searched by the current user, false otherwise. 2698apex reference guide describetabresult class signature public boolean issearchable() return value type: boolean isundeletable() returns true if the object can be undeleted by the current user, false otherwise. signature public boolean isundeletable() return value type: boolean isupdateable() returns true if the object can be updated by the current user, false otherwise. signature public boolean isupdateable() return value type: boolean describetabresult class contains tab metadata information for a tab in a standard or custom app available in the salesforce user interface. namespace schema usage the gettabs method of the schema.describetabsetresult returns a list of schema.describetabresult objects that describe the tabs of one app. the methods in the schema.describetabresult class can be called using their property counterparts. for each method starting with get, you can omit the get prefix and the ending parentheses () to call the property counterpart. for example, tabresultobj.label is equivalent to tabresultobj.getlabel(). similarly, for each method starting with is, omit the is prefix and the ending parentheses (). for example, tabresultobj.iscustom
is equivalent to tabresultobj.custom. 2699apex reference guide describetabresult class describetabresult methods the following are methods for describetabresult. all are instance methods. in this section: getcolors() returns a list of color metadata information for all colors associated with this tab. each color is associated with a theme and context. geticonurl() returns the url for the main 32 x 32-pixel icon for a tab. this icon corresponds to the current theme (theme3) and appears next to the heading at the top of most pages. geticons() returns a list of icon metadata information for all icons associated with this tab. each icon is associated with a theme and context. getlabel() returns the display label of this tab. getminiiconurl() returns the url for the 16 x 16-pixel icon that represents a tab. this icon corresponds to the current theme (theme3) and appears in related lists and other locations. getsobjectname() returns the name of the sobject that is primarily displayed on this tab (for tabs that display a particular sobject). geturl() returns a fully qualified url for viewing this tab. iscustom() returns true if this is a custom tab, or false if this is a standard tab. getcolors() returns a list of color metadata information for all colors associated with this tab. each color is associated with a theme and context. signature public list<schema.describecolorresult> getcolors() return value type: list<schema.describecolorresult> geticonurl() returns the url for the main 32 x 32-pixel icon for a tab. this icon corresponds to the current theme (theme3) and appears next to the heading at the top of most pages. signature public string geticonurl() 2700apex reference guide describetabresult class return value type: string geticons() returns a list of icon metadata information for all icons associated with this tab. each icon is associated with a theme and context. signature public list<schema.describeiconresult> geticons() return value type: list<schema.describeiconresult> getlabel() returns the display label of this tab. signature public string getlabel() return value type: string getminiiconurl() returns the url for the 16 x 16-pixel icon that represents a tab. this icon corresponds to the current theme (theme3) and appears in related lists and other locations. signature public string getminiiconurl() return value type: string getsobjectname() returns the name of the sobject that is primarily displayed on this tab (for tabs that display a particular sobject). signature public string getsobjectname() 2701apex reference guide describetabsetresult class return value type: string geturl() returns a fully qualified url for viewing this tab. signature public string geturl() return value type: string iscustom() returns true if this is a custom tab, or false if this is a standard tab. signature public boolean iscustom() return value type: boolean describetabsetresult class contains metadata information about a salesforce classic standard or custom app available in the salesforce user interface. namespace schema usage the schema.describetabs method returns a list of schema.describetabsetresult objects that describe salesforce classic standard and custom apps. the methods in the schema.describetabsetresult class can be called using their property counterparts. for each method starting with get, you can omit the get prefix and the ending parentheses () to call the property counterpart. for example, tabsetresultobj.label is equivalent to tabsetresultobj.getlabel(). similarly, for each method starting with is, omit the is prefix and the ending parentheses (). for example, tabsetresultobj.isselected is equivalent to tabsetresultobj.selected. 2702apex reference guide describetabsetresult class example this example shows how to call the schema.describetabs method to get describe information for all available salesforce classic apps. this example iterates through each describe result and gets more metadata information for the sales app. // app we're interested to get more info about string appname = 'sales'; // get tab set describes for each app list<schema.describetabsetresult> tabsetdesc = schema.describetabs(); // iterate through each tab set describe for each app and display the
info for(schema.describetabsetresult tsr : tabsetdesc) { // get more information for the sales app if (tsr.getlabel() == appname) { // find out if the app is selected if (tsr.isselected()) { system.debug('the ' + appname + ' app is selected. '); } // get the app's logo url and namespace string logo = tsr.getlogourl(); system.debug('logo url: ' + logo); string ns = tsr.getnamespace(); if (ns == '') { system.debug('the ' + appname + ' app has no namespace defined.'); } else { system.debug('namespace: ' + ns); } // get the number of tabs system.debug('the ' + appname + ' app has ' + tsr.gettabs().size() + ' tabs.'); } } // example debug statement output // debug|the sales app is selected. // debug|logo url: https://mydomainname.my.salesforce.com/img/seasonlogos/2014_winter_aloha.png // debug|the sales app has no namespace defined. // debug|the sales app has 14 tabs. describetabsetresult methods the following are methods for describetabsetresult. all are instance methods. in this section: getdescription() returns the display description for the standard or custom app. getlabel() returns the display label for the standard or custom app. 2703apex reference guide describetabsetresult class getlogourl() returns a fully qualified url to the logo image associated with the standard or custom app. getnamespace() returns the developer namespace prefix of a salesforce appexchange managed package. gettabs() returns metadata information about the standard or custom app’s displayed tabs. isselected() returns true if this standard or custom app is the user’s currently selected app. otherwise, returns false. getdescription() returns the display description for the standard or custom app. signature public string getdescription() return value type: string getlabel() returns the display label for the standard or custom app. signature public string getlabel() return value type: string usage the display label changes when tabs are renamed in the salesforce user interface. see the salesforce online help for more information. getlogourl() returns a fully qualified url to the logo image associated with the standard or custom app. signature public string getlogourl() return value type: string 2704apex reference guide displaytype enum getnamespace() returns the developer namespace prefix of a salesforce appexchange managed package. signature public string getnamespace() return value type: string usage this namespace prefix corresponds to the namespace prefix of the developer edition organization that was enabled to allow publishing a managed package. this method applies to a custom app containing a set of tabs and installed as part of a managed package. gettabs() returns metadata information about the standard or custom app’s displayed tabs. signature public list<schema.describetabresult> gettabs() return value type: list<schema.describetabresult> isselected() returns true if this standard or custom app is the user’s currently selected app. otherwise, returns false. signature public boolean isselected() return value type: boolean displaytype enum a schema.displaytype enum value is returned by the field describe result's gettype method. namespace schema 2705apex reference guide displaytype enum type field value what the field object contains address address values anytype any value of the following types: string, picklist, boolean, integer, double, percent, id, date, datetime, url, or email. base64 base64-encoded arbitrary binary data (of type base64binary) boolean boolean (true or false) values combobox comboboxes, which provide a set of enumerated values and allow the user to specify a value not in the list currency currency values datacategorygroupreference reference to a data category group or a category unique name date date values datetime datetime values double double values email email addresses encryptedstring encrypted string id primary key field for an object integer integer values location location values, including latitude and longitude. long long values multipicklist multi-
select picklists, which provide a set of enumerated values from which multiple values can be selected percent percent values phone phone numbers. values can include alphabetic characters. client applications are responsible for phone number formatting. picklist single-select picklists, which provide a set of enumerated values from which only one value can be selected reference cross-references to a different object, analogous to a foreign key field string string values textarea string values that are displayed as multiline text fields time time values url url values that are displayed as hyperlinks 2706apex reference guide fielddescribeoptions enum usage for more information, see field types in the object reference for salesforce. for more information about the methods shared by all enums, see enum methods. fielddescribeoptions enum a schema.fielddescribeoptions enum value is a parameter in the sobjecttype.getdescribe method. usage for more information about the method using this enum, see getdescribe(options). enum values the following are the values of the schema.fielddescribeoptions enum. value description default compute context-specific, describe field results. full_describe compute all aspects of describe field results. fieldset class contains methods for discovering and retrieving the details of field sets created on sobjects. namespace schema usage use the methods in the schema.fieldset class to discover the fields contained within a field set, and get details about the field set itself, such as the name, namespace, label, and so on. the following example shows how to get a collection of field set describe result objects for an sobject. the key of the returned map is the field set name, and the value is the corresponding field set describe result. map<string, schema.fieldset> fsmap = schema.sobjecttype.account.fieldsets.getmap(); field sets are also available from sobject describe results. the following lines of code are equivalent to the prior sample: schema.describesobjectresult d = account.sobjecttype.getdescribe(); map<string, schema.fieldset> fsmap = d.fieldsets.getmap(); 2707apex reference guide fieldset class to work with an individual field set, you can access it via the map of field sets on an sobject or, when you know the name of the field set in advance, using an explicit reference to the field set. the following two lines of code retrieve the same field set: schema.fieldset fs1 = schema.sobjecttype.account.fieldsets.getmap().get('field_set_name'); schema.fieldset fs2 = schema.sobjecttype.account.fieldsets.field_set_name; example: displaying a field set on a visualforce page this sample uses schema.fieldset and schema.fieldsetmember methods to dynamically get all the fields in the dimensions field set for the merchandise custom object. the list of fields is then used to construct a soql query that ensures those fields are available for display. the visualforce page uses the merchandisedetails class as its controller. public class merchandisedetails { public merchandise__c merch { get; set; } public merchandisedetails() { this.merch = getmerchandise(); } public list<schema.fieldsetmember> getfields() { return sobjecttype.merchandise__c.fieldsets.dimensions.getfields(); } private merchandise__c getmerchandise() { string query = 'select '; for(schema.fieldsetmember f : this.getfields()) { query += f.getfieldpath() + ', '; } query += 'id, name from merchandise__c limit 1'; return database.query(query); } } the visualforce page using the above controller is simple: <apex:page controller="merchandisedetails"> <apex:form > <apex:pageblock title="product details"> <apex:pageblocksection title="product"> <apex:inputfield value="{!merch.name}"/> </apex:pageblocksection> <apex:pageblocksection title="dimensions"> <apex:repeat value="{!fields}" var="f"> <apex:inputfield value="{!merch[f.fieldpath]}" required="{!or(f.required, f.
dbrequired)}"/> </apex:repeat> </apex:pageblocksection> </apex:pageblock> 2708apex reference guide fieldset class </apex:form> </apex:page> one thing to note about the above markup is the expression used to determine if a field on the form should be indicated as being a required field. a field in a field set can be required by either the field set definition, or the field’s own definition. the expression handles both cases. fieldset methods the following are methods for fieldset. all are instance methods. in this section: getdescription() returns the field set’s description. getfields() returns a list of schema.fieldsetmember objects for the fields making up the field set. getlabel() returns the translation of the text label that is displayed next to the field in the salesforce user interface. getname() returns the field set’s name. getnamespace() returns the field set’s namespace. getsobjecttype() returns the schema.sobjecttype of the sobject containing the field set definition. getdescription() returns the field set’s description. signature public string getdescription() return value type: string usage description is a required field for a field set, intended to describe the context and content of the field set. it’s often intended for administrators who might be configuring a field set defined in a managed package, rather than for end users. getfields() returns a list of schema.fieldsetmember objects for the fields making up the field set. 2709apex reference guide fieldset class signature public list<fieldsetmember> getfields() return value type: list<schema.fieldsetmember> getlabel() returns the translation of the text label that is displayed next to the field in the salesforce user interface. signature public string getlabel() return value type: string getname() returns the field set’s name. signature public string getname() return value type: string getnamespace() returns the field set’s namespace. signature public string getnamespace() return value type: string usage the returned namespace is an empty string if your organization hasn’t set a namespace, and the field set is defined in your organization. otherwise, it’s the namespace of your organization, or the namespace of the managed package containing the field set. 2710apex reference guide fieldsetmember class getsobjecttype() returns the schema.sobjecttype of the sobject containing the field set definition. signature public schema.sobjecttype getsobjecttype() return value type: schema.sobjecttype fieldsetmember class contains methods for accessing the metadata for field set member fields. namespace schema usage use the methods in the schema.fieldsetmember class to get details about fields contained within a field set, such as the field label, type, a dynamic soql-ready field path, and so on. the following example shows how to get a collection of field set member describe result objects for a specific field set on an sobject: list<schema.fieldsetmember> fields = schema.sobjecttype.account.fieldsets.getmap().get('field_set_name').getfields(); if you know the name of the field set in advance, you can access its fields more directly using an explicit reference to the field set: list<schema.fieldsetmember> fields = schema.sobjecttype.account.fieldsets.field_set_name.getfields(); see also: fieldset class fieldsetmember methods the following are methods for fieldsetmember. all are instance methods. in this section: getdbrequired() returns true if the field is required by the field’s definition in its sobject, otherwise, false. getfieldpath() returns a field path string in a format ready to be used in a dynamic soql query. getlabel() returns the text label that’s displayed next to the field in the salesforce user interface. 2711apex reference guide fieldsetmember class getrequired() returns true if the field is required by the field set, otherwise, false. gettype() returns the field’s apex data type. getsobjectfield() returns the token for this field. getdbrequired() returns true if
the field is required by the field’s definition in its sobject, otherwise, false. signature public boolean getdbrequired() return value type: boolean getfieldpath() returns a field path string in a format ready to be used in a dynamic soql query. signature public string getfieldpath() return value type: string example see displaying a field set on a visualforce page for an example of how to use this method. getlabel() returns the text label that’s displayed next to the field in the salesforce user interface. signature public string getlabel() return value type: string getrequired() returns true if the field is required by the field set, otherwise, false. 2712apex reference guide picklistentry class signature public boolean getrequired() return value type: boolean gettype() returns the field’s apex data type. signature public schema.displaytype gettype() return value type: schema.displaytype getsobjectfield() returns the token for this field. signature public schema.sobjectfield getsobjectfield() return value type: schema.sobjectfield picklistentry class represents a picklist entry. namespace schema usage picklist fields contain a list of one or more items from which a user chooses a single item. they display as drop-down lists in the salesforce user interface. one of the items can be configured as the default item. a schema.picklistentry object is returned from the field describe result using the getpicklistvalues method. for example: schema.describefieldresult f = account.industry.getdescribe(); list<schema.picklistentry> p = f.getpicklistvalues(); 2713apex reference guide picklistentry class picklistentry methods the following are methods for picklistentry. all are instance methods. in this section: getlabel() returns the display name of this item in the picklist. getvalue() returns the value of this item in the picklist. isactive() returns true if this item must be displayed in the drop-down list for the picklist field in the user interface, false otherwise. isdefaultvalue() returns true if this item is the default value for the picklist, false otherwise. only one item in a picklist can be designated as the default. getlabel() returns the display name of this item in the picklist. signature public string getlabel() return value type: string getvalue() returns the value of this item in the picklist. signature public string getvalue() return value type: string isactive() returns true if this item must be displayed in the drop-down list for the picklist field in the user interface, false otherwise. signature public boolean isactive() 2714apex reference guide recordtypeinfo class return value type: boolean isdefaultvalue() returns true if this item is the default value for the picklist, false otherwise. only one item in a picklist can be designated as the default. signature public boolean isdefaultvalue() return value type: boolean recordtypeinfo class contains methods for accessing record type information for an sobject with associated record types. namespace schema usage a recordtypeinfo object is returned from the sobject describe result using the getrecordtypeinfos method. for example: schema.describesobjectresult r = account.sobjecttype.getdescribe(); list<schema.recordtypeinfo> rt = r.getrecordtypeinfos(); in addition to the getrecordtypeinfos method, you can use the getrecordtypeinfosbyid and the getrecordtypeinfosbyname methods. these methods return maps that associate recordtypeinfo with record ids and record labels, respectively. example the following example assumes at least one record type has been created for the account object: recordtype rt = [select id,name from recordtype where sobjecttype='account' limit 1]; schema.describesobjectresult d = schema.sobjecttype.account; map<id,schema.recordtypeinfo> rtmapbyid = d.getrecordtypeinfosbyid(); schema.recordtypeinfo rtbyid = rtmapbyid.get(rt.id); map<string,schema.recordtypeinfo> rtmapbyname = d.getrecordtypeinfosbyname(); schema.record
typeinfo rtbyname = rtmapbyname.get(rt.name); system.assertequals(rtbyid,rtbyname); recordtypeinfo methods the following are methods for recordtypeinfo. all are instance methods. 2715apex reference guide recordtypeinfo class in this section: getdevelopername() returns the developer name for this record type. getname() returns the ui label of this record type. the label can be translated into any language that salesforce supports. getrecordtypeid() returns the id of this record type. isactive() returns true if this record type is active, false otherwise. isavailable() returns true if this record type is available to the current user, false otherwise. use this method to display a list of available record types to the user when he or she is creating a new record. isdefaultrecordtypemapping() returns true if this is the default record type for the user, false otherwise. ismaster() returns true if this is the master record type and false otherwise. the master record type is the default record type that’s used when a record has no custom record type associated with it. getdevelopername() returns the developer name for this record type. signature public string getdevelopername() return value type: string getname() returns the ui label of this record type. the label can be translated into any language that salesforce supports. signature public string getname() return value type: string getrecordtypeid() returns the id of this record type. 2716apex reference guide recordtypeinfo class signature public id getrecordtypeid() return value type: id isactive() returns true if this record type is active, false otherwise. signature public boolean isactive() return value type: boolean isavailable() returns true if this record type is available to the current user, false otherwise. use this method to display a list of available record types to the user when he or she is creating a new record. signature public boolean isavailable() return value type: boolean isdefaultrecordtypemapping() returns true if this is the default record type for the user, false otherwise. signature public boolean isdefaultrecordtypemapping() return value type: boolean ismaster() returns true if this is the master record type and false otherwise. the master record type is the default record type that’s used when a record has no custom record type associated with it. 2717apex reference guide soaptype enum signature public boolean ismaster() return value type: boolean soaptype enum a schema.soaptype enum value is returned by the field describe result getsoaptype method. namespace schema type field value what the field object contains anytype any value of the following types: string, boolean, integer, double, id, date or datetime. base64binary base64-encoded arbitrary binary data (of type base64binary) boolean boolean (true or false) values date date values datetime datetime values double double values id primary key field for an object integer integer values string string values time time values usage for more information, see soaptypes in the soap api developer guide. for more information about the methods shared by all enums, see enum methods. sobjectdescribeoptions enum a schema.sobjectdescribeoptions enum value is a parameter in the sobjecttype.getdescribe method. usage for more information about the method using this enum, see getdescribe(options). 2718apex reference guide sobjectfield class enum values the following are the values of the schema.sobjectdescribeoptions enum. value description default either eager-load or lazy-load depending on the api version. deferred lazy-load child relationships; do not load all child relationships at the time of first invocation of the method. full eager-load all elements of the describe, including child relationships, up-front at the time of method invocation. see getdescribe(options). sobjectfield class a schema.sobjectfield object is returned from the field describe result using the getcontroller and getsobjectfield methods. namespace schema example schema.describefieldresult f = account.industry.getdescribe(); schema.sobjectfield t = f.getsobjectfield(); sobjectfield methods the following are instance methods for s
objectfield. in this section: getdescribe() returns the describe field result for this field. getdescribe(options) returns the describe field result for this field. this method also provides an option to get all the describe field results for an object. getdescribe() returns the describe field result for this field. signature public schema.describefieldresult getdescribe() 2719apex reference guide sobjecttype class return value type: schema.describefieldresult getdescribe(options) returns the describe field result for this field. this method also provides an option to get all the describe field results for an object. signature public schema.describefieldresult getdescribe(object options) parameters options type: object use this parameter to pass fielddescribeoptions.full_describe when a subset of system objects could have different results for picklist values based on the context they're invoked in. this parameter computes all aspects of describe field results. for example, aiconversationcontext.persontype field is a picklist that contains a list of accessible object types. return value type: schema.describefieldresult sobjecttype class a schema.sobjecttype object is returned from the field describe result using the getreferenceto method, or from the sobject describe result using the getsobjecttype method. namespace schema usage schema.describefieldresult f = account.industry.getdescribe(); list<schema.sobjecttype> p = f.getreferenceto(); sobjecttype methods the following are methods for sobjecttype. all are instance methods. in this section: getdescribe() returns the describe sobject result for this field. 2720apex reference guide sobjecttype class getdescribe(options) returns the describe sobject result for this field; the parameter value determines whether all child relationships are loaded up-front, or not. newsobject() constructs a new sobject of this type. newsobject(id) constructs a new sobject of this type, with the specified id. newsobject(recordtypeid, loaddefaults) constructs a new sobject of this type, and optionally, of the specified record type id and with default custom field values. getdescribe() returns the describe sobject result for this field. signature public schema.describesobjectresult getdescribe() return value type: schema.describesobjectresult getdescribe(options) returns the describe sobject result for this field; the parameter value determines whether all child relationships are loaded up-front, or not. signature public schema.describesobjectresult getdescribe(object options) parameters options type: object the parameter values determine how the elements of the describe operation are loaded. • use sobjectdescribeoptions.full to eager-load all elements of the describe, including child relationships, up-front at the time of method invocation. this describe guarantees fully coherent results, even if the describe object is passed to another namespace, api version, or other apex context that may have different results when generating describe attributes. • use sobjectdescribeoptions.deferred to enable lazy initialization of describe attributes on first use. this means that all child relationships will not be loaded at the time of first invocation of the method. • use sobjectdescribeoptions.default to default to either eager-load or lazy-load depending on the api version. the type of describe operation, as determined by the parameter value is depicted in this table. 2721apex reference guide sobjecttype class table 2: type of load for sobjecttype.getdescribe() parameter value api version 43.0 and earlier api version 44.0 and later full eager eager deferred lazy lazy default lazy lazy return value type: schema.describesobjectresult newsobject() constructs a new sobject of this type. signature public sobject newsobject() return value type: sobject example for an example, see dynamic dml. newsobject(id) constructs a new sobject of this type, with the specified id. signature public sobject newsobject(id id) parameters id type: id return value type: sobject usage for the argument, pass the id of an existing record in the database. 2722apex reference guide sobjecttype class after you create a
new sobject, the sobject returned has all fields set to null. you can set any updateable field to desired values and then update the record in the database. only the fields you set new values for are updated and all other fields which are not system fields are preserved. newsobject(recordtypeid, loaddefaults) constructs a new sobject of this type, and optionally, of the specified record type id and with default custom field values. 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 sobject newsobject(id recordtypeid, boolean loaddefaults) parameters recordtypeid type: id specifies the record type id of the sobject to create. if no record type exists for this sobject, use null. if the sobject has record types and you specify null, the default record type is used. loaddefaults type: boolean specifies whether to populate custom fields with their predefined default values (true) or not (false). return value type: sobject usage • for required fields that have no default values, make sure to provide a value before inserting the new sobject. otherwise, the insertion results in an error. an example is the account name field or a master-detail relationship field. • since picklists and multi-select picklists can have default values specified per record type, this method populates the default value corresponding to the record type specified. • if fields have no predefined default values and the loaddefaults argument is true, this method creates the sobject with field values of null. • if the loaddefaults argument is false, this method creates the sobject with field values of null. • this method populates read-only custom fields of the new sobject with default values. you can then insert the new sobject with the read-only fields, even though these fields cannot be edited after they’re inserted. • if a custom field is marked as unique and also provides a default value, inserting more than one new sobject will cause a run-time exception because of duplicate field values. to learn more about default field values, see “default field values” in the salesforce online help. 2723apex reference guide search namespace example: creating new sobject with default values this sample creates an account with any default values populated for its custom fields, if any, using the newsobject method. it also creates a second account for a specific record type. for both accounts, the sample sets the name field, which is a required field that doesn’t have a default value, before inserting the new accounts. // create an account with predefined default values account acct = (account)account.sobjecttype.newsobject(null, true); // provide a value for name acct.name = 'acme'; // insert new account insert acct; // this is for record type rt1 of account id rtid = [select id from recordtype where sobjecttype='account' and name='rt1'].id; account acct2 = (account)account.sobjecttype.newsobject(rtid, true); // provide a value for name acct2.name = 'acme2'; // insert new account insert acct2; search namespace the search namespace provides classes for getting search results and suggestion results. the following are the classes in the search namespace. in this section: knowledgesuggestionfilter class filter settings that narrow the results from a call to system.search.suggest(searchquery, sobjecttype, options) when the sosl search query contains a knowledgearticleversion object. questionsuggestionfilter class the search.questionsuggestionfilter class filters results from a call to system.search.suggest(searchquery, sobjecttype, options) when the sosl searchquery contains a feeditem object. searchresult class a wrapper object that contains an sobject and search metadata. searchresults class wraps the results returned by the search.find(string) method. suggestionoption class options that narrow record and article suggestion results returned from a call to system.search.suggest(string, string, search.suggestionoption). suggestionresult class a wrapper object that contains an sobject. 2724apex reference guide knowledgesuggestionfilter class suggestionresults class wraps the results returned by the search.suggest(string, string, search.suggestionoption) method. see also: find(searchquery) suggest(
searchquery, sobjecttype, suggestions) knowledgesuggestionfilter class filter settings that narrow the results from a call to system.search.suggest(searchquery, sobjecttype, options) when the sosl search query contains a knowledgearticleversion object. namespace search knowledgesuggestionfilter methods the following are methods for knowledgesuggestionfilter. in this section: addarticletype(articletype) adds a filter that narrows suggestion results to display the specified article type. this filter is optional. adddatacategory(datacategorygroupname, datacategoryname) adds a filter that narrows suggestion results to display articles in the specified data category. this filter is optional. addtopic(topic) specifies the article topic to return. this filter is optional. setchannel(channelname) sets a channel to narrow the suggestion results to articles in the specified channel. this filter is optional. setdatacategories(datacategoryfilters) adds filters that narrow suggestion results to display articles in the specified data categories. use this method to set multiple data category group and name pairs in one call. this filter is optional. setlanguage(localecode) sets a language to narrow the suggestion results to display articles in that language. this filter value is required in calls to system.search.suggest(string, string, search.suggestionoption). setpublishstatus(publishstatus) sets a publish status to narrow the suggestion results to display articles with that status. this filter value is required in calls to system.search.suggest(string, string, search.suggestionoption). setvalidationstatus(validationstatus) sets a validation status to narrow the suggestion results to display articles with that status. this filter is optional. addarticletype(articletype) adds a filter that narrows suggestion results to display the specified article type. this filter is optional. 2725apex reference guide knowledgesuggestionfilter class signature public void addarticletype(string articletype) parameters articletype type: string a three-character id prefix indicating the desired article type. return value type: void usage to add more than 1 article type, call the method multiple times. adddatacategory(datacategorygroupname, datacategoryname) adds a filter that narrows suggestion results to display articles in the specified data category. this filter is optional. signature public void adddatacategory(string datacategorygroupname, string datacategoryname) parameters datacategorygroupname type: string the name of the data category group datacategoryname type: string the name of the data category. return value type: void usage to set multiple data categories, call the method multiple times. the name of the data category group and name of the data category for desired articles, expressed as a mapping, for example, search.knowledgesuggestionfilter.adddatacategory('regions', 'asia'). addtopic(topic) specifies the article topic to return. this filter is optional. 2726apex reference guide knowledgesuggestionfilter class signature public void addtopic(string topic) parameters addtopic type: string the name of the article topic. return value type: void usage to add more than 1 article topic, call the method multiple times. setchannel(channelname) sets a channel to narrow the suggestion results to articles in the specified channel. this filter is optional. signature public void setchannel(string channelname) parameters channelname type: string the name of a channel. valid values are: • allchannels–visible in all channels the user has access to • app–visible in the internal salesforce knowledge application • pkb–visible in the public knowledge base • csp–visible in the customer portal • prm–visible in the partner portal if channel isn’t specified, the default value is determined by the type of user. • pkb for a guest user • csp for a customer portal user • prm for a partner portal user • app for any other type of user if channel is specified, the specified value may not be the actual value requested, because of certain requirements. • for guest, customer portal, and partner portal users, the specified value must match the default value for each user type. if the values don’t match or allchannels is specified, then app replaces the specified value. • for all users other than guest, customer portal, and partner portal users: – if pkb, csp, prm, or app are specified, then the specified value is used. 27
27apex reference guide knowledgesuggestionfilter class – if allchannels is specified, then app replaces the specified value. return value type: void setdatacategories(datacategoryfilters) adds filters that narrow suggestion results to display articles in the specified data categories. use this method to set multiple data category group and name pairs in one call. this filter is optional. signature public void setdatacategories(map datacategoryfilters) parameters datacategoryfilters type: map a map of data category group and data category name pairs. return value type: void setlanguage(localecode) sets a language to narrow the suggestion results to display articles in that language. this filter value is required in calls to system.search.suggest(string, string, search.suggestionoption). signature public void setlanguage(string localecode) parameters localecode type: string a locale code. for example, 'en_us' (english–united states), or 'es' (spanish). return value type: void see also: supported locales 2728apex reference guide questionsuggestionfilter class setpublishstatus(publishstatus) sets a publish status to narrow the suggestion results to display articles with that status. this filter value is required in calls to system.search.suggest(string, string, search.suggestionoption). signature public void setpublishstatus(string publishstatus) parameters publishstatus type: string a publish status. valid values are: • draft–articles aren’t published in salesforce knowledge. • online–articles are published in salesforce knowledge. • archived–articles aren’t published and are available in archived articles view. setvalidationstatus(validationstatus) sets a validation status to narrow the suggestion results to display articles with that status. this filter is optional. signature public void setvalidationstatus(string validationstatus) parameters validationstatus type: string an article validation status. these values are available in the validationstatus field on the knowledgearticleversion object. return value type: void questionsuggestionfilter class the search.questionsuggestionfilter class filters results from a call to system.search.suggest(searchquery, sobjecttype, options) when the sosl searchquery contains a feeditem object. namespace search in this section: questionsuggestionfilter methods 2729apex reference guide questionsuggestionfilter class questionsuggestionfilter methods the following are methods for questionsuggestionfilter. in this section: addgroupid(groupid) adds a filter to display questions associated with the single specified group whose id is passed in as an argument. this filter is optional. addnetworkid(networkid) adds a filter to display questions associated with the single specified network whose id is passed in as an argument. this filter is optional. adduserid(userid) adds a filter to display questions belonging to the single specified user whose id is passed in as an argument. this filter is optional. setgroupids(groupids) sets a new list of groups to replace the current list of groups where the group ids are passed in as an argument. this filter is optional. setnetworkids(networkids) sets a new list of networks to replace the current list of networks where the network ids are passed in as an argument. this filter is optional. settopicid(topicid) sets a filter to display questions associated with the single specified topic whose id is passed in as an argument. this filter is optional. setuserids(userids) sets a new list of users to replace the current list of users where the users ids are passed in as an argument. this filter is optional. addgroupid(groupid) adds a filter to display questions associated with the single specified group whose id is passed in as an argument. this filter is optional. signature public void addgroupid(string groupid) parameters groupid type: string the id for a group. return value type: void usage to add more than one group, call the method multiple times. 2730apex reference guide questionsuggestionfilter class addnetworkid(networkid) adds a filter to display questions associated with the single specified network whose id is passed in as an argument. this filter is optional. signature public void addnetworkid(string networkid) parameters networkid type: string the id of the experience cloud site about which you’re retrieving this information.
return value type: void usage to add more than one network, call the method multiple times. adduserid(userid) adds a filter to display questions belonging to the single specified user whose id is passed in as an argument. this filter is optional. signature public void adduserid(string userid) parameters userid type: string the id for the user. return value type: void usage to add more than one user, call the method multiple times. setgroupids(groupids) sets a new list of groups to replace the current list of groups where the group ids are passed in as an argument. this filter is optional. signature public void setgroupids(list<string> groupids) 2731apex reference guide questionsuggestionfilter class parameters groupids type: list<string> a list of group ids. return value type: void setnetworkids(networkids) sets a new list of networks to replace the current list of networks where the network ids are passed in as an argument. this filter is optional. signature public void setnetworkids(list<string> networkids) parameters networkids type: list<string> a list of network ids. return value type: void settopicid(topicid) sets a filter to display questions associated with the single specified topic whose id is passed in as an argument. this filter is optional. signature public void settopicid(string topicid) parameters topicid type: string the id for a topic. return value type: void setuserids(userids) sets a new list of users to replace the current list of users where the users ids are passed in as an argument. this filter is optional. 2732
apex reference guide searchresult class signature public void setuserids(list<string> userids) parameters userids type: list<string> a list of user ids. return value type: void searchresult class a wrapper object that contains an sobject and search metadata. namespace search searchresult methods the following are methods for searchresult. in this section: getsobject() returns an sobject from a searchresult object. getsnippet(fieldname) returns a snippet from a case, feed, or knowledge article searchresult object based on the specified field name. getsnippet() returns a snippet from a searchresult object based on the default field. getsobject() returns an sobject from a searchresult object. signature public sobject getsobject() 2733apex reference guide searchresult class return value type: sobject see also: find(searchquery) apex developer guide: dynamic sosl getsnippet(fieldname) returns a snippet from a case, feed, or knowledge article searchresult object based on the specified field name. signature public string getsnippet(string fieldname) parameters fieldname type: string the field name to use for creating the snippet. valid values: case.casenumber, feedpost.title, knowledgearticleversion.title return value type: string see also: find(searchquery) apex developer guide: dynamic sosl getsnippet() returns a snippet from a searchresult object based on the default field. signature public string getsnippet() return value type: string see also: find(searchquery) apex developer guide: dynamic sosl 2734apex reference guide searchresults class searchresults class wraps the results returned by the search.find(string) method. namespace search searchresults methods the following are methods for searchresults. in this section: get(sobjecttype) returns a list of search.searchresult objects that contain an sobject of the specified type. get(sobjecttype) returns a list of search.searchresult objects that contain an sobject of the specified type. signature public list<search.searchresult> get(string sobjecttype) parameters sobjecttype type: string the name of an sobject in the dynamic sosl query passed to the search.find(string) method. return value type: list<search.searchresult> usage sosl queries passed to the search.find(string) method can return results for multiple objects. for example, the query search.find('find \'map\' in all fields returning account, contact, opportunity') includes results for 3 objects. you can call get(string) to retrieve search results for 1 object at a time. for example, to get results for the account object, call search.searchresults.get('account'). see also: find(searchquery) searchresult methods apex developer guide: dynamic sosl 2735apex reference guide suggestionoption class suggestionoption class options that narrow record and article suggestion results returned from a call to system.search.suggest(string, string, search.suggestionoption). namespace search suggestionoption methods the following are methods for suggestionoption. in this section: setfilter(knowledgesuggestionfilter) set filters that narrow salesforce knowledge article results in a call to system.search.suggest(string, string, search.suggestionoption). setlimit(limit) the maximum number of record or article suggestions to retrieve. setfilter(knowledgesuggestionfilter) set filters that narrow salesforce knowledge article results in a call to system.search.suggest(string, string, search.suggestionoption). signature public void setfilter(search.knowledegesuggestionfilter knowledgesuggestionfilter) parameters knowledgesuggestionfilter type: knowledgesuggestionfilter an object containing filters that narrow the search results. return value type: void usage search.knowledgesuggestionfilter filters = new search.knowledgesuggestionfilter(); filters.setlanguage('en_us'); filters.setpublishstatus('online'); filters.setchannel('app'); search.suggestionoption options = new search.suggestionoption(); options.setfilter(filters); 2736apex reference guide suggestionresult class search.suggestionresults suggestionresults = search.suggest('all', 'knowledgearticle
version', options); for (search.suggestionresult searchresult : suggestionresults.getsuggestionresults()) { knowledgearticleversion article = (knowledgearticleversion)result.getsobject(); system.debug(article.title); } setlimit(limit) the maximum number of record or article suggestions to retrieve. signature public void setlimit(integer limit) parameters limit type: integer the maximum number of record or article suggestions to retrieve. return value type: void usage by default, the system.search.suggest(string, string, search.suggestionoption) method returns the 5 most relevant results. however, if your query is broad, it could match more than 5 results. if search.suggestionresults.hasmoreresults() returns true, there are more than 5 results. to retrieve them, call setlimit(integer) to increase the number of suggestions results. search.suggestionoption option = new search.suggestionoption(); option.setlimit(10); search.suggest('my query', 'mysobjecttype', option); suggestionresult class a wrapper object that contains an sobject. namespace search suggestionresult methods the following are methods for suggestionresult. 2737apex reference guide suggestionresults class in this section: getsobject() returns the sobject from a suggestionresult object. getsobject() returns the sobject from a suggestionresult object. signature public sobject getsobject() return value type: sobject suggestionresults class wraps the results returned by the search.suggest(string, string, search.suggestionoption) method. namespace search suggestionresults methods the following are methods for suggestionresults. in this section: getsuggestionresults() returns a list of suggestionresult objects from the response to a call to search.suggest(string, string, search.suggestionoption). hasmoreresults() indicates whether a call to system.search.suggest(string, string, search.suggestionoption) has more results available than were returned. getsuggestionresults() returns a list of suggestionresult objects from the response to a call to search.suggest(string, string, search.suggestionoption). signature public list<search.suggestionresult> getsuggestionresults() 2738apex reference guide sfc namespace return value type: list<suggestionresult> hasmoreresults() indicates whether a call to system.search.suggest(string, string, search.suggestionoption) has more results available than were returned. signature public boolean hasmoreresults() return value type: boolean usage if a limit isn’t specified, 5 records are returned in calls to system.search.suggest(string, string, search.suggestionoption). if there are more suggested records than the limit specified, a call to hasmoreresults() returns true. sfc namespace the sfc namespace contains classes used in salesforce files. the following are the classes in the sfc namespace. in this section: contentdownloadcontext enum this enum specifies the download context. contentdownloadhandler class use contentdownloadhandler to define a custom download handler that controls how content is downloaded. contentdownloadhandlerfactory interface use this interface to provide a class factory that salesforce can call to create instances of your custom contentdownloadhandler. contentdownloadcontext enum this enum specifies the download context. usage if the operationcontext is content, chatter, delivery, s1, or mobile, it can be used in a shepherd servlet as a query parameter. it’s possible for a user to change the query parameters. if a user enters a value other than content, chatter, delivery, s1, or mobile, the value is treated as the default value content. users can’t set query parameters to rest_api, soql, or retrieve, so these values can be assumed to be accurate. 2739apex reference guide contentdownloadhandler class enum values the sfc.contentdownloadcontext enum value identifies the content download context. the enum value is provided as a query parameter in the file download servlet. the following are the values of the sfc.contentdownloadcontext enum. value description chatter download from chatter. content default value. downloads from the salesforce crm content product. delivery download of a content delivery. rest_api download from the connect api (/connect/files/$
{fileid}/content endpoint). used in both android and ios apps. retrieve retrieve versiondata from sobject api. s1 download from lightning experience. soql select versiondata from soql. contentdownloadhandler class use contentdownloadhandler to define a custom download handler that controls how content is downloaded. namespace sfc on page 2739 in this section: contentdownloadhandler properties contentdownloadhandler properties the following are properties for contentdownloadhandler. in this section: downloaderrormessage a customized error message explaining why the download isn’t allowed. isdownloadallowed indicates whether or not download is allowed. redirecturl the url the user should be redirected to, for applying information rights management (irm) control, virus scanning, or other behavior. downloaderrormessage a customized error message explaining why the download isn’t allowed. 2740apex reference guide contentdownloadhandlerfactory interface signature public string downloaderrormessage {get; set;} property value type: string this message is used if a redirecturl is not provided. if the download is not allowed, salesforce will throw a contentcustomizeddownloadexception exception that contains the downloaderrormessage. isdownloadallowed indicates whether or not download is allowed. signature public boolean isdownloadallowed {get; set;} property value type: boolean redirecturl the url the user should be redirected to, for applying information rights management (irm) control, virus scanning, or other behavior. signature public string redirecturl {get; set;} property value type: string the url must be a valid relative url. for example, the redirect can be a custom visualforce page such as “/apex/irmcontrol”. urls with no path, such as “www.domain.com”, will result in an invalidparametervalueexception. contentdownloadhandlerfactory interface use this interface to provide a class factory that salesforce can call to create instances of your custom contentdownloadhandler. namespace sfc on page 2739 usage contentdownloadhandler getcontentdownloadhandler(list<id> ids, contentdownloadcontext context); 2741apex reference guide contentdownloadhandlerfactory interface in this section: contentdownloadhandlerfactory methods contentdownloadhandlerfactory example implementation contentdownloadhandlerfactory methods the following are methods for contentdownloadhandlerfactory. in this section: getcontentdownloadhandler(var1, var2) returns a contentdownloadhandler for a given list of content ids and a download context. getcontentdownloadhandler(var1, var2) returns a contentdownloadhandler for a given list of content ids and a download context. signature public sfc.contentdownloadhandler getcontentdownloadhandler(list<id> var1, sfc.contentdownloadcontext var2) parameters var1 type: list<id> var2 type: sfc.contentdownloadcontext on page 2739 return value type: sfc.contentdownloadhandler on page 2740 contentdownloadhandlerfactory example implementation this example creates a class that implements the sfc.contentdownloadhandlerfactory interface and returns a download handler that blocks downloading content to mobile devices. // allow customization of the content download experience public class contentdownloadhandlerfactoryimpl implements sfc.contentdownloadhandlerfactory { public sfc.contentdownloadhandler getcontentdownloadhandler(list<id> ids, sfc.contentdownloadcontext context) { sfc.contentdownloadhandler contentdownloadhandler = new sfc.contentdownloadhandler(); if(context == sfc.contentdownloadcontext.mobile) { contentdownloadhandler.isdownloadallowed = false; contentdownloadhandler.downloaderrormessage = 'downloading a file from a mobile 2742apex reference guide sfdc_checkout namespace device is not allowed.'; return contentdownloadhandler; } contentdownloadhandler.isdownloadallowed = true; return contentdownloadhandler; } } sfdc_checkout namespace the sfdc_checkout namespace provides an interface and classes for b2b commerce apps in salesforce. the following are the classes in the sfdc_checkout namespace. in this section: asynccartprocessor interface use this interface to implement asynchronous integrations in b2b commerce. b2bcheckoutcontroller class communicate with simple checkout apex methods to work with data related to b2b commerce checkout. integrationinfo class provides the values that b2b commerce checkout uses to map requests to responses, necessary metadata, and context. integration
status class supports synchronous execution of apex integrations for b2b commerce. the implementation must return the status of the execution. integrationstatus.status enum the integrationstatus.status enum describes the status of the current integration. asynccartprocessor interface use this interface to implement asynchronous integrations in b2b commerce. namespace sfdc_checkout in this section: asynccartprocessor methods asynccartprocessor example implementation asynccartprocessor methods the following are methods for asynccartprocessor. 2743apex reference guide b2bcheckoutcontroller class in this section: startcartprocessasync(integrationinfo, cartid) the startcartprocessasync method is called asynchronously by the integration framework. calling this method begins cart processing for commerce checkout. startcartprocessasync(integrationinfo, cartid) the startcartprocessasync method is called asynchronously by the integration framework. calling this method begins cart processing for commerce checkout. signature public sfdc_checkout.integrationstatus startcartprocessasync(sfdc_checkout.integrationinfo integrationinfo, id cartid) parameters integrationinfo type: integrationinfo provides values that b2b commerce checkout apis use to map requests to responses, necessary metadata, and context. cartid type: id id of the webcart object. return value type: integrationstatus status of the current integration. possible values are success and failed. asynccartprocessor example implementation this is an example implementation of the sfdc_checkout.asynccartprocessor interface. global interface checkout_asynccartprocessor { //integration for async processing integrationstatus startcartprocessasync( integrationinfo integrationinfo, id cartid); } asynccartprocessor is a base interface. there are four interfaces that extend it, including cartinventoryvalidation, cartpricecalculations, cartshippingcharges, and carttaxcalculations. for more information about these interfaces, including code examples and test classes, see checkout integrations. b2bcheckoutcontroller class communicate with simple checkout apex methods to work with data related to b2b commerce checkout. 2744apex reference guide integrationinfo class namespace sfdc_checkout usage you must specify the sfdc_checkout namespace when creating an instance of this class. in this section: b2bcheckoutcontroller methods b2bcheckoutcontroller methods the following are methods for b2bcheckoutcontroller. in this section: licensecompliance(cartid, orderid) if you implement your own cart-to-order process without invoking the cart to order flow core action, you must invoke this method to correctly track your orders for gmv (gross merchandise value) recognition. licensecompliance(cartid, orderid) if you implement your own cart-to-order process without invoking the cart to order flow core action, you must invoke this method to correctly track your orders for gmv (gross merchandise value) recognition. signature public static void licensecompliance(string cartid, string orderid) parameters cartid type: string the cartid of a web cart from which an order is created. orderid type: string the orderid of the order you created from the cart. return value type: void integrationinfo class provides the values that b2b commerce checkout uses to map requests to responses, necessary metadata, and context. 2745apex reference guide integrationinfo class namespace sfdc_checkout on page 2743 usage this class provides information about a b2b commerce integration. an instance of this class is passed as a parameter into the integration interface. in this section: integrationinfo properties integrationinfo properties the following are properties for integrationinfo. in this section: integrationid the unique id of a b2b commerce integration. jobid the id of the job, specific to the salesforce background operation framework. sitelanguage site language to be used by third party services. integrationid the unique id of a b2b commerce integration. signature public string integrationid {get; set;} property value type: string jobid the id of the job, specific to the salesforce background operation framework. signature public string jobid {get; set;} property value type: string 2746apex reference guide integrationstatus class sitelanguage site language to be used by third party services.
signature public string sitelanguage {get; set;} property value type: string integrationstatus class supports synchronous execution of apex integrations for b2b commerce. the implementation must return the status of the execution. namespace sfdc_checkout usage you must specify the sfdc_checkout namespace when creating an instance of this class. in this section: integrationstatus properties integrationstatus properties the following are properties for integrationstatus. in this section: status indicates the status of the integration process and whether or not it completed successfully. status indicates the status of the integration process and whether or not it completed successfully. signature public sfdc_checkout.integrationstatus.status status {get; set;} property value type: sfdc_checkout.integrationstatus.status on page 2748 2747apex reference guide integrationstatus.status enum integrationstatus.status enum the integrationstatus.status enum describes the status of the current integration. enum values the following are the values of the sfdc_checkout.integrationstatus.status enum. value description failed indicates transient, unknown error, managed by the implementor. the buyer can retry this action. success indicates the integration executed successfully. sfdc_surveys namespace the sfdc_surveys namespace provides an interface for shortening survey invitations. the following are the classes in the sfdc_surveys namespace. in this section: surveyinvitationlinkshortener interface use this interface to provide a class factory that salesforce can call to create instances of your custom surveyinvitationlinkshortener. example implementation to associate surveysubjects with surveyinvitation and surveyresponses if no survey responses are populated, create a custom code to associate surveysubjects with surveyinvitation and surveyresponses. surveyinvitationlinkshortener interface use this interface to provide a class factory that salesforce can call to create instances of your custom surveyinvitationlinkshortener. namespace sfdc_surveys usage implement an instance of the surveyinvitationlinkshortener interface to shorten the survey invitation that can be distributed as short urls over customer engaged channels, such as sms, whatsapp, or facebook messenger. special access rules to implement this interface, you must have the salesforce feedback management license enabled in your salesforce organization. 2748apex reference guide surveyinvitationlinkshortener interface in this section: surveyinvitationlinkshortener methods surveyinvitationlinkshortener example implementation surveyinvitationlinkshortener methods the following are methods for surveyinvitationlinkshortener. in this section: getshortenedurl(var1) returns a shortened url for a given survey invitation. getshortenedurl(var1) returns a shortened url for a given survey invitation. signature public string getshortenedurl(string var1) parameters var1 type: string return value type: string surveyinvitationlinkshortener example implementation this is an example implementation of the sfdc_surveys.surveyinvitationlinkshortener interface. this sample code uses named credentials for authentication. for more information on named credentials, see named credentials as callout endpoints. public class surveyinvitationlinkshortenerimpl implements sfdc_surveys.surveyinvitationlinkshortener { public string getshortenedurl(string invitationurl) { return shortenurlusingbitlyservice(invitationurl); } public string shortenurlusingbitlyservice(string invitationurl) { httprequest request = new httprequest(); request.setendpoint('callout:bitly/v4/shorten'); request.setmethod('post'); request.setheader('authorization', 'bearer {!$credential.password}'); request.setheader('accept', 'application/json'); request.setheader('content-type', 'application/json'); request.setbody(json.serialize(new map<string, object>{ 2749apex reference guide example implementation to associate surveysubjects with surveyinvitation and surveyresponses 'group_guid' => '{!$credential.username}', 'long_url' => invitationurl })); http http = new http(); httpresponse res = http.send(request); object result = json.deserializeuntyped(res.getbody
()); if (result instanceof map<string, object>) { map<string, object> resultmap = (map<string, object>) result; object shortenedlinkval = resultmap.get('link'); if(shortenedlinkval != null && shortenedlinkval instanceof string) { return (string) shortenedlinkval; } } return invitationurl; } } example implementation to associate surveysubjects with surveyinvitation and surveyresponses if no survey responses are populated, create a custom code to associate surveysubjects with surveyinvitation and surveyresponses. this example shows how to associate surveysubjects with surveyinvitation and surveyresponses. public class createentriesinsurveyinvitationresprl { // utility to create surveyinvitation and surveysubject record public static void addentry(string associatedrecordid, string surveyid, string participantid) { string invitationid = createsurveyinvitation(surveyid, participantid); createsurveysubject(invitationid, associatedrecordid); } // create an unauthenticated invitation by setting the surveyid and participantid private static string createsurveyinvitation(string surveyid, string participantid) { surveyinvitation surveyinv = new surveyinvitation(); surveyinv.name = 'surveyinvitationforcase'; // add your survey invitation name here surveyinv.participantid = participantid; surveyinv.communityid = '0dbrm0000004n4y'; //add your community id here surveyinv.optionsallowguestuserresponse = true; surveyinv.surveyid = surveyid; // insert the surveyinvitation record insert surveyinv; return surveyinv.id; } // associate the above invitation to the required record (eg: case, opportunity...) 2750apex reference guide site namespace private static void createsurveysubject(string invitationid, string associatedrecordid) { surveysubject subj = new surveysubject(); subj.name = 'sur_subject_for_invitation'; subj.parentid = invitationid; // similary you can use survey response id to associate survey subject to a response record. subj.subjectid = associatedrecordid; // insert the surveysubject record insert subj; } } //use this trigger to create a survey subject record associated to //the survey response record trigger surveyresponseforcasetrigger on surveyresponse (after insert) { system.debug('inside survey response trigger '); for(surveyresponse sr: trigger.new) { surveysubject subj = new surveysubject(); subj.name = 'sur_subject_for_response'; subj.parentid = sr.id; //associating survey response id //get the associatedrecordid recordid (like case, opportunity etc) using the surveyinvitation id and //assigning it to subjectid, assuming we inserted surveysubject record for the associated invitation //using the previous code list<surveysubject> sursubj=[select subjectid from surveysubject where parentid = :sr.invitationid]; for(surveysubject sub:sursubj){ string ids=string.valueof(sub.subjectid).substring(0,3); if('500'.equals(ids)){ subj.subjectid =sub.subjectid; // insert the surveysubject record insert subj; break; } } site namespace the site namespace provides an interface for rewriting sites urls. the following is the interface in the site namespace. 2751apex reference guide urlrewriter interface in this section: urlrewriter interface enables rewriting sites urls. site exceptions the site namespace contains an exception class. urlrewriter interface enables rewriting sites urls. namespace site usage sites provides built-in logic that helps you display user-friendly urls and links to site visitors. create rules to rewrite url requests typed into the address bar, launched from bookmarks, or linked from external websites. you can also create rules to rewrite the urls for links within site pages. url rewriting not only makes urls more descriptive and intuitive for users, it allows search engines to better index your site pages. for example, let's say that you have a blog site. without url rewriting, a blog entry's url might look like this: https://myblog.my.salesforce-sites.com/posts?id=003d000000q0pcn to rewrite urls for a site, create an apex class that maps
the original urls to user-friendly urls, and then add the apex class to your site. urlrewriter methods the following are methods for urlrewriter. all are instance methods. in this section: generateurlfor(salesforceurls) maps a list of salesforce urls to a list of user-friendly urls. maprequesturl(userfriendlyurl) maps a user-friendly url to a salesforce url. generateurlfor(salesforceurls) maps a list of salesforce urls to a list of user-friendly urls. signature public system.pagereference[] generateurlfor(system.pagereference[] salesforceurls) 2752apex reference guide site exceptions parameters salesforceurls type: system.pagereference[] return value type: system.pagereference[] usage you can use list<pagereference> instead of pagereference[], if you prefer. important: the size and order of the input list of salesforce urls must exactly correspond to the size and order of the generated list of user-friendly urls. the generateurlfor method maps input urls to output urls based on the order in the lists. maprequesturl(userfriendlyurl) maps a user-friendly url to a salesforce url. signature public system.pagereference maprequesturl(system.pagereference userfriendlyurl) parameters userfriendlyurl type: system.pagereference return value type: system.pagereference site exceptions the site namespace contains an exception class. all exception classes support built-in methods for returning the error message and exception type. see exception class and built-in exceptions. the site namespace contains this exception: exception description methods site.externalusercreateexception unable to create use the string getmessage() to get the error message external user and write it to debug log. use list<string> getdisplaymessages() to get a list of errors displayed to the end user. this exception can’t be subclassed or thrown in code. 2753apex reference guide support namespace support namespace the support namespace provides an interface used for case feed. the following is the interface in the support namespace. in this section: emailtemplateselector interface the support.emailtemplateselector interface enables providing default email templates in case feed. with default email templates, specified email templates are preloaded for cases based on criteria such as case origin or subject. milestonetriggertimecalculator interface the support.milestonetriggertimecalculator interface calculates the time trigger for a milestone. emailtemplateselector interface the support.emailtemplateselector interface enables providing default email templates in case feed. with default email templates, specified email templates are preloaded for cases based on criteria such as case origin or subject. namespace support to specify default templates, you must create a class that implements support.emailtemplateselector. when you implement this interface, provide an empty parameterless constructor. in this section: emailtemplateselector methods emailtemplateselector example implementation emailtemplateselector methods the following are methods for emailtemplateselector. in this section: getdefaulttemplateid(caseid) returns the id of the email template to preload for the case currently being viewed in the case feed using the specified case id. getdefaulttemplateid(caseid) returns the id of the email template to preload for the case currently being viewed in the case feed using the specified case id. signature public id getdefaulttemplateid(id caseid) 2754apex reference guide emailtemplateselector interface parameters caseid type: id return value type: id emailtemplateselector example implementation this is an example implementation of the support.emailtemplateselector interface. the getdefaultemailtemplateid method implementation retrieves the subject and description of the case corresponding to the specified case id. next, it selects an email template based on the case subject and returns the email template id. global class mycasetemplatechooser implements support.emailtemplateselector { // empty constructor global mycasetemplatechooser() { } // the main interface method global id getdefaultemailtemplateid(id caseid) { // select the case we're interested in, choosing any fields that are relevant to our decision case c = [select subject, description from case where id=:caseid]; emailtemplate et; if (c.subject.contains('lx-1150')) { et = [select id from emailtemplate where developername = 'lx1150_template']; } else if(
c.subject.contains('lx-1220')) { et = [select id from emailtemplate where developername = 'lx1220_template']; } // return the id of the template selected return et.id; } } the following example tests the above code: @istest private class mycasetemplatechoosertest { static testmethod void testchoosetemplate() { mycasetemplatechooser chooser = new mycasetemplatechooser(); // create a simulated case to test with case c = new case(); c.subject = 'i\'m having trouble with my lx-1150'; database.insert(c); // make sure the proper template is chosen for this subject id actualtemplateid = chooser.getdefaultemailtemplateid(c.id); 2755apex reference guide milestonetriggertimecalculator interface emailtemplate expectedtemplate = [select id from emailtemplate where developername = 'lx1150_template']; id expectedtemplateid = expectedtemplate.id; system.assertequals(actualtemplateid, expectedtemplateid); // change the case properties to match a different template c.subject = 'my lx1220 is overheating'; database.update(c); // make sure the correct template is chosen in this case actualtemplateid = chooser.getdefaultemailtemplateid(c.id); expectedtemplate = [select id from emailtemplate where developername = 'lx1220_template']; expectedtemplateid = expectedtemplate.id; system.assertequals(actualtemplateid, expectedtemplateid); } } milestonetriggertimecalculator interface the support.milestonetriggertimecalculator interface calculates the time trigger for a milestone. namespace support implement the support.milestonetriggertimecalculator interface to calculate a dynamic time trigger for a milestone based on the milestone type, the properties of the case, and case-related objects. to implement the support.milestonetriggertimecalculator interface, you must first declare a class with the implements keyword as follows: global class employee implements support.milestonetriggertimecalculator { next, your class must provide an implementation for the following method: global integer calculatemilestonetriggertime(string caseid, string milestonetypeid) the implemented method must be declared as global or public. in this section: milestonetriggertimecalculator methods milestonetriggertimecalculator example implementation milestonetriggertimecalculator methods the following are instance methods for milestonetriggertimecalculator. 2756apex reference guide milestonetriggertimecalculator interface in this section: calculatemilestonetriggertime(caseid, milestonetypeid) calculates the milestone trigger time based on the specified case and milestone type and returns the time in minutes. calculatemilestonetriggertime(caseid, milestonetypeid) calculates the milestone trigger time based on the specified case and milestone type and returns the time in minutes. syntax public integer calculatemilestonetriggertime(string caseid, string milestonetypeid) parameters caseid type: string id of the case the milestone is applied to. milestonetypeid type: string id of the milestone type. return value type: integer the calculated trigger time in minutes. milestonetriggertimecalculator example implementation this sample class demonstrates the implementation of thesupport.milestonetriggertimecalculator interface. in this sample, the case’s priority and the milestone m1 determine that the time trigger is 18 minutes. global class mymilestonetimecalculator implements support.milestonetriggertimecalculator { global integer calculatemilestonetriggertime(string caseid, string milestonetypeid){ case c = [select priority from case where id=:caseid]; milestonetype mt = [select name from milestonetype where id=:milestonetypeid]; if (c.priority != null && c.priority.equals('high')){ if (mt.name != null && mt.name.equals('m1')) { return 7;} else { return 5; } } else { return 18; } } } 2757apex reference guide system namespace this test class can be used to test the implementation of support.milestonetriggertimecalculator. @istest private class milestonetimecalculatortest { static testmethod void testmilestonetimecalculator() { // select an existing milestone type to test with milestonetype[] mtlst =
[select id, name from milestonetype limit 1]; if(mtlst.size() == 0) { return; } milestonetype mt = mtlst[0]; // create case data. // typically, the milestone type is related to the case, // but for simplicity, the case is created separately for this test. case c = new case(priority = 'high'); insert c; mymilestonetimecalculator calculator = new mymilestonetimecalculator(); integer actualtriggertime = calculator.calculatemilestonetriggertime(c.id, mt.id); if(mt.name != null && mt.name.equals('m1')) { system.assertequals(actualtriggertime, 7); } else { system.assertequals(actualtriggertime, 5); } c.priority = 'low'; update c; actualtriggertime = calculator.calculatemilestonetriggertime(c.id, mt.id); system.assertequals(actualtriggertime, 18); } } system namespace the system namespace provides classes and methods for core apex functionality. the following are the classes in the system namespace. in this section: accesslevel class defines the different modes, such as system or user mode, that apex database operations execute in. accesstype enum specifies the access check type for the fields of an sobject. address class contains methods for accessing the component fields of address compound fields. answers class represents zone answers. 2758apex reference guide system namespace apexpages class use apexpages to add and check for messages associated with the current page, as well as to reference the current page. approval class contains methods for processing approval requests and setting approval-process locks and unlocks on records. assert class contains methods to assert various conditions with test methods, such as whether two values are the same, a condition is true, or a variable is null. asyncinfo class provides methods to get the current stack depth, maximum stack depth, and the minimum queueable delay for queueable transactions, and to determine if maximum stack depth is set. asyncoptions class contains maximum stack depths for queueable transactions and the minimum queueable delay in minutes. passed as parameter to the system.enqueuejob() method to define the maximum stack depth for queueable transactions and the minimum queueable delay in minutes. blob class contains methods for the blob primitive data type. boolean class contains methods for the boolean primitive data type. businesshours class use the businesshours methods to set the business hours at which your customer support team operates. callable interface enables developers to use a common interface to build loosely coupled integrations between apex classes or triggers, even for code in separate packages. agreeing upon a common interface enables developers from different companies or different departments to build upon one another’s solutions. implement this interface to enable the broader community, which might have different solutions than the ones you had in mind, to extend your code’s functionality. cases class use the cases class to interact with case records. comparable interface adds sorting support for lists that contain non-primitive types, that is, lists of user-defined types. continuation class use the continuation class to make callouts asynchronously to a soap or rest web service. cookie class the cookie class lets you access cookies for your salesforce site using apex. crypto class provides methods for creating digests, message authentication codes, and signatures, as well as encrypting and decrypting information. custom metadata type methods custom metadata types are customizable, deployable, packageable, and upgradeable application metadata. all custom metadata is exposed in the application cache, which allows access without repeated queries to the database. the metadata is then available for formula fields, validation rules, flows, apex, and soap api. all methods are static. 2759apex reference guide system namespace custom settings methods custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. all custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. this data is then available for formula fields, validation rules, flows, apex, and the soap api. database class contains methods for creating and manipulating data. date class contains methods for the date primitive data type. datetime class contains methods for the dat
etime primitive data type. decimal class contains methods for the decimal primitive data type. domain class represents an existing domain hosted by salesforce that serves the org or its content. contains methods to obtain information about these domains, such as the domain type, my domain name, and sandbox name. domaincreator class use the domaincreator class to return a hostname specific to the org. for example, get the org’s visualforce hostname. values are returned as a hostname, such as mydomainname.lightning.force.com. domainparser class use the domainparser class to parse a domain that salesforce hosts for the org and extract information about the domain. domaintype enum specifies the domain type for a system.domain. double class contains methods for the double primitive data type. emailmessages class use the methods in the emailmessages class to interact with emails and email threading. encodingutil class use the methods in the encodingutil class to encode and decode url strings, and convert strings to hexadecimal format. enum methods an enum is an abstract data type with values that each take on exactly one of a finite set of identifiers that you specify. apex provides built-in enums, such as logginglevel, and you can define your own enum. eventbus class contains methods for publishing platform events. exception class and built-in exceptions an exception denotes an error that disrupts the normal flow of code execution. you can use apex built-in exceptions or create custom exceptions. all exceptions have common methods. flexqueue class contains methods that reorder batch jobs in the apex flex queue. featuremanagement class use the methods in the system.featuremanagement class to check and modify the values of feature parameters, and to show or hide custom objects and custom permissions in your subscribers’ orgs. 2760apex reference guide system namespace formula class contains the recalculateformulas method that updates (recalculates) all formula fields on the input sobjects. formularecalcfielderror class the return type of the formularecalcresult.geterrors method. formularecalcresult class the return type of the formula.recalculateformulas method. http class use the http class to initiate an http request and response. httpcalloutmock interface enables sending fake responses when testing http callouts. httprequest class use the httprequest class to programmatically create http requests like get, post, patch, put, and delete. httpresponse class use the httpresponse class to handle the http response returned by the http class. id class contains methods for the id primitive data type. ideas class represents zone ideas. installhandler interface enables custom code to run after a managed package installation or upgrade. integer class contains methods for the integer primitive data type. json class contains methods for serializing apex objects into json format and deserializing json content that was serialized using the serialize method in this class. jsongenerator class contains methods used to serialize objects into json content using the standard json encoding. jsonparser class represents a parser for json-encoded content. jsontoken enum contains all token values used for parsing json content. label class provides methods to retrieve a custom label or to check if translation exists for a label in a specific language and namespace. label names are dynamically resolved at run time, overriding the user’s current language if a translation exists for the requested language. you can’t access labels that are protected in a different namespace. limits class contains methods that return limit information for specific resources. list class contains methods for the list collection type. location class contains methods for accessing the component fields of geolocation compound fields. 2761apex reference guide system namespace logginglevel enum specifies the logging level for the system.debug method. long class contains methods for the long primitive data type. map class contains methods for the map collection type. matcher class matchers use patterns to perform match operations on a character string. math class contains methods for mathematical operations. messaging class contains messaging methods used when sending a single or mass email. multistaticresourcecalloutmock class utility class used to specify a fake response using multiple resources for testing http callouts. network class manage experience cloud sites. orglimit class contains methods that provide the name, maximum value
, and current value of an org limit. orglimits class contains methods that provide a list or map of all orglimit instances for salesforce your org, such as soap api requests, bulk api requests, and streaming api limits. pagereference class a pagereference is a reference to an instantiation of a page. among other attributes, pagereferences consist of a url and a set of query parameter names and values. packaging class contains a method for obtaining information about managed and unlocked packages. pattern class represents a compiled representation of a regular expression. queueable interface enables the asynchronous execution of apex jobs that can be monitored. queueablecontext interface represents the parameter type of the execute() method in a class that implements the queueable interface and contains the job id. this interface is implemented internally by apex. quickaction class use apex to request and process actions on objects that allow custom fields, on objects that appear in a chatter feed, or on objects that are available globally. quiddity enum specifies a quiddity value used by the methods in the system.request class remoteobjectcontroller use remoteobjectcontroller to access the standard visualforce remote objects operations in your remote objects override methods. 2762apex reference guide system namespace request class contains methods to obtain the request id and quiddity value of the current salesforce request. resetpasswordresult class represents the result of a password reset. restcontext class contains the restrequest and restresponse objects. restrequest class use the system.restrequest class to access and pass request data in a restful apex method. restresponse class represents an object used to pass data from an apex restful web service method to an http response. sandboxpostcopy interface to make your sandbox environment business ready, automate data manipulation or business logic tasks. extend this interface and add methods to perform post-copy tasks, then specify the class during sandbox creation. schedulable interface the class that implements this interface can be scheduled to run at different intervals. schedulablecontext interface represents the parameter type of a method in a class that implements the schedulable interface and contains the scheduled job id. this interface is implemented internally by apex. schema class contains methods for obtaining schema describe information. search class use the methods of the search class to perform dynamic sosl queries. security class contains methods to securely implement apex applications. selectoption class a selectoption object specifies one of the possible values for a visualforce selectcheckboxes, selectlist, or selectradio component. set class represents a collection of unique elements with no duplicate values. site class use the site class to manage your sites. change, reset, validate, and check the expiration of passwords. create site users, person accounts, and portal users. get the admin email and id. get various urls, the path prefix, the id, the template, and the type of the site. log in to the site. sobject class contains methods for the sobject data type. sobjectaccessdecision class contains the results of a call to the security.stripinaccessible method and methods to retrieve those results. staticresourcecalloutmock class utility class used to specify a fake response for testing http callouts. string class contains methods for the string primitive data type. 2763apex reference guide system namespace stubprovider interface stubprovider is a callback interface that you can use as part of the apex stub api to implement a mocking framework. use this interface with the test.createstub() method to create stubbed apex objects for testing. system class contains methods for system operations, such as writing debug messages and scheduling jobs. test class contains methods related to apex tests. time class contains methods for the time primitive data type. timezone class represents a time zone. contains methods for creating a new time zone and obtaining time zone properties, such as the time zone id, offset, and display name. trigger class use the trigger class to access run-time context information in a trigger, such as the type of trigger or the list of sobject records that the trigger operates on. triggeroperation enum system.triggeroperation enum values are associated with trigger events. type class contains methods for getting the apex type that corresponds to an apex class and for instantiating new types. uninstallhandler interface enables custom code to run after a managed package is uninstalled. url class represents a uniform resource locator (url) and provides access to parts of the url. enables access
to the base url used to access your salesforce org. userinfo class contains methods for obtaining information about the context user. usermanagement class contains methods to manage end users, for example, to register their verification methods, verify their identity, or remove their personal information. version class use the version methods to get the version of a first-generation managed package, and to compare package versions. webservicecallout class enables making callouts to soap operations on an external web service. this class is used in the apex stub class that is auto-generated from a wsdl. webservicemock interface enables sending fake responses when testing web service callouts of a class auto-generated from a wsdl. xmlstreamreader class the xmlstreamreader class provides methods for forward, read-only access to xml data. you can pull data from xml or skip unwanted events. you can parse nested xml content that’s up to 50 nodes deep. xmlstreamwriter class the xmlstreamwriter class provides methods for writing xml data. 2764apex reference guide accesslevel class accesslevel class defines the different modes, such as system or user mode, that apex database operations execute in. namespace system usage by default, apex code runs in system mode, which means that it runs with substantially elevated permissions over the user running the code. in system mode, the object and field-level permissions of the current user are ignored, and the record sharing rules are controlled by the class sharing keywords. in user mode, the current user's object permissions, field-level security, and sharing rules are enforced. many of the dml methods of the system.database and system.search classes include an accesslevel parameter to specify the execution mode. example if the user running this apex code doesn't have write access to the account object, the database.insert() method returns an error. list<account> toinsert = new list<account>{new account(name = 'exciting new account')}; list<database.saveresult> sr = database.insert(toinsert, accesslevel.user_mode); in contrast, this example shows the method running in system mode. the success of the insert doesn't depend on whether the user running the apex code has create access to the account object. list<account> toinsert = new list<account>{new account(name = 'exciting new account')}; list<database.saveresult> sr = database.insert(toinsert, accesslevel.system_mode); in this section: accesslevel properties accesslevel properties the following are properties for accesslevel. in this section: system_mode execution mode in which the the object and field-level permissions of the current user are ignored, and the record sharing rules are controlled by the class sharing keywords. user_mode execution mode in which the object permissions, field-level security, and sharing rules of the current user are enforced. 2765apex reference guide accesstype enum system_mode execution mode in which the the object and field-level permissions of the current user are ignored, and the record sharing rules are controlled by the class sharing keywords. signature public system.accesslevel system_mode {get;} property value type: system.accesslevel user_mode execution mode in which the object permissions, field-level security, and sharing rules of the current user are enforced. signature public system.accesslevel user_mode {get;} property value type: system.accesslevel accesstype enum specifies the access check type for the fields of an sobject. usage use these enum values for the accesschecktype parameter of the stripinaccessible method. enum values the following are the values of the system.accesstype enum. value description creatable check the fields of an sobject for create access. readable check the fields of an sobject for read access. updatable check the fields of an sobject for update access. upsertable check the fields of an sobject for both insert and update access. address class contains methods for accessing the component fields of address compound fields. 2766apex reference guide address class namespace system usage each of these methods is also equivalent to a read-only property. for each getter method, you can access the property using dot notation. for example, myaddress.getcity() is equivalent to myaddress.city. you can’t use dot notation to access compound fields’ subfields directly on the parent field. instead, assign the parent field
to a variable of type address, and then access its components. for example, to access the city field in myaccount.billingaddress, do the following: address addr = myaccount.billingaddress; string acctcity = addr.city; important: “address” in salesforce can also refer to the address standard object. when referencing the address object in your apex code, always use schema.address instead of address to prevent confusion with the standard address compound field. if referencing both the address object and the address standard field in the same snippet, you can differentiate between the two by using system.address for the field and schema.address for the object. example // select and access address fields. // call the getdistance() method in different ways. account[] records = [select id, billingaddress from account limit 10]; for(account acct : records) { address addr = acct.billingaddress; double lat = addr.latitude; double lon = addr.longitude; location loc1 = location.newinstance(30.1944,-97.6682); double apexdist1 = addr.getdistance(loc1, 'mi'); double apexdist2 = loc1.getdistance(addr, 'mi'); system.assertequals(apexdist1, apexdist2); double apexdist3 = location.getdistance(addr, loc1, 'mi'); system.assertequals(apexdist2, apexdist3); } in this section: address methods address methods the following are methods for address. in this section: getcity() returns the city field of this address. 2767apex reference guide address class getcountry() returns the text-only country/territory name component of this address. getcountrycode() returns the country/territory code of this address if state and country/territory picklists are enabled in your organization. otherwise, returns null. getdistance(tolocation, unit) returns the distance from this location to the specified location using the specified unit. getgeocodeaccuracy() when using geolocation data for a given address, this method gives you relative location information based on latitude and longitude values. for example, you can find out if the latitude and longitude values point to the middle of the street, instead of the exact address. getlatitude() returns the latitude field of this address. getlongitude() returns the longitude field of this address. getpostalcode() returns the postal code of this address. getstate() returns the text-only state name component of this address. getstatecode() returns the state code of this address if state and country/territory picklists are enabled in your organization. otherwise, returns null. getstreet() returns the street field of this address. getcity() returns the city field of this address. signature public string getcity() return value type: string getcountry() returns the text-only country/territory name component of this address. signature public string getcountry() 2768apex reference guide address class return value type: string getcountrycode() returns the country/territory code of this address if state and country/territory picklists are enabled in your organization. otherwise, returns null. signature public string getcountrycode() return value type: string getdistance(tolocation, unit) returns the distance from this location to the specified location using the specified unit. signature public double getdistance(location tolocation, string unit) parameters tolocation type: location the location to which you want to calculate the distance from the current location. unit type: string the distance unit you want to use: mi or km. return value type: double getgeocodeaccuracy() when using geolocation data for a given address, this method gives you relative location information based on latitude and longitude values. for example, you can find out if the latitude and longitude values point to the middle of the street, instead of the exact address. signature public string getgeocodeaccuracy() return value type: string 2769apex reference guide address class the getgeocodeaccuracy() return value tells you more about the location at a latitude and longitude for a given address. for example, zip means the latitude and longitude point to the center of the zip code area, in case a match for an exact street address can’t be found
. accuracy value description address in the same building nearaddress near the address block midway point of the block street midway point of the street extendedzip center of the extended zip code area zip center of the zip code area neighborhood center of the neighborhood city center of the city county center of the county state center of the state unknown no match for the address was found geocodes are added only for some standard addresses. • billing address on accounts • shipping address on accounts • mailing address on contacts • address on leads person accounts are not supported. note: for getgeocodeaccuracy() to work, set up and activate the geocode data integration rules for the related address fields. getlatitude() returns the latitude field of this address. signature public double getlatitude() return value type: double 2770apex reference guide address class getlongitude() returns the longitude field of this address. signature public double getlongitude() return value type: double getpostalcode() returns the postal code of this address. signature public string getpostalcode() return value type: string getstate() returns the text-only state name component of this address. signature public string getstate() return value type: string getstatecode() returns the state code of this address if state and country/territory picklists are enabled in your organization. otherwise, returns null. signature public string getstatecode() return value type: string getstreet() returns the street field of this address. 2771apex reference guide answers class signature public string getstreet() return value type: string answers class represents zone answers. namespace system usage answers is a feature that enables users to ask questions and have zone members post replies. members can then vote on the helpfulness of each reply, and the person who asked the question can mark one reply as the best answer. for more information on answers, see “answers overview” in the salesforce online help. example the following example finds questions in an internal zone that have similar titles as a new question: public class findsimilarquestioncontroller { public static void test() { // instantiate a new question question question = new question (); // specify a title for the new question question.title = 'how much vacation time do full-time employees get?'; // specify the communityid (internal_community) in which to find similar questions. community community = [ select id from community where name = 'internal_community' ]; question.communityid = community.id; id[] results = answers.findsimilar(question); } } the following example marks a reply as the best reply: id questionid = [select id from question where title = 'testing setbestreplyid' limit 1].id; id replyid = [select id from reply where questionid = :questionid limit 1].id; answers.setbestreply(questionid,replyid); 2772apex reference guide answers class answers methods the following are methods for answers. all methods are static. in this section: findsimilar(yourquestion) returns a list of similar questions based on the title of the specified question. setbestreply(questionid, replyid) sets the specified reply for the specified question as the best reply. because a question can have multiple replies, setting the best reply helps users quickly identify the reply that contains the most helpful information. findsimilar(yourquestion) returns a list of similar questions based on the title of the specified question. signature public static id[] findsimilar(question yourquestion) parameters yourquestion type: question return value type: id[] usage each findsimilar call counts against the sosl statements governor limit allowed for the process. setbestreply(questionid, replyid) sets the specified reply for the specified question as the best reply. because a question can have multiple replies, setting the best reply helps users quickly identify the reply that contains the most helpful information. signature public static void setbestreply(string questionid, string replyid) parameters questionid type: string replyid type: string 2773apex reference guide apexpages class return value type: void apexpages class use apexpages to add and check for messages associated with the current page, as well as to reference the current page. names
pace system usage in addition, apexpages is used as a namespace for the pagereference class and the message class. apexpages methods the following are methods for apexpages. all are instance methods. in this section: addmessage(message) add a message to the current page context. addmessages(exceptionthrown) adds a list of messages to the current page context based on a thrown exception. currentpage() returns the current page's pagereference. getmessages() returns a list of the messages associated with the current context. hasmessages() returns true if there are messages associated with the current context, false otherwise. hasmessages(severity) returns true if messages of the specified severity exist, false otherwise. addmessage(message) add a message to the current page context. signature public void addmessage(apexpages.message message) parameters message type: apexpages.message 2774apex reference guide apexpages class return value type: void addmessages(exceptionthrown) adds a list of messages to the current page context based on a thrown exception. signature public void addmessages(exception exceptionthrown) parameters exceptionthrown type: exception return value type: void currentpage() returns the current page's pagereference. signature public system.pagereference currentpage() return value type: system.pagereference example this code segment returns the id parameter of the current page. public mycontroller() { account = [ select id, name, site from account where id = :apexpages.currentpage(). getparameters(). get('id') ]; } getmessages() returns a list of the messages associated with the current context. 2775apex reference guide approval class signature public apexpages.message[] getmessages() return value type: apexpages.message[] hasmessages() returns true if there are messages associated with the current context, false otherwise. signature public boolean hasmessages() return value type: boolean hasmessages(severity) returns true if messages of the specified severity exist, false otherwise. signature public boolean hasmessages(apexpages.severity severity) parameters sev type: apexpages.severity return value type: boolean approval class contains methods for processing approval requests and setting approval-process locks and unlocks on records. namespace system usage salesforce admins can edit locked records. depending on your approval process configuration settings, an assigned approver can also edit locked records. locks and unlocks that are set programmatically use the same record editability settings as other approval-process locks and unlocks. 2776apex reference guide approval class record locks and unlocks are treated as dml. they’re blocked before a callout, they count toward your dml limits, and if a failure occurs, they’re rolled back along with the rest of your transaction. to change this rollback behavior, use an allornone parameter. approval is also used as a namespace for the processrequest and processresult classes. see also: approval process considerations approval methods the following are methods for approval. all methods are static. in this section: islocked(id) returns true if the record with the id id is locked, or false if it’s not. islocked(ids) returns a map of record ids and their lock statuses. if the record is locked the status is true. if the record is not locked the status is false. islocked(sobject) returns true if the sobject record is locked, or false if it’s not. islocked(sobjects) returns a map of record ids to lock statuses. if the record is locked the status is true. if the record is not locked the status is false. lock(recordid) locks an object, and returns the lock results. lock(recordids) locks a set of objects, and returns the lock results, including failures. lock(recordtolock) locks an object, and returns the lock results. lock(recordstolock) locks a set of objects, and returns the lock results, including failures. lock(recordid, allornothing) locks an object, with the option for partial success, and returns the lock result. lock(recordids, allornothing) locks a set
of objects, with the option for partial success. it returns the lock results, including failures. lock(recordtolock, allornothing) locks an object, with the option for partial success, and returns the lock result. lock(recordstolock, allornothing) locks a set of objects, with the option for partial success. it returns the lock results, including failures. process(approvalrequest) submits a new approval request and approves or rejects existing approval requests. process(approvalrequest, allornone) submits a new approval request and approves or rejects existing approval requests. 2777apex reference guide approval class process(approvalrequests) submits a list of new approval requests, and approves or rejects existing approval requests. process(approvalrequests, allornone) submits a list of new approval requests, and approves or rejects existing approval requests. unlock(recordid) unlocks an object, and returns the unlock results. unlock(recordids) unlocks a set of objects, and returns the unlock results, including failures. unlock(recordtounlock) unlocks an object, and returns the unlock results. unlock(recordstounlock) unlocks a set of objects, and returns the unlock results, including failures. unlock(recordid, allornothing) unlocks an object, with the option for partial success, and returns the unlock result. unlock(recordids, allornothing) unlocks a set of objects, with the option for partial success. it returns the unlock results, including failures. unlock(recordtounlock, allornothing) unlocks an object, with the option for partial success, and returns the unlock result. unlock(recordstounlock, allornothing) unlocks a set of objects, with the option for partial success. it returns the unlock results, including failures. islocked(id) returns true if the record with the id id is locked, or false if it’s not. signature public static boolean islocked(id id) parameters id type: id the id of the record whose lock or unlock status is in question. return value type: boolean islocked(ids) returns a map of record ids and their lock statuses. if the record is locked the status is true. if the record is not locked the status is false. 2778apex reference guide approval class signature public static map<id,boolean> islocked(list<id> ids) parameters ids type: list<id> the ids of the records whose lock or unlock statuses are in question. return value type: map<id,boolean> islocked(sobject) returns true if the sobject record is locked, or false if it’s not. signature public static boolean islocked(sobject sobject) parameters sobject type: sobject the record whose lock or unlock status is in question. return value type: boolean islocked(sobjects) returns a map of record ids to lock statuses. if the record is locked the status is true. if the record is not locked the status is false. signature public static map<id,boolean> islocked(list<sobject> sobjects) parameters sobjects type: list<sobject> the records whose lock or unlock statuses are in question. return value type: map<id,boolean> 2779apex reference guide approval class lock(recordid) locks an object, and returns the lock results. signature public static approval.lockresult lock(id recordid) parameters recordid type: id id of the object to lock. return value type: approval.lockresult lock(recordids) locks a set of objects, and returns the lock results, including failures. signature public static list<approval.lockresult> lock(list<id> ids) parameters ids type: list<id> ids of the objects to lock. return value type: list<approval.lockresult> lock(recordtolock) locks an object, and returns the lock results. signature public static approval.lockresult lock(sobject recordtolock) parameters recordtolock type: sobject 2780apex reference guide approval class return value type: approval.
lockresult lock(recordstolock) locks a set of objects, and returns the lock results, including failures. signature public static list<approval.lockresult> lock(list<sobject> recordstolock) parameters recordstolock type: list<sobject> return value type: list<approval.lockresult> lock(recordid, allornothing) locks an object, with the option for partial success, and returns the lock result. signature public static approval.lockresult lock(id recordid, boolean allornothing) parameters recordid type: id id of the object to lock. allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: approval.lockresult lock(recordids, allornothing) locks a set of objects, with the option for partial success. it returns the lock results, including failures. signature public static list<approval.lockresult> lock(list<id> recordids, boolean allornothing) 2781apex reference guide approval class parameters recordids type: list<id> ids of the objects to lock. allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: list<approval.lockresult> lock(recordtolock, allornothing) locks an object, with the option for partial success, and returns the lock result. signature public static approval.lockresult lock(sobject recordtolock, boolean allornothing) parameters recordtolock type: sobject allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: approval.lockresult lock(recordstolock, allornothing) locks a set of objects, with the option for partial success. it returns the lock results, including failures. signature public static list<approval.lockresult> lock(list<sobject> recordstolock, boolean allornothing) parameters recordstolock type: list<sobject> 2782
apex reference guide approval class allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: list<approval.lockresult> process(approvalrequest) submits a new approval request and approves or rejects existing approval requests. signature public static approval.processresult process(approval.processrequest approvalrequest) parameters approvalrequest type: approval.processrequest return value type: approval.processresult example // insert an account account a = new account(name='test', annualrevenue=100.0); insert a; // create an approval request for the account approval.processsubmitrequest req1 = new approval.processsubmitrequest(); req1.setobjectid(a.id); // submit the approval request for the account approval.processresult result = approval.process(req1); process(approvalrequest, allornone) submits a new approval request and approves or rejects existing approval requests. 2783apex reference guide approval class signature public static approval.processresult process(approval.processrequest approvalrequest, boolean allornone) parameters approvalrequest approval.processrequest allornone type: boolean the optional allornone parameter specifies whether the operation allows for partial success. if you specify false for this parameter and an approval fails, the remainder of the approval processes can still succeed. return value approval.processresult process(approvalrequests) submits a list of new approval requests, and approves or rejects existing approval requests. signature public static approval.processresult [] process(approval.processrequest[] approvalrequests) parameters approvalrequests approval.processrequest [] return value approval.processresult [] process(approvalrequests, allornone) submits a list of new approval requests, and approves or rejects existing approval requests. signature public static approval.processresult [] process(approval.processrequest[] approvalrequests, boolean allornone) parameters approvalrequests approval.processrequest [] 2784apex reference guide approval class allornone type: boolean the optional allornone parameter specifies whether the operation allows for partial success. if you specify false for this parameter and an approval fails, the remainder of the approval processes can still succeed. return value approval.processresult [] unlock(recordid) unlocks an object, and returns the unlock results. signature public static approval.unlockresult unlock(id recordid) parameters recordid type: id id of the object to unlock. return value type: approval.unlockresult unlock(recordids) unlocks a set of objects, and returns the unlock results, including failures. signature public static list<approval.unlockresult> unlock(list<id> recordids) parameters recordids type: list<id> ids of the objects to unlock. return value type: list<approval.unlockresult> unlock(recordtounlock) unlocks an object, and returns the unlock results. 2785apex reference guide approval class signature public static approval.unlockresult unlock(sobject recordtounlock) parameters recordtounlock type: sobject return value type: approval.unlockresult unlock(recordstounlock) unlocks a set of objects, and returns the unlock results, including failures. signature public static list<approval.unlockresult> unlock(list<sobject> recordstounlock) parameters recordstounlock type: list<sobject> return value type: list<approval.unlockresult> unlock(recordid, allornothing) unlocks an object, with the option for partial success, and returns the unlock result. signature public static approval.unlockresult unlock(id recordid, boolean allornothing) parameters recordid type: id id of the object to lock. allornothing type: boolean specifies whether this operation allows partial success. if you specify false and
a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. 2786apex reference guide approval class return value type: approval.unlockresult unlock(recordids, allornothing) unlocks a set of objects, with the option for partial success. it returns the unlock results, including failures. signature public static list<approval.unlockresult> unlock(list<id> recordids, boolean allornothing) parameters recordids type: list<id> ids of the objects to unlock. allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: list<approval.unlockresult> unlock(recordtounlock, allornothing) unlocks an object, with the option for partial success, and returns the unlock result. signature public static approval.unlockresult unlock(sobject recordtounlock, boolean allornothing) parameters recordtounlock type: sobject allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: approval.unlockresult 2787apex reference guide assert class unlock(recordstounlock, allornothing) unlocks a set of objects, with the option for partial success. it returns the unlock results, including failures. signature public static list<approval.unlockresult> unlock(list<sobject> recordstounlock, boolean allornothing) parameters recordstounlock type: list<sobject> allornothing type: boolean specifies whether this operation allows partial success. if you specify false and a record fails, the remainder of the dml operation can still succeed. this method returns a result object that you can use to verify which records succeeded, which failed, and why. return value type: list<approval.unlockresult> assert class contains methods to assert various conditions with test methods, such as whether two values are the same, a condition is true, or a variable is null. namespace system assert methods the following are methods for assert. in this section: areequal(expected, actual, msg) asserts that the first two arguments are the same. areequal(expected, actual) asserts that the two arguments are the same. arenotequal(notexpected, actual, msg) asserts that the first two arguments aren’t the same. arenotequal(notexpected, actual) asserts that the two arguments aren’t the same. fail(msg) immediately return a fatal error that causes code execution to halt. 2788apex reference guide assert class fail() immediately return a fatal error that causes code execution to halt. isfalse(condition, msg) asserts that the specified condition is false. isfalse(condition) asserts that the specified condition is false. isinstanceoftype(instance, expectedtype, msg) asserts that the instance is of the specified type. isinstanceoftype(instance, expectedtype) asserts that the instance is of the specified type. isnotinstanceoftype(instance, notexpectedtype, msg) asserts that the instance isn’t of the specified type. isnotinstanceoftype(instance, notexpectedtype) asserts that the instance isn’t of the specified type. isnotnull(value, msg) asserts that the value isn’t null. isnotnull(value) asserts that the value isn’t null. isnull(value, msg) asserts that the value is null. isnull(value) asserts that the value is null. istrue(condition, msg) asserts that the specified condition is true. istrue(condition) asserts that the specified condition is true. areequal(expected, actual, msg)
asserts that the first two arguments are the same. signature public static void areequal(object expected, object actual, string msg) parameters expected type: object expected value. actual type: object actual value. 2789apex reference guide assert class msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the first two arguments aren't the same, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string sub = 'abcde'.substring(2); assert.areequal('cde', sub, 'expected characters after first two'); // succeeds areequal(expected, actual) asserts that the two arguments are the same. signature public static void areequal(object expected, object actual) parameters expected type: object expected value. actual type: object actual value. return value type: void usage if the two arguments aren't the same, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string sub = 'abcde'.substring(2); assert.areequal('cde', sub); // succeeds 2790apex reference guide assert class arenotequal(notexpected, actual, msg) asserts that the first two arguments aren’t the same. signature public static void arenotequal(object notexpected, object actual, string msg) parameters notexpected type: object value that’s not expected. actual type: object actual value. msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the first two arguments are the same, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string sub = 'abcde'.substring(2); assert.arenotequal('xyz', sub, 'characters not expected after first two'); // succeeds arenotequal(notexpected, actual) asserts that the two arguments aren’t the same. signature public static void arenotequal(object notexpected, object actual) parameters notexpected type: object value that’s not expected. 2791apex reference guide assert class actual type: object actual value. return value type: void usage if the two arguments are the same, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string sub = 'abcde'.substring(2); assert.arenotequal('xyz', sub); // succeeds fail(msg) immediately return a fatal error that causes code execution to halt. signature public static void fail(string msg) parameters msg type: string (optional) custom message returned as part of the error message. return value type: void usage commonly used in a try/catch block test case where an exception is expected to be thrown. you can’t, however, catch the assertion failure in the try/catch block even though it’s logged as an exception. example // test case where exception is expected try { someclass.methodundertest(); assert.fail('dmlexception expected'); } catch (dmlexception ex) { 2792apex reference guide assert class // add assertions here about the expected exception } fail() immediately return a fatal error that causes code execution to halt. signature public static void fail() return value type: void usage commonly used in a try/catch block test case where an exception is expected to be thrown. you can’t, however, catch the assertion failure in the try/catch block even though it’s logged as an exception. example // test case where exception is expected try { someclass.methodundertest(); assert.fail(); } catch (dml
exception ex) { // add assertions here about the expected exception } isfalse(condition, msg) asserts that the specified condition is false. signature public static void isfalse(boolean condition, string msg) parameters condition type: boolean condition you’re checking to determine if it’s false. msg type: string (optional) custom message returned as part of the error message. 2793apex reference guide assert class return value type: void usage if the condition is true, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example boolean containscode = 'salesforce'.contains('code'); assert.isfalse(containscode, 'no code'); // assertion succeeds isfalse(condition) asserts that the specified condition is false. signature public static void isfalse(boolean condition) parameters condition type: boolean condition you’re checking to determine if it’s false. return value type: void usage if the condition is true, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example boolean containscode = 'salesforce'.contains('code'); assert.isfalse(containscode); // assertion succeeds isinstanceoftype(instance, expectedtype, msg) asserts that the instance is of the specified type. signature public static void isinstanceoftype(object instance, system.type expectedtype, string msg) 2794apex reference guide assert class parameters instance type: object instance whose type you're checking. expectedtype type: system.type on page 3473 expected type. msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the instance isn't of the specified type, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example account o = new account(); assert.isinstanceoftype(o, account.class); // succeeds isinstanceoftype(instance, expectedtype) asserts that the instance is of the specified type. signature public static void isinstanceoftype(object instance, system.type expectedtype) parameters instance type: object instance whose type you're checking. expectedtype type: system.type on page 3473 expected type. return value type: void 2795apex reference guide assert class usage if the instance isn't of the specified type, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example account o = new account(); assert.isinstanceoftype(o, account.class); // succeeds account o = new account(); assert.isinstanceoftype(o, account.class, 'expected type.'); // succeeds isnotinstanceoftype(instance, notexpectedtype, msg) asserts that the instance isn’t of the specified type. signature public static void isnotinstanceoftype(object instance, system.type notexpectedtype, string msg) parameters instance type: object instance whose type you're checking. notexpectedtype type: system.type on page 3473 type that's not expected. msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the instance is of the specified type, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example contact con = new contact(); assert.isnotinstanceoftype(con, account.class, 'not expected type'); // succeeds 2796apex reference guide assert class isnotinstanceoftype(instance, notexpectedtype) asserts that the instance isn’t of the specified type. signature public static void isnotinstanceoftype(object instance, system.type notexpectedtype)
parameters instance type: object instance whose type you're checking. notexpectedtype type: system.type on page 3473 type that's not expected. return value type: void usage if the instance is of the specified type, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example contact con = new contact(); assert.isnotinstanceoftype(con, account.class); // succeeds isnotnull(value, msg) asserts that the value isn’t null. signature public static void isnotnull(object value, string msg) parameters value type: object value you’re checking to determine if it’s not null. msg type: string (optional) custom message returned as part of the error message. 2797apex reference guide assert class return value type: void usage if the value is null, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string mystring = 'value'; assert.isnotnull(mystring, 'mystring should not be null'); // succeeds isnotnull(value) asserts that the value isn’t null. signature public static void isnotnull(object value) parameters value type: object value you’re checking to determine if it’s not null. return value type: void usage if the value is null, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string mystring = 'value'; assert.isnotnull(mystring); // succeeds isnull(value, msg) asserts that the value is null. signature public static void isnull(object value, string msg) 2798apex reference guide assert class parameters value type: object value you’re checking to determine if it’s null. msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the value isn't null, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example string mystring = null; assert.isnull(mystring, 'string should be null'); // succeeds isnull(value) asserts that the value is null. signature public static void isnull(object value) parameters value type: object value you’re checking to determine if it’s null. return value type: void usage if the value isn't null, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. 2799apex reference guide assert class example string mystring = null; assert.isnull(mystring); // succeeds istrue(condition, msg) asserts that the specified condition is true. signature public static void istrue(boolean condition, string msg) parameters condition type: boolean condition you’re checking to determine if it’s true. msg type: string (optional) custom message returned as part of the error message. return value type: void usage if the specified condition is false, a fatal error is returned that causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example boolean containsforce = 'salesforce'.contains('force'); assert.istrue(containsforce, 'contains force'); // assertion succeeds istrue(condition) asserts that the specified condition is true. signature public static void istrue(boolean condition) parameters condition type: boolean condition you’re checking to determine if it’s true. 2800apex reference guide asyncinfo class return value type: void usage if the specified condition is false, a fatal error is returned that
causes code execution to halt. you can’t catch an assertion failure using a try/catch block even though it’s logged as an exception. example boolean containsforce = 'salesforce'.contains('force'); assert.istrue(containsforce); // assertion succeeds asyncinfo class provides methods to get the current stack depth, maximum stack depth, and the minimum queueable delay for queueable transactions, and to determine if maximum stack depth is set. namespace system in this section: asyncinfo methods asyncinfo methods the following are methods for asyncinfo. in this section: getcurrentqueueablestackdepth() get the current queueable stack depth for queueable transactions. getmaximumqueueablestackdepth() get the maximum queueable stack depth for queueable transactions. getminimumqueueabledelayinminutes() get the minimum queueable delay for queueable transactions (in minutes). hasmaxstackdepth() determine if maximum stack depth is set for your queueable requests. getcurrentqueueablestackdepth() get the current queueable stack depth for queueable transactions. 2801apex reference guide asyncoptions class signature public static integer getcurrentqueueablestackdepth() return value type: integer getmaximumqueueablestackdepth() get the maximum queueable stack depth for queueable transactions. signature public static integer getmaximumqueueablestackdepth() return value type: integer getminimumqueueabledelayinminutes() get the minimum queueable delay for queueable transactions (in minutes). signature public static integer getminimumqueueabledelayinminutes() return value type: integer returns null if no delay is defined. hasmaxstackdepth() determine if maximum stack depth is set for your queueable requests. signature public static boolean hasmaxstackdepth() return value type: boolean asyncoptions class contains maximum stack depths for queueable transactions and the minimum queueable delay in minutes. passed as parameter to the system.enqueuejob() method to define the maximum stack depth for queueable transactions and the minimum queueable delay in minutes. 2802apex reference guide blob class namespace system in this section: asyncoptions properties asyncoptions properties the following are properties for asyncoptions. in this section: maximumqueueablestackdepth maximum stack depth for queueable transactions. minimumqueueabledelayinminutes minimum queueable delay for queueable transactions. maximumqueueablestackdepth maximum stack depth for queueable transactions. signature public integer maximumqueueablestackdepth {get; set;} property value type: integer minimumqueueabledelayinminutes minimum queueable delay for queueable transactions. signature public integer minimumqueueabledelayinminutes {get; set;} property value type: integer blob class contains methods for the blob primitive data type. namespace system 2803apex reference guide blob class usage for more information on blobs, see primitive data types. blob methods the following are methods for blob. in this section: size() returns the number of characters in the blob. topdf(stringtoconvert) creates a binary object out of the given string, encoding it as a pdf file. tostring() casts the blob into a string. valueof(stringtoblob) casts the specified string to a blob. size() returns the number of characters in the blob. signature public integer size() return value type: integer example string mystring = 'stringtoblob'; blob myblob = blob.valueof(mystring); integer size = myblob.size(); topdf(stringtoconvert) creates a binary object out of the given string, encoding it as a pdf file. signature public static blob topdf(string stringtoconvert) parameters stringtoconvert type: string 2804apex reference guide blob class note: referencing a static resource throws an invalidparametervalue exception. return value type: blob example string pdfcontent = 'this is a test string'; account a = new account(name = 'test'); insert a; attachment attachmentpdf = new attachment(); attachmentpdf.parentid = a.id; attachmentpdf.name = a.name + '.pdf'; attachmentpdf.body = blob.to
pdf(pdfcontent); insert attachmentpdf; tostring() casts the blob into a string. signature public string tostring() return value type: string example string mystring = 'stringtoblob'; blob myblob = blob.valueof(mystring); system.assertequals('stringtoblob', myblob.tostring()); valueof(stringtoblob) casts the specified string to a blob. signature public static blob valueof(string stringtoblob) parameters stringtoblob type: string 2805apex reference guide boolean class return value type: blob example string mystring = 'stringtoblob'; blob myblob = blob.valueof(mystring); boolean class contains methods for the boolean primitive data type. namespace system boolean methods the following are methods for boolean. all methods are static. in this section: valueof(stringtoboolean) converts the specified string to a boolean value and returns true if the specified string value is true. otherwise, returns false. valueof(fieldvalue) converts the specified object to a boolean value. use this method to convert a history tracking field value or an object that represents a boolean value. valueof(stringtoboolean) converts the specified string to a boolean value and returns true if the specified string value is true. otherwise, returns false. signature public static boolean valueof(string stringtoboolean) parameters stringtoboolean type: string return value type: boolean usage if the specified argument is null, this method throws an exception. 2806apex reference guide businesshours class example boolean b = boolean.valueof('true'); system.assertequals(true, b); valueof(fieldvalue) converts the specified object to a boolean value. use this method to convert a history tracking field value or an object that represents a boolean value. signature public static boolean valueof(object fieldvalue) parameters fieldvalue type: object return value type: boolean usage use this method with the oldvalue or newvalue fields of history sobjects, such as accounthistory, when the field type corresponds to a boolean type, like a checkbox field. example list<accounthistory> ahlist = [select field,oldvalue,newvalue from accounthistory]; for(accounthistory ah : ahlist) { system.debug('field: ' + ah.field); if (ah.field == 'isplatinum__c') { boolean oldvalue = boolean.valueof(ah.oldvalue); boolean newvalue = boolean.valueof(ah.newvalue); } businesshours class use the businesshours methods to set the business hours at which your customer support team operates. namespace system 2807apex reference guide businesshours class businesshours methods the following are methods for businesshours. all methods are static. in this section: add(businesshoursid, startdate, intervalmilliseconds) adds an interval of time from a start datetime traversing business hours only. returns the result datetime in the local time zone. addgmt(businesshoursid, startdate, intervalmilliseconds) adds an interval of milliseconds from a start datetime traversing business hours only. returns the result datetime in gmt. diff(businesshoursid, startdate, enddate) returns the difference in milliseconds between a start and end datetime based on a specific set of business hours. iswithin(businesshoursid, targetdate) returns true if the specified target date occurs within business hours. holidays are included in the calculation. nextstartdate(businesshoursid, targetdate) starting from the specified target date, returns the next date when business hours are open. if the specified target date falls within business hours, this target date is returned. add(businesshoursid, startdate, intervalmilliseconds) adds an interval of time from a start datetime traversing business hours only. returns the result datetime in the local time zone. signature public static datetime add(string businesshoursid, datetime startdate, long intervalmilliseconds) parameters businesshoursid type: string startdate type: datetime intervalmilliseconds type: long interval value should be provided in milliseconds, however time precision smaller than one minute is ignored. return value type: datetime addgmt
(businesshoursid, startdate, intervalmilliseconds) adds an interval of milliseconds from a start datetime traversing business hours only. returns the result datetime in gmt. 2808apex reference guide businesshours class signature public static datetime addgmt(string businesshoursid, datetime startdate, long intervalmilliseconds) parameters businesshoursid type: string startdate type: datetime intervalmilliseconds type: long return value type: datetime diff(businesshoursid, startdate, enddate) returns the difference in milliseconds between a start and end datetime based on a specific set of business hours. signature public static long diff(string businesshoursid, datetime startdate, datetime enddate) parameters businesshoursid type: string startdate type: datetime enddate type: datetime return value type: long iswithin(businesshoursid, targetdate) returns true if the specified target date occurs within business hours. holidays are included in the calculation. signature public static boolean iswithin(string businesshoursid, datetime targetdate) 2809apex reference guide businesshours class parameters businesshoursid type: string the business hours id. targetdate type: datetime the date to verify. return value type: boolean example the following example finds whether a given time is within the default business hours. // get the default business hours businesshours bh = [select id from businesshours where isdefault=true]; // create datetime on may 28, 2013 at 1:06:08 am in the local timezone. datetime targettime = datetime.newinstance(2013, 5, 28, 1, 6, 8); // find whether the time is within the default business hours boolean iswithin= businesshours.iswithin(bh.id, targettime); nextstartdate(businesshoursid, targetdate) starting from the specified target date, returns the next date when business hours are open. if the specified target date falls within business hours, this target date is returned. signature public static datetime nextstartdate(string businesshoursid, datetime targetdate) parameters businesshoursid type: string the business hours id. targetdate type: datetime the date used as a start date to obtain the next date. return value type: datetime 2810apex reference guide callable interface example the following example finds the next date starting from the target date when business hours reopens. if the target date is within the given business hours, the target date is returned. the returned time is in the local time zone. // get the default business hours businesshours bh = [select id from businesshours where isdefault=true]; // create datetime on may 28, 2013 at 1:06:08 am in the local timezone. datetime targettime = datetime.newinstance(2013, 5, 28, 1, 6, 8); // starting from the targettime, find the next date when business hours reopens. return the target time. // if it is within the business hours. the returned time will be in the local time zone datetime nextstart = businesshours.nextstartdate(bh.id, targettime); callable interface enables developers to use a common interface to build loosely coupled integrations between apex classes or triggers, even for code in separate packages. agreeing upon a common interface enables developers from different companies or different departments to build upon one another’s solutions. implement this interface to enable the broader community, which might have different solutions than the ones you had in mind, to extend your code’s functionality. note: this interface is not an analog of the java callable interface, which is used for asynchronous invocation. don’t confuse the two. namespace system usage to implement the callable interface, you need to write only one method: call(string action, map<string, object> args). in code that utilizes or tests an implementation of callable, cast an instance of your type to callable. this interface is not intended to replace defining more specific interfaces. rather, the callable interface allows integrations in which code from different classes or packages can use common base types. in this section: callable methods callable example implementation callable methods the following are methods for callable. 2811apex reference guide callable interface in this section: call(action, args) provides functionality that other classes or packages can utilize and build upon. call
(action, args) provides functionality that other classes or packages can utilize and build upon. signature public object call(string action, map<string,object> args) parameters action type: string the behavior for the method to exhibit. args type: map on page 3144<string,object> arguments to be used by the specified action. return value type: object the result of the method invocation. callable example implementation this class is an example implementation of the system.callable interface. public class extension implements callable { // actual method string concatstrings(string stringvalue) { return stringvalue + stringvalue; } // actual method decimal multiplynumbers(decimal decimalvalue) { return decimalvalue * decimalvalue; } // dispatch actual methods public object call(string action, map<string, object> args) { switch on action { when 'concatstrings' { return this.concatstrings((string)args.get('stringvalue')); } when 'multiplynumbers' { return this.multiplynumbers((decimal)args.get('decimalvalue')); 2812apex reference guide cases class } when else { throw new extensionmalformedcallexception('method not implemented'); } } } public class extensionmalformedcallexception extends exception {} } the following test code illustrates how calling code utilizes the interface to call a method. @istest private with sharing class extensioncaller { @istest private static void givenconfiguredextensionwhencalledthenvalidresult() { // given string extensionclass = 'extension'; // typically set via configuration decimal decimaltestvalue = 10; // when callable extension = (callable) type.forname(extensionclass).newinstance(); decimal result = (decimal) extension.call('multiplynumbers', new map<string, object> { 'decimalvalue' => decimaltestvalue }); // then system.assertequals(100, result); } } see also: apex developer guide: classes and casting cases class use the cases class to interact with case records. namespace system cases methods the following are static methods for cases. 2813apex reference guide cases class in this section: generatethreadingmessageid(caseid) returns an rfc 2822-compliant message identifier that contains information used to match the email and its replies to a case. getcaseidfromemailheaders(headers) returns the case id corresponding to the specified email header information, or returns null if none is found. getcaseidfromemailthreadid(emailthreadid) returns the case id corresponding to the specified email thread id. (deprecated. use getcaseidfromemailheaders and emailmessages.getrecordidfromemail instead.) generatethreadingmessageid(caseid) returns an rfc 2822-compliant message identifier that contains information used to match the email and its replies to a case. signature public static string generatethreadingmessageid(id caseid) parameters caseid type: id the case sobject id to which replies to this email should be attached. return value type: string usage use the returned message identifier when sending case-related emails in apex. the returned message identifier can be used in message-id or references headers. however, because salesforce doesn’t let users specify the message-id, we set this identifier in the references header. when users reply to the sent email, replies should be attached to the specified case. example in this sample, we create an email with a message identifier so that the email and any responses can be associated with the related case. //get your case id. here we use a dummy id id caseid = id.valueof('500xx000000bpktaaq'); //create a singleemailmessage object messaging.singleemailmessage email = new messaging.singleemailmessage(); //set recipients and other fields email.settoaddresses(new string[] {'[email protected]'}); email.setplaintextbody('test email notification'); //........... more fields ........... //get the threading message identifier string messageid = cases.generatethreadingmessageid(caseid); //insert the message identifier into the references header email.setreferences(messageid); 2814apex reference guide cases class //send out the email messaging.sendemail(new messaging.singleemailmessage
[]{email}); getcaseidfromemailheaders(headers) returns the case id corresponding to the specified email header information, or returns null if none is found. signature public static id getcaseidfromemailheaders(list<messaging.inboundemail.header> headers) parameters headers type: list<messaging.inboundemail.header> return value type: id usage to optimize finding a match between email threads and cases in your custom code, we recommend that you use this method and emailmessages.getrecordidfromemail to implement a combination of token- and header-based threading. if you are transitioning from ref id threading, we recommend that you replace cases.getcaseidfromemailthreadid with a combination of cases.getcaseidfromemailheaders and emailmessages.getrecordidfromemail. if you choose to implement header-based threading only, replace cases.getcaseidfromemailthreadid with cases.getcaseidfromemailheaders. the headers argument is used to find the matching case id using values for the in-reply-to and references headers based on rfc 2822. if email-to-case can’t find any emails with a matching in-reply-to or references header, it also checks the incoming email for an outlook-specific header called thread-index. the first 22 bytes of this header uniquely identify the thread. if email-to-case detects a thread-index header on the incoming mail, it looks for matching information in the clientthreadidentifier field in emailmessage records. if a match is found, the customer’s reply email is linked to the related case. typically this method is used in email services so that you can provide your own handling of inbound emails using apex code. example if you implement header-based threading in your email services currently, we recommend that you use lightning threading, which combines token-based threading and header-based threading. for header-based threading to continue to work, store emails as emailmessage records with the messagedidentifier field set properly. with lightning threading, you can use threading tokens as the primary threading method and rely on header-based threading as a fallback, or vice versa. in this example, we rely on threading tokens and use header-based threading as a fallback. global class attachemailmessagetocaseexample implements messaging.inboundemailhandler { global messaging.inboundemailresult handleinboundemail(messaging.inboundemail email, messaging.inboundenvelope env) { // create an inboundemailresult object for returning the result of the 2815apex reference guide cases class // apex email service. messaging.inboundemailresult result = new messaging.inboundemailresult(); // try to find the case id using threading tokens in email attributes. id caseid = emailmessages.getrecordidfromemail(email.subject, email.plaintextbody, email.htmlbody); // if we haven't found the case id, try finding it using headers. if (caseid == null) { caseid = cases.getcaseidfromemailheaders(email.headers); } // if a case isn’t found, create a new case record. if (caseid == null) { case c = new case(subject = email.subject); insert c; system.debug('new case object: ' + c); caseid = c.id; } // process recipients string toaddresses; if (email.toaddresses != null) { toaddresses = string.join(email.toaddresses, '; '); } // to store an emailmessage for threading, you need at minimum // the status, the messageidentifier, and the parentid fields. emailmessage em = new emailmessage( status = '0', messageidentifier = email.messageid, parentid = caseid, // other important fields. fromaddress = email.fromaddress, fromname = email.fromname, toaddress = toaddresses, textbody = email.plaintextbody, htmlbody = email.htmlbody, subject = email.subject, // parse thread-index header to remain consistent with email-to-case. clientthreadidentifier = getclientthreadidentifier(email.headers) // other fields you wish to add. ); // insert the new emailmessage. insert em; system.debug('new emailmessage object: ' + em ); // set the result to
true. no need to send an email back to the user // with an error message. result.success = true; // return the result for the apex email service. return result; 2816apex reference guide comparable interface } private string getclientthreadidentifier(list<messaging.inboundemail.header> headers) { if (headers == null || headers.size() == 0) return null; try { for (messaging.inboundemail.header header : headers) { if (header.name.equalsignorecase('thread-index')) { blob threadindex = encodingutil.base64decode(header.value.trim()); return encodingutil.converttohex(threadindex).substring(0, 44).touppercase(); } } } catch (exception e){ return null; } return null; } } getcaseidfromemailthreadid(emailthreadid) returns the case id corresponding to the specified email thread id. (deprecated. use getcaseidfromemailheaders and emailmessages.getrecordidfromemail instead.) signature public static id getcaseidfromemailthreadid(string emailthreadid) parameters emailthreadid type: string return value type: id usage the emailthreadid argument should have the following format: _00dxx1gew._500xxyktg. other formats, such as ref:_00dxx1gew._500xxyktl:ref and [ref:_00dxx1gew._500xxyktl:ref], are invalid. comparable interface adds sorting support for lists that contain non-primitive types, that is, lists of user-defined types. namespace system 2817apex reference guide comparable interface usage to add list sorting support for your apex class, you must implement the comparable interface with its compareto method in your class. to implement the comparable interface, you must first declare a class with the implements keyword as follows: global class employee implements comparable { next, your class must provide an implementation for the following method: global integer compareto(object compareto) { // your code here } the implemented method must be declared as global or public. in this section: comparable methods comparable example implementation see also: list class comparable methods the following are methods for comparable. in this section: compareto(objecttocompareto) returns an integer value that is the result of the comparison. compareto(objecttocompareto) returns an integer value that is the result of the comparison. signature public integer compareto(object objecttocompareto) parameters objecttocompareto type: object return value type: integer 2818apex reference guide comparable interface usage the implementation of this method returns the following values: • 0 if this instance and objecttocompareto are equal • > 0 if this instance is greater than objecttocompareto • < 0 if this instance is less than objecttocompareto if this object instance and objecttocompareto are incompatible, a system.typeexception is thrown. comparable example implementation this is an example implementation of the comparable interface. the compareto method in this example compares the employee of this class instance with the employee passed in the argument. the method returns an integer value based on the comparison of the employee ids. global class employee implements comparable { public long id; public string name; public string phone; // constructor public employee(long i, string n, string p) { id = i; name = n; phone = p; } // implement the compareto() method global integer compareto(object compareto) { employee comparetoemp = (employee)compareto; if (id == comparetoemp.id) return 0; if (id > comparetoemp.id) return 1; return -1; } } this example tests the sort order of a list of employee objects. @istest private class employeesortingtest { static testmethod void test1() { list<employee> emplist = new list<employee>(); emplist.add(new employee(101,'joe smith', '4155551212')); emplist.add(new employee(101,'j. smith', '4155551212')); emplist.add(new employee(25,'caragh smith', '4155551000'));
emplist.add(new employee(105,'mario ruiz', '4155551099')); // sort using the custom compareto() method emplist.sort(); // write list contents to the debug log system.debug(emplist); 2819apex reference guide continuation class // verify list sort order. system.assertequals('caragh smith', emplist[0].name); system.assertequals('joe smith', emplist[1].name); system.assertequals('j. smith', emplist[2].name); system.assertequals('mario ruiz', emplist[3].name); } } continuation class use the continuation class to make callouts asynchronously to a soap or rest web service. namespace system example for a code example, see make long-running callouts from a visualforce page. in this section: continuation constructors continuation properties continuation methods continuation constructors the following are constructors for continuation. in this section: continuation(timeout) creates an instance of the continuation class by using the specified timeout in seconds. the timeout maximum is 120 seconds. continuation(timeout) creates an instance of the continuation class by using the specified timeout in seconds. the timeout maximum is 120 seconds. signature public continuation(integer timeout) parameters timeout type: integer the timeout for this continuation in seconds. 2820apex reference guide continuation class continuation properties the following are properties for continuation. in this section: continuationmethod the name of the callback method that is called after the callout response returns. timeout the timeout of the continuation in seconds. maximum: 120 seconds. state data that is stored in this continuation and that can be retrieved after the callout is finished and the callback method is invoked. continuationmethod the name of the callback method that is called after the callout response returns. signature public string continuationmethod {get; set;} property value type: string usage note: if the continuationmethod property is not set for a continuation, the same action method that made the asynchronous callout is called again when the callout response returns. timeout the timeout of the continuation in seconds. maximum: 120 seconds. signature public integer timeout {get; set;} property value type: integer state data that is stored in this continuation and that can be retrieved after the callout is finished and the callback method is invoked. signature public object state {get; set;} 2821apex reference guide continuation class property value type: object example this example shows how to save state information for a continuation in a controller. // declare inner class to hold state info private class stateinfo { string msg { get; set; } list<string> urls { get; set; } stateinfo(string msg, list<string> urls) { this.msg = msg; this.urls = urls; } } // then in the action method, set state for the continuation continuationinstance.state = new stateinfo('some state data', urls); continuation methods the following are methods for continuation. in this section: addhttprequest(request) adds the http request for the callout that is associated with this continuation. getrequests() returns all labels and requests that are associated with this continuation as key-value pairs. getresponse(requestlabel) returns the response for the request that corresponds to the specified label. addhttprequest(request) adds the http request for the callout that is associated with this continuation. signature public string addhttprequest(system.httprequest request) parameters request type: httprequest the http request to be sent to the external service by this continuation. return value type: string 2822apex reference guide continuation class a unique label that identifies the http request that is associated with this continuation. this label is used in the map that getrequests() returns to identify individual requests in a continuation. usage you can add up tothree requests to a continuation. note: the timeout that is set in each passed-in request is ignored. only the global timeout maximum of 120 seconds applies for a continuation. getrequests() returns all labels and requests that are associated with this continuation as key-value pairs. signature public map<string,system.httprequest> getrequests() return value type: map<string,httprequest>
a map of all requests that are associated with this continuation. the map key is the request label, and the map value is the corresponding http request. getresponse(requestlabel) returns the response for the request that corresponds to the specified label. signature public static httpresponse getresponse(string requestlabel) parameters requestlabel type: string the request label to get the response for. return value type: httpresponse usage the status code is returned in the httpresponse object and can be obtained by calling getstatuscode() on the response. a status code of 200 indicates that the request was successful. other status code values indicate the type of problem that was encountered. sample of error status codes when a problem occurs with the response, some possible status code values are: • 2000: the timeout was reached, and the server didn’t get a chance to respond. 2823apex reference guide cookie class • 2001: there was a connection failure. • 2002: exceptions occurred. • 2003: the response hasn’t arrived (which also means that the apex asynchronous callout framework hasn’t resumed). • 2004: the response size is too large (greater than 1 mb). cookie class the cookie class lets you access cookies for your salesforce site using apex. namespace system usage use the setcookies method of the pagereference class to attach cookies to a page. important: • cookie names and values set in apex are url encoded, that is, characters such as @ are replaced with a percent sign and their hexadecimal representation. • the setcookies method adds the prefix “apex__” to the cookie names. • setting a cookie's value to null sends a cookie with an empty string value instead of setting an expired attribute. • after you create a cookie, the properties of the cookie can't be changed. • be careful when storing sensitive information in cookies. pages are cached regardless of a cookie value. if you use a cookie value to generate dynamic content, you should disable page caching. for more information, see configure site caching in salesforce help. consider the following limitations when using the cookie class: • the cookie class can only be accessed using apex that is saved using the salesforce api version 19 and above. • the maximum number of cookies that can be set per salesforce sites domain depends on your browser. newer browsers have higher limits than older ones. • cookies must be less than 4k, including name and attributes. • the maximum header size of a visualforce page, including cookies, is 8,192 bytes. for more information on sites, see “salesforce sites” in the salesforce online help. example the following example creates a class, cookiecontroller, which is used with a visualforce page (see markup below) to update a counter each time a user displays a page. the number of times a user goes to the page is stored in a cookie. // a visualforce controller class that creates a cookie // used to keep track of how often a user displays a page public class cookiecontroller { public cookiecontroller() { cookie counter = apexpages.currentpage().getcookies().get('counter'); 2824apex reference guide cookie class // if this is the first time the user is accessing the page, // create a new cookie with name 'counter', an initial value of '1', // path 'null', maxage '-1', and issecure 'true'. if (counter == null) { counter = new cookie('counter','1',null,-1,true); } else { // if this isn't the first time the user is accessing the page // create a new cookie, incrementing the value of the original count by 1 integer count = integer.valueof(counter.getvalue()); counter = new cookie('counter', string.valueof(count+1),null,-1,true); } // set the new cookie for the page apexpages.currentpage().setcookies(new cookie[]{counter}); } // this method is used by the visualforce action {!count} to display the current // value of the number of times a user had displayed a page. // this value is stored in the cookie. public string getcount() { cookie counter = apexpages.currentpage().getcookies().get('counter'); if(counter == null) { return '0'; } return counter.getvalue(); } } // test class for the visualforce controller @istest private class cookiecontrollertest { // test method for verifying the positive test case static testmethod void
testcounter() { //first page view cookiecontroller controller = new cookiecontroller(); system.assert(controller.getcount() == '1'); //second page view controller = new cookiecontroller(); system.assert(controller.getcount() == '2'); } } the following is the visualforce page that uses the cookiecontroller apex controller above. the action {!count} calls the getcount method in the controller above. <apex:page controller="cookiecontroller"> you have seen this page {!count} times </apex:page> in this section: cookie constructors cookie methods 2825apex reference guide cookie class cookie constructors the following are constructors for cookie. in this section: cookie(name, value, path, maxage, issecure) creates a new instance of the cookie class using the specified name, value, path, age, and the secure setting. cookie(name, value, path, maxage, issecure, samesite) creates a new instance of the cookie class using the specified name, value, path, and age, and settings for security and cross-domain behavior. cookie(name, value, path, maxage, issecure) creates a new instance of the cookie class using the specified name, value, path, age, and the secure setting. signature public cookie(string name, string value, string path, integer maxage, boolean issecure) parameters name type: string the cookie name. it can’t be null. value type: string the cookie data, such as session id. path type: string the path from where you can retrieve the cookie. maxage type: integer a number representing how long a cookie is valid for in seconds. if set to less than zero, a session cookie is issued. if set to zero, the cookie is deleted. issecure type: boolean a value indicating whether the cookie can only be accessed through https (true) or not (false). cookie(name, value, path, maxage, issecure, samesite) creates a new instance of the cookie class using the specified name, value, path, and age, and settings for security and cross-domain behavior. note: google chrome 80 introduces a new default cookie attribute setting of samesite, which is set to lax. previously, the samesite cookie attribute defaulted to the value of none. when samesite is set to none, cookies must be tagged with the issecure attribute indicating that they require an encrypted https connection. 2826apex reference guide cookie class signature public cookie(string name, string value, string path, integer maxage, boolean issecure, string samesite) parameters name type: string the cookie name. it can’t be null. value type: string the cookie data, such as session id. path type: string the path from where you can retrieve the cookie. maxage type: integer a number representing how long a cookie is valid for in seconds. if set to less than zero, a session cookie is issued. if set to zero, the cookie is deleted. issecure type: boolean a value indicating whether the cookie can only be accessed through https (true) or not (false). samesite type: string the samesite attribute on a cookie controls its cross-domain behavior. the valid values are none, lax, and strict. after the chrome 80 release, a cookie with a samesite value of none must also be marked secure by setting a value of none; secure. see also: salesforce spring ’20 release notes: prepare for google chrome’s changes in samesite cookie behavior that can break salesforce integrations chrome platform status: reject insecure samesite=none cookies cookie methods the following are methods for cookie. all are instance methods. in this section: getdomain() returns the name of the server making the request. getmaxage() returns a number representing how long the cookie is valid for, in seconds. if set to < 0, a session cookie is issued. if set to 0, the cookie is deleted. 2827apex reference guide cookie class getname() returns the name of the cookie. can't be null. getpath() returns the path from which you can retrieve the cookie. if null or blank, the location is set to root, or “/”. getsamesite() returns the value for the samesite attribute of the cookie. getvalue() returns the data
captured in the cookie, such as session id. issecure() returns true if the cookie can only be accessed through https, otherwise returns false. getdomain() returns the name of the server making the request. signature public string getdomain() return value type: string getmaxage() returns a number representing how long the cookie is valid for, in seconds. if set to < 0, a session cookie is issued. if set to 0, the cookie is deleted. signature public integer getmaxage() return value type: integer getname() returns the name of the cookie. can't be null. signature public string getname() return value type: string 2828apex reference guide cookie class getpath() returns the path from which you can retrieve the cookie. if null or blank, the location is set to root, or “/”. signature public string getpath() return value type: string getsamesite() returns the value for the samesite attribute of the cookie. signature public string getsamesite() return value type: string see also: web.dev: samesite cookies explained getvalue() returns the data captured in the cookie, such as session id. signature public string getvalue() return value type: string issecure() returns true if the cookie can only be accessed through https, otherwise returns false. signature public boolean issecure() return value type: boolean 2829apex reference guide crypto class crypto class provides methods for creating digests, message authentication codes, and signatures, as well as encrypting and decrypting information. namespace system usage the methods in the crypto class can be used for securing content in lightning platform, or for integrating with external services such as google or amazon webservices (aws). encrypt and decrypt exceptions the following exceptions can be thrown for these methods: • decrypt • encrypt • decryptwithmanagediv • encryptwithmanagediv exception message description invalidparametervalue unable to parse initialization vector from thrown if you're using managed encrypted data. initialization vectors, and the cipher text is less than 16 bytes. invalidparametervalue invalid algorithm algoname. must be thrown if the algorithm name isn't one of aes128, aes192, aes256, aes384, or the valid values. aes512. invalidparametervalue invalid private key. must be size bytes. thrown if size of the private key doesn't match the specified algorithm. invalidparametervalue invalid initialization vector. must be 16 bytes. thrown if the initialization vector isn't 16 bytes. invalidparametervalue invalid data. input data is size bytes, thrown if the data is greater than 1 mb. for which exceeds the limit of 1048576 bytes. decryption, 1048608 bytes are allowed for the initialization vector header, plus any additional padding the encryption added to align to block size. nullpointerexception argument cannot be null. thrown if one of the required method arguments is null. securityexception given final block not properly padded. thrown if the data isn't properly block-aligned or similar issues occur during encryption or decryption. 2830apex reference guide crypto class exception message description securityexception message varies thrown if something goes wrong during either encryption or decryption. crypto methods the following are methods for crypto. all methods are static. in this section: decrypt(algorithmname, privatekey, initializationvector, ciphertext) decrypts the blob ciphertext using the specified algorithm, private key, and initialization vector. use this method to decrypt blobs encrypted using a third party application or the encrypt method. decryptwithmanagediv(algorithmname, privatekey, ivandciphertext) decrypts the blob ivandciphertext using the specified algorithm and private key. use this method to decrypt blobs encrypted using a third party application or the encryptwithmanagediv method. encrypt(algorithmname, privatekey, initializationvector, cleartext) encrypts the blob cleartext using the specified algorithm, private key and initialization vector. use this method when you want to specify your own initialization vector. encryptwithmanagediv(algorithmname, privatekey, cleartext) encrypts the blob cleartext using the specified algorithm and private key. use this method when you want salesforce to generate the initialization vector for you. generateaeskey(size) generates an advanced encryption standard (aes) key.
generatedigest(algorithmname, input) computes a secure, one-way hash digest based on the supplied input string and algorithm name. generatemac(algorithmname, input, privatekey) computes a message authentication code (mac) for the input string, using the private key and the specified algorithm. getrandominteger() returns a random integer. getrandomlong() returns a random long. sign(algorithmname, input, privatekey) computes a unique digital signature for the input string, using the specified algorithm and the supplied private key. signwithcertificate(algorithmname, input, certdevname) computes a unique digital signature for the input string, using the specified algorithm and the supplied certificate and key pair. signxml(algorithmname, node, idattributename, certdevname) envelops the signature into an xml document. signxml(algorithmname, node, idattributename, certdevname, refchild) inserts the signature envelope before the specified child node. 2831apex reference guide crypto class verify(string algorithmname, blob data, blob signature, blob publickey) verifies the digital signature for the blob data using the specified algorithm and the supplied public key. use this method to verify a blob signed by a digital signature created using a third-party application or the sign method. verify(string algorithmname, blob data, blob signature, string certdevname) verifies the digital signature for the blob data using the specified algorithm and the public key associated with the certdevname. use this method to verify a blob signed by a digital signature created using a third-party application or the sign method. verifyhmac(string algorithmname, blob input, blob privatekey, blob mactoverify) verifies the hmac signature for blob data using the specified algorithm, input data, privatekey, and the mac. use this method to verify a blob signed by a digital signature created using a third-party application or the sign method. decrypt(algorithmname, privatekey, initializationvector, ciphertext) decrypts the blob ciphertext using the specified algorithm, private key, and initialization vector. use this method to decrypt blobs encrypted using a third party application or the encrypt method. signature public static blob decrypt(string algorithmname, blob privatekey, blob initializationvector, blob ciphertext) parameters algorithmname type: string privatekey type: blob initializationvector type: blob ciphertext type: blob return value type: blob usage valid values for algorithmname are: • aes128 • aes192 • aes256 these algorithms are all industry standard advanced encryption standard (aes) algorithms with different size keys. they use cipher block chaining (cbc) and pkcs7 padding. the length of privatekey must match the specified algorithm: 128 bits, 192 bits, or 256 bits, which is 16 bytes, 24 bytes, or 32 bytes, respectively. you can use a third-party application or the generateaeskey method to generate this key for you. the initialization vector must be 128 bits (16 bytes.) 2832
apex reference guide crypto class example blob exampleiv = blob.valueof('example of iv123'); blob key = crypto.generateaeskey(128); blob data = blob.valueof('data to be encrypted'); blob encrypted = crypto.encrypt('aes128', key, exampleiv, data); blob decrypted = crypto.decrypt('aes128', key, exampleiv, encrypted); string decryptedstring = decrypted.tostring(); system.assertequals('data to be encrypted', decryptedstring); decryptwithmanagediv(algorithmname, privatekey, ivandciphertext) decrypts the blob ivandciphertext using the specified algorithm and private key. use this method to decrypt blobs encrypted using a third party application or the encryptwithmanagediv method. signature public static blob decryptwithmanagediv(string algorithmname, blob privatekey, blob ivandciphertext) parameters algorithmname type: string privatekey type: blob ivandciphertext type: blob the first 128 bits (16 bytes) of ivandciphertext must contain the initialization vector. return value type: blob usage valid values for algorithmname are: • aes128 • aes192 • aes256 these algorithms are all industry standard advanced encryption standard (aes) algorithms with different size keys. they use cipher block chaining (cbc) and pkcs7 padding. the length of privatekey must match the specified algorithm: 128 bits, 192 bits, or 256 bits, which is 16 bytes, 24 bytes, or 32 bytes, respectively. you can use a third-party application or the generateaeskey method to generate this key for you. 2833apex reference guide crypto class example blob key = crypto.generateaeskey(128); blob data = blob.valueof('data to be encrypted'); blob encrypted = crypto.encryptwithmanagediv('aes128', key, data); blob decrypted = crypto.decryptwithmanagediv('aes128', key, encrypted); string decryptedstring = decrypted.tostring(); system.assertequals('data to be encrypted', decryptedstring); encrypt(algorithmname, privatekey, initializationvector, cleartext) encrypts the blob cleartext using the specified algorithm, private key and initialization vector. use this method when you want to specify your own initialization vector. signature public static blob encrypt(string algorithmname, blob privatekey, blob initializationvector, blob cleartext) parameters algorithmname type: string privatekey type: blob initializationvector type: blob cleartext type: blob return value type: blob usage the initialization vector must be 128 bits (16 bytes.) use either a third-party application or the decrypt method to decrypt blobs encrypted using this method. use the encryptwithmanagediv method if you want salesforce to generate the initialization vector for you. it is stored as the first 128 bits (16 bytes) of the encrypted blob. valid values for algorithmname are: • aes128 • aes192 • aes256 these algorithms are all industry standard advanced encryption standard (aes) algorithms with different size keys. they use cipher block chaining (cbc) and pkcs7 padding. the length of privatekey must match the specified algorithm: 128 bits, 192 bits, or 256 bits, which is 16 bytes, 24 bytes, or 32 bytes, respectively. you can use a third-party application or the generateaeskey method to generate this key for you. 2834apex reference guide crypto class example blob exampleiv = blob.valueof('example of iv123'); blob key = crypto.generateaeskey(128); blob data = blob.valueof('data to be encrypted'); blob encrypted = crypto.encrypt('aes128', key, exampleiv, data); blob decrypted = crypto.decrypt('aes128', key, exampleiv, encrypted); string decryptedstring = decrypted.tostring(); system.assertequals('data to be encrypted', decryptedstring); encryptwithmanagediv(algorithmname, privatekey, cleartext) encrypts the blob cleartext using the specified algorithm and private key. use this method when you want salesforce to generate the initialization vector for you. signature public static blob encrypt
withmanagediv(string algorithmname, blob privatekey, blob cleartext) parameters algorithmname type: string privatekey type: blob cleartext type: blob return value type: blob usage the initialization vector is stored as the first 128 bits (16 bytes) of the encrypted blob. use either third-party applications or the decryptwithmanagediv method to decrypt blobs encrypted with this method. use the encrypt method if you want to generate your own initialization vector. valid values for algorithmname are: • aes128 • aes192 • aes256 these algorithms are all industry standard advanced encryption standard (aes) algorithms with different size keys. they use cipher block chaining (cbc) and pkcs7 padding. the length of privatekey must match the specified algorithm: 128 bits, 192 bits, or 256 bits, which is 16 bytes, 24 bytes, or 32 bytes, respectively. you can use a third-party application or the generateaeskey method to generate this key for you. 2835apex reference guide crypto class example blob key = crypto.generateaeskey(128); blob data = blob.valueof('data to be encrypted'); blob encrypted = crypto.encryptwithmanagediv('aes128', key, data); blob decrypted = crypto.decryptwithmanagediv('aes128', key, encrypted); string decryptedstring = decrypted.tostring(); system.assertequals('data to be encrypted', decryptedstring); generateaeskey(size) generates an advanced encryption standard (aes) key. signature public static blob generateaeskey(integer size) parameters size type: integer the key's size in bits. valid values are: • 128 • 192 • 256 return value type: blob example blob key = crypto.generateaeskey(128); generatedigest(algorithmname, input) computes a secure, one-way hash digest based on the supplied input string and algorithm name. signature public static blob generatedigest(string algorithmname, blob input) parameters algorithmname type: string valid values for algorithmname are: • md5 2836apex reference guide crypto class • sha1 • sha3-256 • sha3-384 • sha3-512 • sha-256 • sha-512 input type: blob return value type: blob example blob targetblob = blob.valueof('examplemd5string'); blob hash = crypto.generatedigest('md5', targetblob); generatemac(algorithmname, input, privatekey) computes a message authentication code (mac) for the input string, using the private key and the specified algorithm. signature public static blob generatemac(string algorithmname, blob input, blob privatekey) parameters algorithmname type: string the valid values for algorithmname are: • hmacmd5 • hmacsha1 • hmacsha256 • hmacsha512 input type: blob privatekey type: blob the value of privatekey does not need to be in decoded form. the value cannot exceed 4 kb. return value type: blob 2837apex reference guide crypto class example string salt = string.valueof(crypto.getrandominteger()); string key = 'key'; blob data = crypto.generatemac('hmacsha256', blob.valueof(salt), blob.valueof(key)); getrandominteger() returns a random integer. signature public static integer getrandominteger() return value type: integer example integer randomint = crypto.getrandominteger(); getrandomlong() returns a random long. signature public static long getrandomlong() return value type: long example long randomlong = crypto.getrandomlong(); sign(algorithmname, input, privatekey) computes a unique digital signature for the input string, using the specified algorithm and the supplied private key. signature public static blob sign(string algorithmname, blob input, blob privatekey) 2838apex reference guide crypto class parameters algorithmname type: string the algorithm name. the valid values for algorithmname are rsa, rsa-sha1, rsa-sha256, rsa-sha384, r