<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ApexDevForce.com</title>
    <description></description>
    <link>https://apexdevforce.com/</link>
    <atom:link href="https://apexdevforce.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 02 Dec 2024 15:01:31 +0000</pubDate>
    <lastBuildDate>Mon, 02 Dec 2024 15:01:31 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Salesforce SFDX CI/CD - Bitbucket Pipelines Example</title>
        <description>&lt;h1 id=&quot;salesforce-sfdx-cicd---bitbucket-pipelines-example&quot;&gt;Salesforce SFDX CI/CD - Bitbucket Pipelines Example&lt;/h1&gt;

&lt;h3 id=&quot;1-prerequisites---environment-and-tools&quot;&gt;1. Prerequisites - environment and tools&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Command Line on an OS MacOS / Linux / Windows&lt;/li&gt;
  &lt;li&gt;Web Browser&lt;/li&gt;
  &lt;li&gt;OpenSSL - OOTB in MacOS and Linux. Windows: https://www.openssl.org/&lt;/li&gt;
  &lt;li&gt;Salesforce Deployment Traget Org with Admin User Access&lt;/li&gt;
  &lt;li&gt;SFDX CLI - https://developer.salesforce.com/tools/sfdxcli&lt;/li&gt;
  &lt;li&gt;Bitbucket Pipeline - bitbucket user account with repo admin permission&lt;/li&gt;
  &lt;li&gt;Git - https://git-scm.com/&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;2-openssl---crete-a-private-key-and-self-sighned-digital-certificate&quot;&gt;2. OpenSSL - crete a private key and self-sighned digital certificate&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Run the following Commands in a folder, e.g. a folder named “my_ssh_keys” on Desktop
    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/Desktop/my_ssh_keys
openssl genrsa &lt;span class=&quot;nt&quot;&gt;-des3&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-passout&lt;/span&gt; pass:x &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.pass.key 2048
openssl rsa &lt;span class=&quot;nt&quot;&gt;-passin&lt;/span&gt; pass:x &lt;span class=&quot;nt&quot;&gt;-in&lt;/span&gt; server.pass.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.key
openssl req &lt;span class=&quot;nt&quot;&gt;-new&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-key&lt;/span&gt; server.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.csr
openssl x509 &lt;span class=&quot;nt&quot;&gt;-req&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sha256&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-days&lt;/span&gt; 365 &lt;span class=&quot;nt&quot;&gt;-in&lt;/span&gt; server.csr &lt;span class=&quot;nt&quot;&gt;-signkey&lt;/span&gt; server.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.crt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;3-salesforce-org---create-a-connect-app-on-deployment-target-org&quot;&gt;3. Salesforce Org - create a Connect App on deployment target org&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Classic UI: Setup -&amp;gt; Build -&amp;gt; Create -&amp;gt; Apps -&amp;gt; New Connected Apps -&amp;gt; New&lt;/li&gt;
  &lt;li&gt;Lightning: Setup -&amp;gt; PLATFORM TOOLS -&amp;gt; Apps -&amp;gt; App Manager -&amp;gt; New Connected App&lt;/li&gt;
  &lt;li&gt;Connect App Name: e.g. My CICD&lt;/li&gt;
  &lt;li&gt;Contact Email: your@email.address&lt;/li&gt;
  &lt;li&gt;Enable OAuth Settings
    &lt;ul&gt;
      &lt;li&gt;Callback URL: http://localhost:1717/OauthRedirect&lt;/li&gt;
      &lt;li&gt;Tick “Use digital signatures” -&amp;gt; upload the &lt;strong&gt;server.crt&lt;/strong&gt; that was generated by OpenSSL in step 2.&lt;/li&gt;
      &lt;li&gt;OAuth scope:
        &lt;ul&gt;
          &lt;li&gt;Access and manage your data (api)&lt;/li&gt;
          &lt;li&gt;Perform requests on your behalf at any time (refresh_token, offline_access)&lt;/li&gt;
          &lt;li&gt;Provide access to your data via the Web (web)&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_connected_app.htm&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;4-salesforce-org---oauth-from-browser-to-the-deployment-target-org&quot;&gt;4. Salesforce Org - OAuth from browser to the deployment target org&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Allow from 2-10 minutes for your changes to take effect on the server before using the connected app.&lt;/li&gt;
  &lt;li&gt;Open browser, past the following address to login to the Salesforce deployment target org
    &lt;ul&gt;
      &lt;li&gt;https://&lt;strong&gt;org-custom-domain&lt;/strong&gt;.my.salesforce.com/services/oauth2/authorize?client_id=&lt;strong&gt;consumer_key&lt;/strong&gt;&amp;amp;redirect_uri=http://localhost:1717/OauthRedirect&amp;amp;response_type=code&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Replace &lt;strong&gt;org-custom-domain&lt;/strong&gt; with the deployment target custom domain&lt;/li&gt;
  &lt;li&gt;Replace &lt;strong&gt;consumer_key&lt;/strong&gt; with the connect app’s consumer key&lt;/li&gt;
  &lt;li&gt;Login and Authorize (here the login user will be used as the pipeline Salesforce login user)
    &lt;ul&gt;
      &lt;li&gt;After login and authroize, the browser will be redirected to http://localhost:1717/OauthRedirect, just ignore and close the browser tab.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;5-bitbucket-pipeline---enable-pipline&quot;&gt;5. Bitbucket Pipeline - enable pipline&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Click Pipeline on repo sidebar menu&lt;/li&gt;
  &lt;li&gt;Select the default &lt;strong&gt;Starter&lt;/strong&gt; pipeline&lt;/li&gt;
  &lt;li&gt;Replace the &lt;strong&gt;bitbucket-pipelines.yml&lt;/strong&gt; content with the following example.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
image:
  name: salesforce/salesforcedx:7.75.1-slim

pipelines:
  default:
    - step:
        script:
          - echo &quot;Commited changes to a branch that does not match the listed branches in bitbucket-pipelines.yml.&quot;
          - echo &quot;You can skip running pipline by adding [skip ci] or [ci skip] (with []) to the git commit message.&quot;
          - sfdx --version
          - sfdx plugins --core
  branches:
    qa:
     - step:
         script:
           - sfdx --version
           - sfdx force:auth:jwt:grant -f server.key -i $SFDC_CONSUMER_KEY -u $SFDC_USER -d -s -r $SFDC_URL
           - sfdx force:source:deploy -x $MANIFEST_PACKAGE_PATH -l RunSpecifiedTests -r $TEST_CLASSES_1
&lt;/pre&gt;

&lt;ul&gt;
  &lt;li&gt;The example will work when changes committed to the git repo branch named &lt;strong&gt;qa&lt;/strong&gt; i.e. the CI/CD will automatically run when someone pull-request and merge changes to the &lt;strong&gt;qa&lt;/strong&gt; branch.&lt;/li&gt;
  &lt;li&gt;You can change the branch name to suit your project settings.&lt;/li&gt;
  &lt;li&gt;You can add more branches to deploy different branches to different deployment target orgs, in this case you will need to set up Connect Apps in each deployment target orgs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;6-bitbucket-pipeline---repository-variables&quot;&gt;6. Bitbucket Pipeline - repository variables&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;The example in step 5 need following variables to be set up in the repository.&lt;/li&gt;
  &lt;li&gt;Repository sidebar -&amp;gt; Repository settings -&amp;gt; PIPELINES &amp;gt; Repository Variables: Add new Name and Value pairs
    &lt;ul&gt;
      &lt;li&gt;SFDC_CONSUMER_KEY : the consumer key from the newly created Salesforce Connect App&lt;/li&gt;
      &lt;li&gt;SFDC_USER : Salesforce Org user name of the CI/CD runner, the user that used in the OAuth slide&lt;/li&gt;
      &lt;li&gt;SFDC_URL : https://test.salesforce.com  for sandboxes, replace “test” with “login” for production.&lt;/li&gt;
      &lt;li&gt;TEST_CLASSES_1 : list of comma separated unit test class names, e.g. MyClassTest,YourClassTest&lt;/li&gt;
      &lt;li&gt;MANIFEST_PACKAGE_PATH : manifest/release_package.xml&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;7-bitbucket-pipeline---running-cicd&quot;&gt;7. Bitbucket Pipeline - running CI/CD&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;In the example bitbucket-pipelines.yml the configuration is based on a branch named: &lt;strong&gt;qa&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Create a branch in the repository, name it as &lt;strong&gt;qa&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Commit the bitbucket-pipelines.yml and the &lt;strong&gt;server.key&lt;/strong&gt; (created by OpenSSL in the step 1) to the &lt;strong&gt;qa&lt;/strong&gt; branch.&lt;/li&gt;
  &lt;li&gt;Create the release_package.xml and commit it along with the metadata files that listed in it to the &lt;strong&gt;qa&lt;/strong&gt; branch, your pipeline should have started automatically.&lt;/li&gt;
  &lt;li&gt;Don’t forget to update the Test Classes in the Repository variables. In the example the variable name is &lt;strong&gt;TEST_CLASSES_1&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;8-good-luck-8-is-a-lucky-number-in-chinese-culture-which-means-get-rich-&quot;&gt;8. Good luck! 8 is a lucky number in Chinese culture, which means get &lt;strong&gt;rich&lt;/strong&gt; :)&lt;/h3&gt;
