• About
  • Contact me!

Salesforce Everywhere

~ Blog on Salesforce Dev and admin stuff

Salesforce Everywhere

Category Archives: Uncategorized

How to get field values on onLoad in lightning-record-edit-form in LWC?

03 Monday Jan 2022

Posted by Mani in Uncategorized

≈ Leave a comment

Tags

LWC, onLoad

Let’s say we are using lightning-record-edit form in LWC to display/edit the data and we have a requirement to get the field values during the onLoad event of the form.

For instance, onLoad event calls handleOnLoad method and the code below shows the right approach to get the field values from the form based on the recordId:

handleOnLoad(event) {
        var record = event.detail.records;
        var fields = record[this.recordId].fields;(obviously we need to have the recordId declared as @api decorator and the lwc is placed on the record page. Please refer the link https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_record_context to read more about it)
        const assetName = fields.Name.value;      
        alert(assetName);
}

We can use template.querySelector as well(as given below), but it is not the right approach(rather not a good approach):

handleOnLoad() {
    let name = this.template.querySelector('.name').value;//in the html, we should have given class="name" for the name field
}

Hope this post is helpful and let me know for any questions. Thanks!!

How to check if the logged in user is a Guest user or not in APEX class?

08 Sunday Aug 2021

Posted by Mani in Uncategorized

≈ Leave a comment

Tags

APEX, Guest User check

To check if the logged in user is a Guest user or not in the APEX code, we can make use of the method isGuestUser() in Auth.CommunitiesUtil class where Auth is the namespace that provides an interface and classes for single sign-on into Salesforce and session security management.

        if(Auth.CommunitiesUtil.isGuestUser())
        {
            <call method X>
        }
        else
        {
            <call method Y>
        }

Also, there is a method isInternalUser() which returns true if the logged in user is an employee or the Internal user.

Hope this post is helpful!!

How to Close Quick action in LWC

07 Saturday Aug 2021

Posted by Mani in Uncategorized

≈ Leave a comment

Tags

LWC Quick Action, Quick Action

Recently, as part of Summer 21 release, Salesforce has given us an option to call the LWC directly from the Quick Action, earlier we had to call Lightning Component(LC) from the Quick Action and call the LWC from LC.

In my current project, I had created a Quick Action called “Edit” and to close the Quick Action when user clicks on Cancel button inside the modal, we had to do the following:

import { CloseActionScreenEvent } from ‘lightning/actions’;

Let’s say the method closeModal is called, when user clicks on Cancel button:

closeModal() {

this.dispatchEvent(new CloseActionScreenEvent());

}

To create the modal when user clicks on Edit button, we have not used lightning-quick-action-panel component(Beta) and used Modals blueprint in SLDS. Please refer the above link for creating a Quick Action and calling the LWC from it:

https://developer.salesforce.com/blogs/2021/05/learn-moar-with-summer-21-lwc-quick-actions

Documentation for the lightning-quick-action-panel is available in the below link:

https://developer.salesforce.com/docs/component-library/bundle/lightning-quick-action-panel/documentation

Thanks and see you all at the next post!!

P.S: Tried Anchor PodCast tool for this blog post:) and here is the link https://anchor.fm/manibalan-sampathkumar/episodes/How-to-Close-Quick-action-in-LWC-e15j8ta

Duration of the events in the Salesforce calendar can’t go beyond 14 days

15 Tuesday May 2018

Posted by Mani in Salesforce Configuration, Uncategorized

≈ Leave a comment

Tags

Calendar event

I have faced this issue recently in my current project [Later on, I realized that I was aware of this issue earlier perhaps 3 yrs ago when I was working in the consulting firm, my bad memory:)]. The requirement is to create the calendar event when the record is created in one of our Custom object based on the start and end date fields in it.

I created a process builder and it gets triggered when the new record is created in the Custom object. Immediate action in the process builder is to create a record in Event object.

It works fine when the difference in start and end date is less than or equal to 14 days (duration of the event is less than or equal to 14 days) else it throws an error ”

Vote for the below idea so that salesforce removes this limit in the calendar event:

https://success.salesforce.com/ideaView?id=08730000000Guw6AAC

Workaround: I created a flow to create events based on the start and end date. Suppose, start and end date span for 6 months(Start date=15/5/2018 and End date=15/11/2018), split them into 14 days and create events accordingly. So, in this case, I would have created 13 event records approximately from 15/5/2018.

Please comment below for any questions on this.

Tip # 25: Error in creating Lookup relationship

29 Sunday Apr 2018

Posted by Mani in Salesforce Configuration, Uncategorized

≈ Leave a comment

Tags

Lookup fields

Recently, when I tried creating a lookup relationship with the Product (Standard Object) from the custom object, I got the below error though I was not trying to create the Master Detail relationship:

You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master-Detail.

Moreover, the custom object was a new object and it did not have any records. I was bit confused and the error message is misleading as well. Then, after googling, it looks like you can create a lookup field to Product only if you allow to clear the field if the Product record is deleted(please check the below screenshot for your reference):

Lookuperror

Please let me know for any clarification.

Salesforce Certified Platform Developer I – Spring ’18 Release Exam

29 Sunday Apr 2018

Posted by Mani in Salesforce Certified Platform Dev Spring 18 release, Uncategorized

≈ Leave a comment

Tags

Spring 18

Please find the release notes link below:

http://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/salesforce_release_notes.htm

Q1

Q2

Q3

Q4

Q5

Salesforce Certified Platform App Builder – Spring ’18 Release Exam

29 Sunday Apr 2018

Posted by Mani in Salesforce app builder maintenance exam, Uncategorized

≈ Leave a comment

Tags

Spring 18

Please find the release notes link below:

http://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/salesforce_release_notes.htm

Q1

Q2

Q3

Q4

Q5

Salesforce Certified Administrator – Spring ’18 Release Exam

29 Sunday Apr 2018

Posted by Mani in Salesforce admin exam, Salesforce administration, Uncategorized

≈ Leave a comment

Tags

Salesforce Certified Administrator - Spring '18 Release Exam

Please find the release notes link below:

https://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/salesforce_release_notes.htm

Q1

Q2

Q3

Q4

Q5

Q6

Tip # 24: Password issue in ANT

23 Saturday Dec 2017

Posted by Mani in Uncategorized

≈ Leave a comment

I was using ANT Migration tool to deploy the components(e.g. Layouts, classes etc) from my machine to Sandbox last week. But, for some reason, though I have given the correct user name and password in build.properties file, it was giving me authentication error(Invalid username, password, security token; or user locked out).  I tried the same user name and password to log into Salesforce Sandbox using browser, I could login into it successfully. This looked very strange to me and then I found out the issue:

my password had two $ signs and for some reason, ANT was not able to recognise them. After, I changed the password by excluding the $ signs, it worked.

I thought of sharing this as it would help someone who face this issue since I had to spend about an hour to figure out the issue.

 

Salesforce Certified Platform Developer I

21 Saturday Oct 2017

Posted by Mani in Uncategorized

≈ 2 Comments

Recently, I cleared my Salesforce Platform Dev I exam and following are the tips from my side to clear the exam:

  1. If you have access to a Premier Online Training catalogue or Partner Training catalogue, you can go through the Cert Prep video from Salesforce and it will definitely be a very good starting point and will brush up your skills on the topics given in the exam guide . Link for the video – Certification Preparation for Platform Developer I
  2. Go through the questions given in SfdcStudy , Propofs and  Salesforcesteps
  3. Please note that some of the answers for the questions given in the above links might not be correct hence double check by googling or post them in comments section and I will try to answer them.

P.S: I found this link from the net today and I believe that it could be useful too https://quizlet.com/133435950/flashcards

← Older posts

Blog Stats

  • 111,809 hits

Archives

Recent Posts: Salesforce Everywhere

How to get field values on onLoad in lightning-record-edit-form in LWC?

Using Dynamic Actions

How to check if the logged in user is a Guest user or not in APEX class?

How to Close Quick action in LWC

Lightning component to filter Products and display results in lightning data table

Connect with me

  • View @manibalan_s’s profile on Twitter
  • LinkedIn

Developer links

  • Salesforce Developer website
  • Salesforce Success Community

Enter your email address and click on Follow us (below) to follow this blog and receive notifications of new posts by email.

Website Powered by WordPress.com.

  • Follow Following
    • Salesforce Everywhere
    • Already have a WordPress.com account? Log in now.
    • Salesforce Everywhere
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar