Search This Blog

Friday, January 22, 2021

Thursday, January 21, 2021

How to retrieve validation rule using package.XML in vs code Salesforce - Salesforce Globe For You

 How to retrieve validation rules using package.xml in vs code salesforce  - Salesforce Globe For You 

Problem: Assume a validation Mobile_Number_Required is written on the Lead object.Now we need to retrieve that validation rule in vs code tool using package.xml



Solution: Use name as ValidationRule and member as objectName.validationName as shown below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata"><types>

     <members>Lead.Mobile_Number_Required</members>

        <name>ValidationRule</name>

    </types>

    <version>48.0</version>

</Package>

Output:



Tuesday, January 5, 2021

How to iterate a list in lwc component Salesforce - Salesforce Globe For You

 How to iterate a list in lwc component Salesforce?  - Salesforce Globe For You 


Solution: Use for:each attribute to iterate the list in lwc component.

Example:

iterateListInLWC.html

<template>

    <lightning-card title="Following are the months present in a year" icon-name="custom:custom14">

        <ul class="slds-m-around_medium">

            <template for:each={months} for:item="month">

                <li key={month.Name}>

                    {month.Name}

                </li>

            </template>

        </ul>

    </lightning-card>

</template>

iterateListInLWC.js

import { LightningElement } from 'lwc';

export default class IterateListInLWC extends LightningElement {

    months = [

        {

            Name: 'January',

        },

        {

            Name: 'February',

        },

        {

            Name: 'March',

        },

        {

            Name: 'April',

        },

        {

            Name: 'May',

        },

        {

            Name: 'June',

        },

        {

            Name: 'July',

        },

        {

            Name: 'August',

        },

        {

            Name: 'September',

        },

        {

            Name: 'October',

        },

        {

            Name: 'November',

        },

        {

            Name: 'December',

        },

    ];

}

iterateListInLWC.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">

    <apiVersion>50.0</apiVersion>

    <isExposed>true</isExposed>

    <targets> 

        <target>lightning__AppPage</target>

        <target>lightning__RecordPage</target>

        <target>lightning__HomePage</target>

    </targets>

</LightningComponentBundle>

Output: