Thursday, December 23, 2021

Get selected radio button value in LWC

This post explains how to get selected radio button in LWC. Below is demo of output :

Get selected radio button value in LWC

To use the radio button in LWC you have to use the lightning-radio-group tag. you can get the value of the selected radio button with the help of event.target.value .

RadioButton.cmp :

<template>
    <div style="background:white;padding:10px;">
        <lightning-radio-group name="RadioGroup"
                                label="SFDC"
                                options={options}
                                value={value}
                                onchange={valChange}
                                type="radio">
        </lightning-radio-group>
        <br/>
        <div>* Selected value is <b>{value}</b></div>
    </div>
</template>

RadioButton.js:

import { LightningElement } from 'lwc';
export default class RadioButton extends LightningElement {
    value = 'LWC';
    get options() {
        return [
            { label: 'LWC', value: 'LWC' },
            { label: 'SALESFORCE', value: 'SALESFORCE' },
            { label: 'LIGHTNING COMPONENT', value: 'LIGHTNING COMPONENT' },
        ];
    }
    valChange(event){
        this.value = event.target.value;
    }
}

RadioButton.meta:

<?xml version="1.0"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
</LightningComponentBundle>


Thanks, 
Lovesalesforceyes


Saturday, December 18, 2021

How to handle Identifier name is reserved error in apex json response

This post explain how to handle Identifier name is reserved error in apex json response.


Handle Identifier name is reserved error in apex json response

To handle the reserved identifier name in apex you have to replace the reserved variable with some non reserved variable and also change the wrapper variables accordingly. Refer the following code:


HandleReserveIdentifier.apx:

public class HandleReserveIdentifier {
    public static void handler(){
        String res = '{"Info": [{"name": "carry","currency": "INR"},{"name": "max","currency": "CLPs"}]}';
        res = res.replace('currency','currency1'); // Replace reserved identifier with some non-reserved identifier
        Information rapper = new Information();
        rapper = (InformationJSON.deserialize(res, Information.class);
        system.debug(rapper);
    }
    
     public class Information{
        @AuraEnabled public List<InfoInfo {get;set;}
    }
        public class Info
        {
            @AuraEnabled public String name{get;set;}
            @AuraEnabled public String currency1{get;set;}
        }
}


Thanks, 
Lovesalesforceyes

Wednesday, December 15, 2021

How to schedule salesforce certification exam

This post explains how to schedule a salesforce certification exam. 1.) Go to https://www.webassessor.com 2.) Create a new account and enter all the valid information. If you already have an account, simply login. 3.) After that click on Register for an exam tab.

How to schedule salesforce certification exam

4.) Choose the exam type which you want to give. 5.) After that you will see two options onsite and online. If you want to give the exam at the exam center click on site otherwise if you want to give the exam at your place then select online. 5.) After that you have to select the date and time when you want to give the exam. Date and time shown there is according to your country. 6.) Complete the payment process. That's it. 7.) Before the exam, complete your biometric process and install sentinel software. You will receive the mail regarding your scheduled exam in which there are few important links regarding exam and required requirements. 


Thanks, 
Lovesalesforceyes


Wednesday, December 8, 2021

PD1 Important questions Part 1

 1.) A developer creates a custom exception as shown below:

public class partiyException extends exception{}

what are two ways the developer can fire the exception in apex ?

choose 2 answers

A. throw new parityException('parity does not match');

B. new ParityException('parity does not match');

C. new ParityException();

D. throw new ParityException();

Answer: A,D


2.) Which two sfdx commands can be used to add testing data into a developer sandbox?

Choose two answers

A. force:data:bulk:upsert

B. force:data:object:create

C. force:data:tree:import

D. force:data:async:upsert

Answer: A,C


3.) The following automation already exist on the Account object:

  • A workflow rule that update a field when a certain criteria is met
  • A custom validation on a field
  • A flow that updates related contact records
  • A developer creates a trigger on the account object

What should the developer consider while testing the trigger code?

A. The flow may be launched multiple times.

B. The workflow rule field update will cause the custom validation to run again.

C. Workflow rules will fire only after the trigger has commited all DML operations to the database.

D. The trigger may fire multiple times during a transaction.

Answer: D


4.) A salesforce administrator used flow builder to create a flow named "accountOnboarding". The flow must be used inside an Aura component.

Which tag should a developer used to display the flow in the component?

A. aura:flow

B. lightning:flow

C. aura-flow

D. lightning-flow

Answer: B


5.) What should a developer use to fix a lightning web component bug in a sandbox?

