Friday, 30 October 2020

Bind Record Using Wrapper Class in Component | Opportunity, Account and Contact List

WELCOME TO SFDC4STUDENTS.COM 

Step 1 - Create Apex Class named OpportunityAccountContactController.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class OpportunityAccountContactController {
    @AuraEnabled
    public static string getOppWithAccAndCon(String oppId){
        OpportunityAccountContactListWrapper oppAccConWrapper = new OpportunityAccountContactListWrapper();
        Opportunity oppRecord = [SELECT Id, Name, AccountId FROM Opportunity WHERE Id =: oppId limit 1];
        if(oppRecord.Id != null){
			string strAccId = oppRecord.AccountId;
			Account accList = [SELECT Id, Name, BillingState, Website, Phone,
                                 (SELECT Id, FirstName, LastName, Email From Contacts)
                                 FROM Account WHERE Id =: strAccId];			
			
			oppAccConWrapper.opportunityRecord = oppRecord;
            oppAccConWrapper.accRecord = accList;
            oppAccConWrapper.contactList = accList.Contacts;
            oppAccConWrapper.contactCount = accList.Contacts.size();
        }
        return json.serialize(oppAccConWrapper);
    }
    
    // wrapper class with @AuraEnabled and {get;set;} properties 
    public class OpportunityAccountContactListWrapper{
		@AuraEnabled
        public Opportunity opportunityRecord{get;set;}
        @AuraEnabled
        public Account accRecord{get;set;}
        @AuraEnabled
        public List<Contact> contactList{get;set;}
        @AuraEnabled
        public Integer contactCount{get;set;}
    }
}

Step 2 - Create Aura Component named OpportunityAccountContactComponent.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<aura:component controller="OpportunityAccountContactController"  implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">  
    <aura:handler name="init" value="{!this}" action="{!c.initData}"/>
    <!-- Attributes declaration--> 
    <aura:attribute name="opportunityAccountContactWrapper" type="object"/>
    <aura:attribute name="recordId" type="Id" />
    
    <div class="slds-p-around--large">
        <h1 style="font-size:25px;">{!v.opportunityAccountContactWrapper.opportunityRecord.Name}</h1> 
        <h1 style="font-size:15px;">{!v.opportunityAccountContactWrapper.accRecord.Name}</h1> 
        <br/>
        <p style="color:red">Total Contacts = {!v.opportunityAccountContactWrapper.contactCount}</p>
        
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                        <div class="slds-truncate" title="First Name">First Name</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="First Name">Last Name</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Email">Email</div>
                    </th>
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.opportunityAccountContactWrapper.contactList }" var="con">
                    <tr>
                        <th scope="row">
                            <div class="slds-truncate" title="{!con.FirstName}">{!con.FirstName}</div>
                        </th>
                        <th scope="row">
                            <div class="slds-truncate" title="{!con.LastName}">{!con.LastName}</div>
                        </th>
                        <th scope="row">
                            <div class="slds-truncate" title="{!con.Email}">{!con.Email}</div>
                        </th>
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </div>
</aura:component>

Step 3 - Create Aura Component JavaScript Controller named OpportunityAccountContactController.

1
2
3
4
5
6
({
    initData: function(component, event, helper) {
        console.log('***Controller Called');
        helper.getAccountContactWrapperhelper(component, event, helper);
    },
})

Step 4 - Create Aura Component JavaScript Helper named OpportunityAccountContactHelper.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
({
    getAccountContactWrapperhelper: function(component, event, helper) {
      console.log('***helper Called');
      var a= component.get("v.recordId");
      console.log('***In helper'+a);
      //call apex class method
      var action = component.get('c.getOppWithAccAndCon');
        action.setParams({
            oppId : component.get("v.recordId")
        });
      action.setCallback(this, function(response) {
        //store state of response
        var state = response.getState();
        if (state === "SUCCESS") {
          //set response value in wrapperList attribute on component.
          component.set('v.opportunityAccountContactWrapper', JSON.parse(response.getReturnValue()));
        }
      });
      $A.enqueueAction(action);
    },
})

Step 5 - Create a Lightning Action Button on Opportunity Object.


Step 6 -  Add Action Button on Opportunity Record Page Layout.




Step 7 -  Go to any Opportunity Record. Then click the button from the Opportunity Record Page.


Step 8 -  See the bound data on the Modal Popup of Component.


Thanks for come to my Blog. If this post is helpful to you then share and follow to get a new coming SFDC4Students blog posts.