</description>
        <pubDate>Wed, 01 Jul 2020 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/software-engineering/salesforce-sfdx-ci-cd-bitbucket-piplines-example/</link>
        <guid isPermaLink="true">https://apexdevforce.com/software-engineering/salesforce-sfdx-ci-cd-bitbucket-piplines-example/</guid>
        
        <category>SFDX</category>
        
        <category>Bitbucket Pipelines</category>
        
        <category>CI/CD</category>
        
        
        <category>Software-Engineering</category>
        
      </item>
    
      <item>
        <title>Apex get outstanding scheduled jobs</title>
        <description>&lt;p&gt;Get outstanding scheduled Apex jobs&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getOutstandingJobs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jobName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Job Types:&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Data Export (0)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Dashboard Refresh (3)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Analytic Snapshot (4)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Scheduled Apex (7)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Report Run (8)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Batch Job (9)&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// The current state of the job. The job state is managed by the system. Possible values are:&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// WAITING: The job is waiting for execution.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ACQUIRED: The job has been picked up by the system and is about to execute.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// EXECUTING: The job is executing.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// COMPLETE: The trigger has fired and is not scheduled to fire again.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ERROR: The trigger definition has an error.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// DELETED: The job has been deleted.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// PAUSED: A job can have this state during patch and major releases. After the release has finished, the job state is automatically set to WAITING or another state.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// BLOCKED: Execution of a second instance of the job is attempted while one instance is running. This state lasts until the first job instance is completed.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// PAUSED_BLOCKED: A job has this state due to a release occurring. When the release has finished and no other instance of the job is running, the job’s status is set to another state.&lt;/span&gt;
  
  &lt;span class=&quot;c1&quot;&gt;// hardcoded to type=7, as it is the schedule job&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;CronTrigger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronExpression&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StartTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;EndTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PreviousFireTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;NextFireTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
             &lt;span class=&quot;nc&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronJobDetail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronJobDetail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronJobDetail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;JobType&lt;/span&gt; 
             &lt;span class=&quot;no&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronTrigger&lt;/span&gt; 
             &lt;span class=&quot;no&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronJobDetail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;JobType&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;7&apos;&lt;/span&gt; 
             &lt;span class=&quot;no&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;State&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;WAITING&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;
             &lt;span class=&quot;no&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CronJobDetail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;like&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;jobName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;&apos;%&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// this query check for any &quot;waiting&quot; job that match the jobname... doesn&apos;t really care when it is fired&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// this check make sure we don&apos;t schdule more than 1 job with the same name&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;//for(CronTrigger c: cts){system.debug(c);}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 12 Dec 2018 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/apex/apex-outstanding-scheduled-jobs/</link>
        <guid isPermaLink="true">https://apexdevforce.com/apex/apex-outstanding-scheduled-jobs/</guid>
        
        <category>Apex</category>
        
        <category>Scheduled Job</category>
        
        
        <category>Apex</category>
        
      </item>
    
      <item>
        <title>com.sforce.ws.SoapFaultException Unable to find a deserializer for the type common.api.soap.wsdl.QueryResult Error Id</title>
        <description>&lt;p&gt;com.sforce.ws.SoapFaultException: Unable to find a deserializer for the type common.api.soap.wsdl.QueryResult Error Id: 883671539-69937 (-428048666)&lt;/p&gt;