A. Developer console

B. Execute anonymous

C. Force.com IDE.

D. VS code

Answer: D


6.) A developer creates a lightning web component that imports a method within an Apex class. When a validate button is pressed, the method runs to execute complex validations.

In this implementation scenario, which artifact is part of the controller according to the MVC architecture?

A. XML file

B. HTML file

C. JavaScript file

D. Apex class

Answer: D


Thanks, 
Lovesalesforceyes

How to make text field read only in LWC and AURA

This post explains how to make text field read only in LWC and AURA salesforce. To make the field read only in lightning there are two ways :

  • readonly="true"
  • disabled = "true"

readOnly.html(LWC):

<template>
    <div style="padding-left:100px; width:300px;">
        <lightning-input type="text" label="This is read only field" value="Read only field" readonly/>
    </div>
    <div style="padding-left:100px; width:300px;">
        <lightning-input type="text" label="This is read only field" value="Read only field" disabled="true"/>
    </div>
</template>

readOnly.cmp(AURA):

<aura:component >
    <div style="padding-left:100px; width:300px;">
        <lightning:input type="text" readonly="true" value="Read only field" label="This is read only field" />
    </div>
    <div style="padding-left:100px; width:300px;">
        <lightning:input type="text" disabled="true" value="Read only field" label="This is read only field" />
    </div>
</aura:component>


OUTPUT :

How to make text field read only in LWC and AURA

Thanks, 
Lovesalesforceyes


Tuesday, December 7, 2021

How to use standard lightning icons in LWC and AURA salesforce

This post explains how to use standard lightning icons in LWC and AURA salesforce. Standard lightning icons are of five types and we can use these icons in our component with the help of lightning-icon tag.

  • Action Icon :  These are used to show actions which user can take.
  • Doctype Icon : These are used to show type of file.
  • Standard Icon : These are used to show standard objects and entities.
  • Utility Icon : These are used throughout the interface.
  • Custom Icon : These are used to represent custom object.

slds_Icons.html(LWC):

<template>
    <div>Action Icon : 
        <lightning-icon icon-name="action:approval" title="Approved" size="medium"></lightning-icon>
    </div><br/>
     <div> Doctype Icon :
         <lightning-icon icon-name="doctype:audio" title="Audio" size="large"></lightning-icon>
     </div><br/>
     <div> Standard Icon :
        <lightning-icon icon-name="standard:event" title="Event" size="large"></lightning-icon>
     </div><br/>
     <div> Utility Icon :
        <lightning-icon icon-name="utility:connected_apps" title="Connected" size="large"></lightning-icon>
     </div><br/>
    <div> Custom Icon :
         <lightning-icon icon-name="custom:custom1" title="custom1" size="large"></lightning-icon>
    </div>
</template>

slds_Icons.cmp(AURA):

<aura:component >
    <div>Action Icon : 
        <lightning:icon iconName="action:approval" title="Approved" size="medium" />
    </div><br/>
     <div> Doctype Icon :
         <lightning:icon iconName="doctype:audio" title="Audio" size="large" />
     </div><br/>
     <div> Standard Icon :
        <lightning:icon iconName="standard:event" title="Event" size="large" />
     </div><br/>
     <div> Utility Icon :
        <lightning:icon iconName="utility:connected_apps" title="Connected" size="large" />
     </div><br/>
    <div> Custom Icon :
         <lightning:icon iconName="custom:custom1" title="custom1" size="large" />
    </div>
</aura:component>


OUTPUT :


How to use standard icons in LWC and AURA salesforce


Thanks, 
Lovesalesforceyes


Sunday, December 5, 2021

How to get Id from URL in LWC

This post explains how to get Id from URL in LWC.

getParametersFromURL.html :

<template>
    <div class="slds-p-around_medium lgc-bg">
            <lightning-input type="text" label="Url " value={urlIddisabled="true"></lightning-input>
    </div>
</template>


getParametersFromURL.js :

import { LightningElement, track} from 'lwc';
export default class getParametersFromURL extends LightningElement {
    @track urlId;
    connectedCallback() {
        var urlParameters = window.location.href;
        var urlStateParameters = urlParameters.split('Opportunity/');
        var urlIDValue = urlStateParameters[1];
        urlIDValue = urlIDValue.split('/');
        this.urlId = urlIDValue[0];
    }
}



How to get Id from URL in LWC


Thanks, 
Lovesalesforceyes

Get selected radio button value in LWC

This post explains how to get selected radio button in LWC. Below is demo of output : To use the radio button in LWC you have to use the  li...