Sunday, 30 June 2019

Load or Update Records with the Custom Metadata Loader

Hi,
Usually, we can't insert or update Custom Metadata records using Apex with normal DML statements.

We have custom meta loader to insert or update multiple records into Custom Metadata.


The custom metadata loader lets you load or update up to 200 records with a single call.

  1. Download the tool from GitHub and deploy the package to your org via Workbench. Create the .zip file from the contents of the custom_md_loader directory instead of zipping up the directory itself.
  2. Create a .csv file with a header that contains the custom metadata type’s field API names. Either the Label or the Developer Name field is required. See sample.csv in your download for an example. If your org is namespaced, include the namespace prefix in your header. To update an existing custom metadata record, use the Label or Developer Name field to identify it.
  3. From Setup, assign the Custom Metadata Loader permission set to the appropriate users, including yourself.
  4. From the App Picker, select Custom Metadata Loader.
  5. Click the Custom Metadata Loader tab. If you haven’t already done so, the app prompts you to configure your Remote Site Settings.
  6. Upload your .csv file and select the corresponding custom metadata type.
  7. Click Create/Update custom metadata to bulk-load the records from the .csv file or update existing records. If the file has duplicate Label or Developer Name entries, the last entry becomes the new or updated record.


References:

Saturday, 22 June 2019

Custom Metadata Record creation in apex

Hi,

Here I am going to explain how can we create custom metadata record in apex.

Usually, we can' create custom metadata record through DML statements in apex.


But we have  "Metadata" class to create Custom Metadata record in apex.

When we use this no DML operations happen for creating records. instead, it does the deployment of custom metadata values.

Whenever we want to use this we have to create a call back class which implements "Metadata.DeployCallback" interface as shown below as this action is asynchronous.

Callback Class:
public class MetadataCallbackCls implements Metadata.DeployCallback {
    public void handleResult(Metadata.DeployResult result,
                             Metadata.DeployCallbackContext context) {
        if (result.status == Metadata.DeployStatus.Succeeded) {
            System.debug('success: '+ result);
        } else {         
            System.debug('fail: '+ result);
        }
    }
}


Example Snippet for creating Custom Meta Data:


Let's take custom metadata type "User_Creds__mdt" which has a custom field "Password__c".

To insert a record into the same we have to follow the same below.

    Metadata.CustomMetadata customMetadataObj =  new Metadata.CustomMetadata();
    customMetadataObj .fullName = 'User_Creds__mdt.Balaji_M';
    customMetadataObj .label = 'Balaji_M';

    Metadata.CustomMetadataValue customFieldObj = new Metadata.CustomMetadataValue();
    customFieldObj .field = 'Password__c';
    customFieldObj .value = 'XXXXX';

    customMetadataObj.values.add(customFieldObj);

    Metadata.DeployContainer containerObj= new Metadata.DeployContainer();
    containerObj.addMetadata(customMetadataObj);


    MetadataCallbackCls  callback = new MetadataCallbackCls ();
 
    Id jobId = Metadata.Operations.enqueueDeployment(containerObj, callback);


Output:




References:

https://developer.salesforce.com/docs/atlas.en-us.208.0.apexcode.meta/apexcode/apex_class_Metadata_CustomMetadata.htm#apex_class_Metadata_CustomMetadata


https://trailhead.salesforce.com/en/content/learn/modules/apex_metadata_api/apex_metadata_api_updates

https://trailhead.salesforce.com/en/content/learn/modules/custom_metadata_types_adv/cmt_develop

https://developer.salesforce.com/docs/atlas.en-us.208.0.apexcode.meta/apexcode/apex_interface_Metadata_DeployCallback.htm#apex_Metadata_DeployCallback_methods

Saturday, 8 June 2019

TrailHeadX 2019 Top Sessions

My Top Sessions in Developer Experience (DX) event, Salesforce DX Keynote,Salesforce Blockchain, product innovation updates, Golden Hoodie, Trailshred, Career Fair, Trailmoji

1. Salesforce Blockchain stole the show

Salesforce had lots of great new product and feature announcements at TrailheaDX ’19 (see the next top moment), but the one that stood out the most was Salesforce Blockchain — a new, low-code blockchain platform connected to CRM so organizations can securely collaborate and share data across third parties.

Salesforce audience of admins and developers at TrailheaDX ’19 were hungry for product innovation. And salesforce were happy to oblige. In addition to Salesforce Blockchain, we announced we open sourced Lightning Web Components and now offer a Trailhead badge in ethical AI development — a hot topic across the industry right now. We can’t wait to see everything our Trailblazers do with these innovations.

2. Three new Trailblazers joined the Golden Hoodie club

Receiving a Golden Hoodie on stage is a major acknowledgment — not only of the individual’s personal achievements but of how they’ve given back to the Trailblazer Community at large. At TrailheaDX ’19, we welcomed three new Trailblazers to the coveted Golden Hoodie club: Susannah St-Germain, Angela Mahoney, and Phillip Connaughton.

3. Trailshred rocked the house

Thousands of keynote attendees rocked out to LT Smooth’s rendition of Guns N’ Roses’ song, “Sweet Child of Mine” called “Sweet Code of Mine.” The sing-a-long was in honor of our newest feature on Trailhead giving learners the ability to add sound effects to their Salesforce org. Complete the Add Sound Effects to Your Salesforce Org Trail before the clock strikes midnight (PT) on August 7, 2019 and the special Trailshred community badge will mosh its way onto your profile.

4. Trailblazers refined their skills at the Career Fair

The TrailheaDX ’19 Career Fair gave both early and experienced Salesforce developers, consultants, admins, marketers, and analysts the opportunity to network with an array of employers in the Salesforce ecosystem. Trailblazers also attended sessions where they could touch up their resume, get advice from career coaches, and build a career plan.

5. Trailmoji gave us a new way to express ourselves

Salesforce’s Executive Vice President of Developer Relations and General Manager of Trailhead Sarah Franklin announced the new Trailmoji app during the main keynote, igniting an explosion of attendees customizing their personal Trailmoji look and sharing it on social media.


What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...