&lt;p&gt;Resolve:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Check the Query String&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; QueryResult accountQueryResult = enterpriseConnection.query(&quot;SELECT Id, (SELECT Id FROM Contacts), Name, FROM Account WHERE Id = \&apos;&quot; + acctId + &quot;\&apos; LIMIT 1&quot;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Notice the sub-query (SELECT Id FROM Contacts), the result of the above query has nested contact objects information.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Now start to use the account query result by casting it to Account acct = (Account)accountQueryResult.getRecords()[0];&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Start using ‘acct’ as Account object, (remember it has nested contact object information), the ERROR may occurs if you use this ‘acct’ directly in other SOAP methods, as other methods may require a Account object without the nested Contact objects (Unable to find a deserializer for the type common.api.soap.wsdl.QueryResult). So process the ‘acct’ to remove the sub contact objects before using it in other methods.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Sun, 07 Jan 2018 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/integration/com-sforce-ws-soapfaultexception-unable-to-find-a-deserializer-for-the-type-common-api-soap-wsdl-queryresult-error-id/</link>
        <guid isPermaLink="true">https://apexdevforce.com/integration/com-sforce-ws-soapfaultexception-unable-to-find-a-deserializer-for-the-type-common-api-soap-wsdl-queryresult-error-id/</guid>
        
        <category>SoapFaultException</category>
        
        <category>deserializer</category>
        
        
        <category>Integration</category>
        
      </item>
    
      <item>
        <title>Attach a Dynamic PDF Message to a Salesforce Email Template</title>
        <description>&lt;p&gt;Attach a Dynamic PDF Message to a Salesforce Email Template.The Email Template can be used in Email Alerts that will be triggered by Workflow Rule / Process / Flow … etc&lt;/p&gt;

&lt;h3 id=&quot;we-will-create-following-items&quot;&gt;We will create following items:&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;A Visualforce page that will be rendered as PDF. (e.g. Receipt)&lt;/li&gt;
  &lt;li&gt;A Apex Controller Class for the above VF page. (e.g. ReceiptController)&lt;/li&gt;
  &lt;li&gt;A VF Component that to be referenced by the Visualforce Email Template. (e.g. ReceiptAttachment)&lt;/li&gt;
  &lt;li&gt;A Apex Controller Class for the above VF Component. (e.g. ReceiptAttachmentController)An Visualforce Email Template.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;sample-code-list&quot;&gt;Sample Code List&lt;/h3&gt;

&lt;h4 id=&quot;receiptpage&quot;&gt;Receipt.page&lt;/h4&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;apex:page&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;controller=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ReceiptController&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;applyHtmlTag=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;applyBodyTag=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;showHeader=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;sidebar=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;span&amp;gt;&lt;/span&gt;Dynamic PDF data:  &lt;span class=&quot;nt&quot;&gt;&amp;lt;apex:outputText&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{!ContactName}&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;escape=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/apex:page&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;receiptcontrollerclass&quot;&gt;ReceiptController.class&lt;/h4&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ReceiptController&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ContactID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ContactID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
            &lt;span class=&quot;nc&quot;&gt;ApexPages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getParameters&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contactId&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;ContactID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ApexPages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getParameters&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contactId&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ContactID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ContactName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Contact&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ContactID&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;LIMIT&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;receiptattachmentcomponent&quot;&gt;ReceiptAttachment.component&lt;/h4&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;apex:component controller=&quot;ReceiptAttachmentController&quot; access=&quot;global&quot;&amp;gt;
    &amp;lt;apex:attribute name=&quot;contactId&quot;

        description=&quot;Contact Id&quot;

        assignTo=&quot;{!contactObjectId}&quot;

        type=&quot;Id&quot; /&amp;gt;

    &amp;lt;apex:outputText value=&quot;{!PageContents}&quot; escape=&quot;false&quot; /&amp;gt;
&amp;lt;/apex:component&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;receiptattachmentcontrollerclass&quot;&gt;ReceiptAttachmentController.class&lt;/h4&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ReceiptAttachmentController&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PageContents&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contactObjectId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;UpdateContents&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; 
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;UpdateContents&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contactObjectID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;PageReference&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pageRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Receipt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pageRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getParameters&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contactId&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contactObjectID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;PageContents&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pageRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getContent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;display:none !important;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; 
        &lt;span class=&quot;nc&quot;&gt;PageContents&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;An&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;has&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;occurred&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;trying&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;generate&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invoice&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;  &lt;span class=&quot;nc&quot;&gt;Please&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contact&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; 
                       &lt;span class=&quot;err&quot;&gt;&apos;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nError&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;Message:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;visualforce-email-template&quot;&gt;Visualforce Email Template&lt;/h4&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;messaging:emailTemplate subject=&quot;Receipt Attached&quot; recipientType=&quot;Contact&quot; 
 relatedToType=&quot;Contact&quot; replyTo=&quot;your@company.com&quot;&amp;gt;
    &amp;lt;messaging:attachment renderAs=&quot;PDF&quot; filename=&quot;receipt.pdf&quot;&amp;gt;
        &amp;lt;c:ReceiptAttachment contactId=&quot;{!relatedTo.Id}&quot;/&amp;gt;
    &amp;lt;/messaging:attachment&amp;gt;
    &amp;lt;messaging:htmlEmailBody &amp;gt;
    &amp;lt;html&amp;gt;
        Please find your invoice attached.
    &amp;lt;/html&amp;gt;
    &amp;lt;/messaging:plainTextEmailBody&amp;gt;
&amp;lt;/messaging:emailTemplate&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you will see “Visualforce Attachments” in the Email Template, File Name: receipt.pdf&lt;/p&gt;
</description>
        <pubDate>Wed, 17 May 2017 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/apex/attach-a-dynamic-pdf-message-to-a-salesforce-email-template/</link>
        <guid isPermaLink="true">https://apexdevforce.com/apex/attach-a-dynamic-pdf-message-to-a-salesforce-email-template/</guid>
        
        <category>Apex</category>
        
        <category>Visualforce</category>
        
        <category>PDF</category>
        
        <category>EmailTemplate</category>
        
        
        <category>Apex</category>
        
      </item>
    
      <item>
        <title>Salesforce Formula field to generate Case ref number</title>
        <description>&lt;p&gt;V1&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;TRIM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; [ ref:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$Organization&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$Organization&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;SUBSTITUTE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SUBSTITUTE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SUBSTITUTE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:ref ] &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;V2 Case ref number used in Email communication.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ref:_&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$Organization&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SUBSTITUTE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$Organization&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;._&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SUBSTITUTE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:ref&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Tue, 07 Mar 2017 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/appbuilder/formula-field-to-generate-case-ref-number/</link>
        <guid isPermaLink="true">https://apexdevforce.com/appbuilder/formula-field-to-generate-case-ref-number/</guid>
        
        <category>Formula</category>
        
        <category>Case</category>
        
        
        <category>AppBuilder</category>
        
      </item>
    
      <item>
        <title>Salesforce Formula Calculate Years and Months Between 2 Dates</title>
        <description>&lt;p&gt;To calculate Years and Months in Salesforce formula field between 2 dates.Use case:Calculate how many years and months work experience from an employee start work date.Formula Field, return Text:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;TEXT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 
&lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 

&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Years &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; 

&lt;span class=&quot;nx&quot;&gt;TEXT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MOD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 
&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TODAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Start_Date__c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; 

&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Months&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Sun, 22 May 2016 00:00:00 +0000</pubDate>
        <link>https://apexdevforce.com/appbuilder/salesforce-formula-calculate-years-and-months-between-2-dates/</link>
        <guid isPermaLink="true">https://apexdevforce.com/appbuilder/salesforce-formula-calculate-years-and-months-between-2-dates/</guid>
        
        <category>Formula</category>
        
        
        <category>AppBuilder</category>
        
      </item>
    
  </channel>
</rss>