Tuesday, 27 October 2020

Create Rest API in Salesforce | Execute Rest API on Workbench

 Step 1: Create an Apex class for Rest API.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
@RestResource(urlMapping='/api/Account/*')
global with sharing class MyFirstRestAPIClass
{
    @HttpPost
    global static String doPost(String name,String phone,String AccountNumber ) 
    {
        Account acc = new Account();
        acc.Name = name;
        acc.Phone = phone;
        acc.AccountNumber = AccountNumber ;
        insert acc;
        
        return acc.id;
    }
}

Step 2: Open the Workbench and log in with Salesforce Credential.

Step 3: Click on "Utilities (1)" and then click on the "REST Explorer".



Step 4: Select the POST radio button (2).

Step 5: Use the REST API URL (3).

As you can see, the class is annotated with @RestResource(urlMapping='/api/Account/*).
The base endpoint for Apex REST is
https://instance.salesforce.com/services/apexrest/.

The URL mapping is appended to the base endpoint to form the endpoint for your REST service.
For example, in the class example, the REST endpoint is
https://instance.salesforce.com/services/apexrest/api/Account/.

Step 6: Use the Request Body in JSON format and click on the Execute button (4).

{
  "name" : "My Rest API Account",
  "phone" : "9876543210",
  "AccountNumber" : "54321"
}

Step 7: Finally you will get the response with status code 200 (5).

Thanks for spending your valuable time with us.

Saturday, 25 April 2020

Toggle Checkbox in Lightning Aura Component

Toggle Lightning Component:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<!--Toggle.cmp-->
<aura:component>
    <aura:attribute name="toggleValue" type="String"/>

  <label class="slds-checkbox_toggle slds-grid">
     <span>Save File in Salesforce related to Task. </span>
                            <ui:inputCheckbox aura:id="chkbox" class="slds-input"/>
     <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
     <span class="slds-checkbox_faux"></span>
     <span class="slds-checkbox_on">Enabled</span>
     <span class="slds-checkbox_off">Disabled</span>
     </span>
  </label>
</aura:component>

Toggle Lightning Component JS Controller:

1
2
3
4
5
6
7
8
<!--ToggleController-->

({
    selectChange : function(cmp, event, helper) {
        var checkToggleVal = cmp.find("chkbox").get("v.value");
        alert(checkToggleVal);
    }
})

Monday, 6 April 2020

How to Register Google reCAPTCHA for Website and Android?


Introducing reCAPTCHA v3

What is reCAPTCHA?

reCAPTCHA is a free service that protects your website from spam and abuse. reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to keep automated software from engaging in abusive activities on your site. It does this while letting your valid users pass through with ease.

We are excited to introduce reCAPTCHA v3, which helps you detect abusive traffic on your website without any user friction. It returns a score based on the interactions with your website and provides you more flexibility to take appropriate actions. See the blog for more details.

The reCAPTCHA advantage

Advanced Security
reCAPTCHA protects and defends

reCAPTCHA is built for security. Armed with state-of-the-art technology, reCAPTCHA is always at the forefront of spam and abuse fighting trends so it can provide you an unparalleled view into abusive traffic on your site.

Ease of use
Easy for People. Hard for Bots.

Purposefully designed. And actively aware. reCAPTCHA knows when to be easy on people and hard on bots.

Creation of Value
Help everyone, everywhere - One CAPTCHA at a time.

Hundreds of millions of CAPTCHAs are solved by people every day. reCAPTCHA makes positive use of this human effort by channeling the time spent solving CAPTCHAs into annotating images and building machine-learning datasets. This in turn helps improve maps and solve hard AI problems.

Please follow these steps to register the Google reCaptcha.

Step 1. Click Here to reCaptcha Register. If asked to log in then please log in with your Google Gmail Account.

Step 2. Fill in all the fields and accept the T&C (After Verify).

Step 3. Submit the form.

Step 4. When you will submit your form then you will get a new window where will your two keys.
          SITE KEY - Use this site key in the HTML code your site serves to users.
           For Client Side Integration.

           SECRET KEY - Use this secret key for communication between your site and reCAPTCHA.
          For Server Side Integration.

Thursday, 23 January 2020

Amazing Facts of Salesforce


1. The Salesforce Tower, also known as Transbay Tower, in San Francisco is the tallest building in the Bay Area and the second tallest in the United States.

2. Salesforce has a band called Apex & the Limits that are made up of current Salesforce MVPs.

3. Salesforce was named the world’s most innovative company by Forbes 4 times in a row, from 2011 to 2014.

4. Marc Benioff is the cousin of David Benioff, the Game of Thrones TV Series creator.

                                

5. BOLDforce is Salesforce’s Black Organization for Leadership & Development that aims in developing educational youth programs to help create education and awareness around diversity and inclusion.

6. There are over 3,500 apps on the Salesforce AppExchange.

7. Radical Apex Developers (RAD) Women is a community group that has been teaching women to code on the Salesforce platform.

8. Salesforce invented the 1/1/1 Model – Salesforce pioneered the Pledge 1% model of integrated corporate philanthropy that is all about dedicating 1% of equity, product, or employee time back into the community.

9. Salesforce offers an Education Reimbursement Program that reimburses employees’ cost of fees, tuition, and books up to $5,000 per year.

10. Salesforce offers job training and career accelerator program for military service, members, veterans, and spouses called Vetforce.

11. AppExchange from Salesforce was launched in 2005, 3 years before Apple’s App Store.



12. Time magazine was acquired by Salesforce founders for $190 million.

13. Salesforce ranked #1 on the Fortune 100 Best Companies to work for.

14. At just 26 years of age, Marc Benioff was the youngest Vice President of Oracle.

15. Dreamforce, the biggest Salesforce event of the year, was first launched in 2002 and held in San Francisco every year.

16. Salesforce’s largest acquisition was Mulesoft for a whopping $6.5 billion.

17. Salesforce Trailhead leads the field of gamification and it makes the learning process fun for participants at the same time by helping them complete Trailheads and earn badges along the way.


18. Salesforce has an entire community designed to bring together people with various disabilities called Abilityforce.

19. Salesforce has its own community called the IdeaExchange where you can suggest and vote on ideas from fellow Trailblazers.

20. Salesforce has its personal online shop for swags called the Salesforce Store.

21. There are currently a total of 22 Salesforce Certifications available.

22. Salesforce has its own user-generated community for Q&A on Twitter called AskForce.

23. Salesforce has acquired over 50 companies since its inception in 1999.

24. ExactTarget was acquired by Salesforce for $2.5 billion in 2013 and later became the well-known Salesforce Marketing Cloud.

25. Salesforce acquired Demandware for an unprecedented sum of $2.8 billion in 2016 and renamed it Salesforce Commerce Cloud.


Thursday, 2 January 2020

Push Notification Using Automation in Salesforce

Hi folks, Today we will learn how to we can get a bell notification when the automation will fire in Salesforce.

Push notification — An alert appears on the user's mobile device when a user has installed the Salesforce app for Android or iOS. These alerts can consist of text, icons, and sounds, depending on the device type.

1. From the Home tab, type "Custom Notifications" in the Quick Find Box and then click on Custom Notifications link which is under the "Notification Builder".


2. Click on the New button and fill in the Custom Notification Name (API Name will auto-populate) and check the Supported Channels. It can be Desktop or Mobile or both according to your use. I will suggest for check both.


3. Type Process Builder from Quick Find Box and then Select.


4. Click on the New button and fill in the "Process Name" (API Name will auto-populate).
Select A Record Changes from "The process starts when" section and then click the Save button.


5. Click on Add Object, Select your object i.e. Contact. Select "Start The Process" according to your condition.


6. Click on Add Criteria. Fill in the "Criteria Name" and "Set Conditions".


7. Click on Add Action. Select the "Action Type" Send Custom Notification and then fill in the "Action Name".
In "Notification Type", Select your previously created custom notification "Bell Notification".
In the "Notification Recipient" section, select whoever will receive the push (bell) notification.

i.e. "Queue". Here "My_Queue" is the Salesforce Queue API name where we can add multiple users and they will receive the bell notification at the same time.


8. On the Notification Title and Notification Body section, you need to fill in the message as well as you can also Merge the object field.


When you will click on the "Merge Field" then you will see the below popup as per the image. From here you can add the field that will get the real data from the record when the Process Builder will fire.


9. When all will complete then click on the Save button.

10. Activate your Process Builder and try to fire it.



If you have done the same thing from this post then you need to go to any Contact record and update the email.

You will receive a push notification (In this case the "Queue" users will receive the push notification).


 We have not tested the custom notification on mobile devices. Let's start the process. Thanks for following this post as well as these steps. I think this is very helpful to you. If you have any queries regarding this step then please comment.

Total Pageviews