How to trigger a flow from apex in Salesforce
In this blog, we will discuss on how to invoke a lightning Auto launched flow from the apex class. 1. It works only with autolaunched Flow. 2. Use the start method in the Flow.Interview class to launch an autolaunched flow or user provisioning flow from Apex. 3. In this example, we will use a visualforce page where flow will be invoked …
“NO_MASS_MAIL_PERMISSION” Error While Sending Email From Apex
If you are getting this error message while sending email using “Messaging.SingleEmailMessage” System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature.: [] Step to resolution Make sure Email Deliverability is turned on. …
“NO_MASS_MAIL_PERMISSION” Error While Sending Email From Apex Read More »
Determine if the Salesforce instance is production org or a Sandbox org in code?
Most efficient way of identifying the type of org (Production or Sandbox) via Apex code: Actually we can query this detail from Organization object as below: On the top of this, we can build our own service method like below:
Convert String into Blob and Blob into String using Apex in Salesforce
Apex Code Snippet to Convert Blob into String Apex Code Snippet to Convert String into Blob
“The REST API is not enabled for this Organization” while using Salesforce REST Api
Check on the profile for the user. Access the profile settings in order to verify that API is enabled as well. In LEX, go to Set up | Users | Profiles. In Classic, click Setup | Administration Setup | Manage Users | Profiles. Select the profile that you need to check, and under “Administrative Permissions” verify if API Enabled is selected.
Approve Records in Bulk Using Apex
The following sample code approves records in mass using apex. Below example just uses Account object’s record. Please feel free to update it as per your need.
Convert epoch to datetime in Apex
We get this requirement while coding several time to convert epoch time (Unix time) to Datetime. First thing, never store a epoch time in Integer and use Long always. Below given code can be used to convert into datetime: To get the epoch from a datetime variable you can just call the getTime() instance method:
How to generate PDF using Apex?
You can use the PageReference.getContentAsPDF() method in Apex to render a Visualforce page as PDF data. Then use Apex code to convert that PDF data to an email attachment, a document, a Chatter post, and so on.The following example is a simple three element form that selects an account and a report format, and then sends the …
How to append in a CSV file using Apex
Feel free to utilize this method and change as per your need: