ABSYZ ABSYZ

  • Home

    Home

  • About us

    Who We Are

  • Our Expertise

    What we Do

  • Our Approach

    How We Do It

  • Products

    What We Made

  • Industries

    Who We Do It For

  • Clients

    Whom We Did It For.

  • Article & Blogs

    What Experts Think

  • Careers

    Join The Team

  • Get In Touch

    Let’s Get Started

ABSYZ

Create/Update Salesforce Picklist definitions using metadata API

Home / Article & Blogs / Salesforce / Integration / Create/Update Salesforce Picklist definitions using metadata API
By Team ABSYZ inIntegration, Metadata API, Salesforce
Introduction:

Imagine you have a customer who is not familiar with Salesforce and there is a need to add/update picklist values along with record types in the system, then you cannot expect him to follow the ideal steps (Setup->Object Manager->) to make the changes. So, this problem can be solved by using Lightning Component with Metadata API Service. This component enables a user to make the required changes  across multiple fields in your Salesforce instance with couple of clicks from the UI itself.

Unique features:

1. On click Create/Update picklist values.

2. On click assigning of picklist values to the record types.

3. On click removing of picklist values from the record types.

4. On click Update of records upon updation of picklist values.

Display UI:

 

Functionality:

Step1: Object Name – Displays all the object names present in your Salesforce instance

Select an Object

 

Step2: Picklist – Displays all the fields of the selected Object

Select a Picklist

 

Step3: Action – Displays two actions available Create/Update

Select an Action which you want to perform

 

Step3a: If Action selected is ‘Create’

Select Record Types: – Displays all the available record types

Select the Record Types to which you want to assign the new picklist value

 

Step3b: Description – Contains the name of the new picklist value

Give the name of the new picklist value here

 

Step4: Action – Displays two actions available Create/Update

Select an Action which you want to perform

 

Step4a: Picklist Value to Update – Displays the picklist values related to the picklist field selected

Select a picklist value which you want to update

 

Step4b: Select RecordTypes

Selected Options – Displays all the record type names in which the selected value is already present

Available Options – Displays all the record type names in which the selected value is not present

Select the record types to which the picklist value need to be assigned and remove the record types from which the picklist value need to be removed

 

Step4c: Description – Contains the updated name of the picklist value

 

Step5: Save

Clicking on

 

required operation will be performed.

UI:

UniversalPicklist.cmp

You have to build a lightning component to get UI as shown in the above snippet, you need to display five fields and a button.

 

Object Name: You can either hard code what all objects you want to display in this field or get all the objects using schema

 

Picklist: As soon as you select an Object Name you need to make a server call and get all the respective picklist fields available. You can get all the fields using schema

Action: Since we need only two different actions here, you can display those two values using <lightning:select>

 

  • Create:- If you select ‘Create’ you need to make another server call and get all the record types in that particular object and display them in a format shown in the above snippet using <lightning:dualListbox>
  • Update:- If you select ‘Update’ this means that you want to update an existing picklist value. So, here also you need to make a server call get all the picklist values for a selected picklist field. You can refer to this doc for getting the picklist values

Picklist Value to Update: The obtained picklist values will be displayed here. As soon as a picklist value is selected, you should get all the record types which has and which doesn’t have this picklist value and display on the UI accordingly, as shown in the snippet.

Description: This field holds the new or updated picklist value which user enters

Back end Logic:

MetadataApiService.apxc

You should have a MetadataApiService class.

Refer this link, you can use the same class.

UniversalPicklistController.apxc

Create/Update picklist value for custom fields: You can refer to this link for creating or updating the piclist values using metadataservices

Create/Update picklist value for standard fields: Refer the below code for standard fields:

 

//Read
        MetadataApiService.StandardValueSet StandardField = (MetadataApiService.StandardValueSet) service.readMetadata('StandardValueSet', new String[] { picklistapiname }).getRecords()[0];
        
        MetadataApiService.StandardValue sv = new MetadataApiService.StandardValue();
        sv.fullName = valueInTheDescription;
        sv.default_x = false;
        StandardField.standardValue.add(sv);
        
        // Update 
        List<MetadataApiService.SaveResult> lstResults = service.updateMetadata( new MetadataApiService.Metadata[] { StandardField });

Updating Record Types: You can refer to this link to update Record Types

UniversalPicklistCntrlSessionIdGenerator.vfp

Use this code for generating session Id

 

<apex:page >
    Start_Of_Session_Id{!$Api.Session_ID}End_Of_Session_Id
</apex:page>

UniversalPicklistControllerUtils.apxc

 

global class UniversalPicklistControllerUtils {
    global static String getSessionIdFromVFPage(PageReference visualforcePage){
            String content= visualforcePage.getContent().toString();
            Integer s = content.indexOf('Start_Of_Session_Id') + 'Start_Of_Session_Id'.length(),
                e = content.indexOf('End_Of_Session_Id');
            return userinfo.getSessionId();
    }
}

 

picklistSalesforce.comSFDC
314
Like this post
127 Posts
Team ABSYZ

Search Posts

Archives

Categories

Recent posts

BioAsia 2023 in Hyderabad: An Annual International Event

BioAsia 2023 in Hyderabad: An Annual International Event

The Role Of Marketing in Small & Medium Enterprises

The Role Of Marketing in Small & Medium Enterprises

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Salesforce For Retail: How Salesforce CRM Can Help Retailers

What is ChatGPT & How Does It Work?

What is ChatGPT & How Does It Work?

What Is Graphic Design? (Executive Summary 2023)

What Is Graphic Design? (Executive Summary 2023)

  • Previous PostComposite Resources in Salesforce
  • Next PostREST API call from Einstein Analytics Dashboard
    Composite Resources in Salesforce

Related Posts

Salesforce For Retail: How Salesforce CRM Can Help Retailers
Salesforce

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Introduction To Copado Devops Tool
Salesforce

Introduction To Copado Devops Tool

What is Salesforce Code Builder?
Salesforce

What is Salesforce Code Builder?

Automation in Healthcare And Its Benefits
Health Cloud Salesforce

Automation in Healthcare And Its Benefits

Leave a Reply (Cancel reply)

Your email address will not be published. Required fields are marked *

*
*

ABSYZ Logo

INDIA | USA | UAE

  • About us
  • Article & Blogs
  • Careers
  • Get In Touch
  • Our Expertise
  • Our Approach
  • Products
  • Industries
  • Clients
  • White Papers

Copyright ©2022 Absyz Inc. All Rights Reserved.

youngsoft
Copy
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “ACCEPT ALL”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent. Privacy Policy
Cookie SettingsREJECT ALLACCEPT ALL
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.

Functional

Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.

Performance

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.

Others

Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

SAVE & ACCEPT