Showing posts with label Record Type. Show all posts
Showing posts with label Record Type. Show all posts

Sunday, December 1, 2019

How to get Picklist values based on record type in Lightning Web Components(lwc)

To get picklist values based on record type we have to use getPicklistValuesByRecordType wire adapter.
Syntax
import { getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';

In this demo, I am using Account object, based on record type id I am getting picklist values of Industry field

HTML Code
<template>
    <lightning-card title="Picklist Vlaues based on Record Type">
      <div if:true={options}>
            <lightning-combobox name="progress"
                                label="Industry"
                                value={value}
                                placeholder="-Select-"
                                options={options}
                                onchange={handleChange} ></lightning-combobox><br/>
        
            you selected industry: <b>{value}</b><br/><br/>
      </div>
    </lightning-card>
    
</template>

Javascript Controller
import { LightningElement, track, wire} from 'lwc';
import { getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';

export default class PicklistValuesByRecordType extends LightningElement {
    @track value;
    @track options;

    @wire(getPicklistValuesByRecordType, { objectApiName: 'Account', recordTypeId: '012B0000000gTUOIA2' }) 
    IndustryPicklistValues({error, data}) {
        if(data) {
            this.options = data.picklistFieldValues.Industry.values;
        }
        else if(error) {
            window.console.log('error =====> '+JSON.stringify(error));
        }
    }

    handleChange(event) {
        this.value = event.target.value;
    }
}

Output

Sunday, December 23, 2018

How to get Record Type Developer Name in Apex?


This post explains how to get the record type developer name in the apex.

Getting Record Type Id using Developer Name

Let assume Record Type Developer Name  is "Customer_Account" on Account Object
you want id of the Record type use below sample code

Example

Id idRecordId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Customer_Account').getRecordTypeId();
System.debug('RecordTypeId based on Developer Name ---> '+idRecordId);
the above code returns the Record type Id based on developer name

Getting Record Type Developer Name

Let assume Record Type Name  is "Cluster Account" on Account Object
you want Developer Name of the Record type use below sample code

Example

String strRecordDevName = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Cluster Account').getDeveloperName();
System.debug('Record Developer Name ====> '+strRecordDevName);
the above code returns the developer name based on the record type name
Assume you have record type id instead of name use below sample code
String strRecordDevName = Schema.SObjectType.Account.getRecordTypeInfosById().get('012w0000000kgdfAAQ').getDeveloperName();
System.debug('Record Developer Name ====> '+strRecordDevName);
Let us know if have any queries
Happy Learning!!!

Saturday, July 21, 2018

Optimize The Sales process Using Path in Lightning Experience

In this Post Exploring The Sales Process Using Path in Lightning Experience.
  • Creating the Path based On Selected Object and Record Type.
  • adding the Path on Your Record Page.
  • How to add Chatter Links to Relevant Posts.

Monday, July 16, 2018

How To Check Page Layout Assignment Using SOQL Query

This post explains how to check page layout assignment using SOQL.

1. We can see the Page Layout is assigned to any profile or not.

2. We can see the RecordTypeId also, means we can See the Record Type assignment also.

Note:  Use Tooling API to Query, Please Select Tooling API while Querying.

If you are using Developer Console to query
Demo:
SELECT Layout.Name, Layout.TableEnumOrId, ProfileId, Profile.Name, RecordTypeId FROM ProfileLayout WHERE Layout.Name='<Layout Name>' AND Layout.TableEnumOrId = '<object Name OR object ID>'
Check below screenshot for more information about result.

Happy Learning!!