• Santosh Borfalkar 15
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name = "AmazeKart" type = "string" default = "AmazeKart"/>
    <aura:attribute name = "Computers" type = "string" default = "Computers"/>
    <aura:attribute name = "Mobiles"   type = "string" default = "Mobiles"/>
    <aura:attribute name = "Watches"   type = "string" default = "Watches"/>
    <aura:attribute name = "Cart"      type = "string" default = "Cart"/>
   <!-- <aura:attribute name = "pageReference" type = "object"/>
     <aura:handler name= "init" value = "{!this}" action= "{!c.doInit}"/>
     -->
    
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem>
            <lightning:icon iconName="standard:scan_card" alternativeText="amazeKart"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">{!v.AmazeKart}</h1>
                
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    
    <div class="slds-box slds-theme_shade slds-theme_alert-texture">
        <div class="slds-grid slds_align-center">
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p> <lightning:button label="Computers" class ="slds-m-top-medium" variant="brand"
                                              onclick="{!c.handleClick}"/></p>
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p><lightning:button label="Watches" class ="slds-m-top-medium" variant="brand"
                                             onclick="{!c.handleClick}"/></p>
                        
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p>
                           
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Mobiles" value= "Navigate" variant = "brand" onclick="{!c.handleClick}"/>
                        </p>
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-6">
                <span>
                    <div class="slds-box slds-box">
                        <p><lightning:button label="Cart" class ="slds-m-top-medium" variant="brand"
                                             onclick="{!c.handleClick}"/></p>
                        
                    </div>
                </span>
            </div>
        </div>
    </div>
</aura:component >
 
({
    handleClick : function(component, event, helper) {
       var navService = component.find("navService");
        var pageReferenceNav = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__mobiles',
            },
            state: {
                "myAttr": "attrValue" 
            }
        };
        pageReference.navigate(pageReferenceNav);
     },
   
    
})

Please help me with above issue

Write a trigger on the Lead object that populates a custom “Key Fields Populated” (API Name: Key_Fields_Populated__c) number field whenever the Lead is created. 
“Key Fields Populated” should count the total number of the following fields that are not null:
FirstName
LastName
Email
Phone
Website
Title

This is my code 

trigger KeyFieldsPopulated on Lead (before insert)
{
    List<Lead> leads = new List<Lead>();
    for (Lead L :trigger.new)
    {
        Set<String> fieldsPopulated = new Set<String>();
        
        fieldsPopulated.add(L.FirstName);
        fieldsPopulated.add(L.LastName);
        fieldsPopulated.add(L.Website);
        fieldsPopulated.add(L.Title);
        fieldsPopulated.add(L.Email);
        fieldsPopulated.add(L.Phone);
        integer count;
        
        for (string field : fieldsPopulated )
        {
            for ( integer i = 0 ; i< fieldsPopulated.size();i++)
            {
                if ( field !=null)
                    
                {
                    System.debug(field);
                        count += 1;
                      
                    L.Key_fields_Populated__c = count;
                }
            }
        }
    }
  }

 

Write a trigger on the Lead object that populates a custom “Key Fields Populated” (API Name: Key_Fields_Populated__c) number field whenever the Lead is created. 
“Key Fields Populated” should count the total number of the following fields that are not null:
FirstName
LastName
Email
Phone
Website
Title

This is my code 

trigger KeyFieldsPopulated on Lead (before insert)
{
    List<Lead> leads = new List<Lead>();
    for (Lead L :trigger.new)
    {
        Set<String> fieldsPopulated = new Set<String>();
        
        fieldsPopulated.add(L.FirstName);
        fieldsPopulated.add(L.LastName);
        fieldsPopulated.add(L.Website);
        fieldsPopulated.add(L.Title);
        fieldsPopulated.add(L.Email);
        fieldsPopulated.add(L.Phone);
        integer count;
        
        for (string field : fieldsPopulated )
        {
            for ( integer i = 0 ; i< fieldsPopulated.size();i++)
            {
                if ( field !=null)
                    
                {
                    System.debug(field);
                        count += 1;
                      
                    L.Key_fields_Populated__c = count;
                }
            }
        }
    }
  }

 
When I try to complete a hands-on challenge in Trailhead, I select a playground, navigate to setup, begin to do anything, and I'm kicked out to the Salesforce login screen. Help? Cookies and cache have been cleared, without remedy.