Wednesday, September 25, 2019

Platform Developer I Certification Maintenance (Summer '19) Answer

Platform Developer I Certification Maintenance (Summer '19) Answer


Step1:


1.Which attribute can an app builder use to make a dependent picklist screen component in flow screens required?
A. {!$GlobalConstant.True}
2.How can an app builder determine what flow type best meets a specific business process?
A. Flow Templates
3.An app builder needs to notify an account owner of a new support case logged by a high-risk account. Which feature should the app builder use to send a custom notification to the account owner?
A.Notification builder
4.Agents need to be able to see email attachments easily when reviewing cases. Which related list can the app builder add to the case page layout?
A.Files related list
5.Where should an app builder go to create a Lightning letterhead after enabling enhanced letterheads for Lightning email templates?
A. App Launcher>Enhanced Letterhead

Step 2:


1.Setup-->quickfind Enter path settings-->clickon enable-->click on new path
 path Name: Milestones
 Object: Opportunity
 Record Type: Master
 Picklist: Stage
 Click Next in Step 2; we don't need to configure guidance for success

2.click on->A. When users reach a specific step in the path, help them celebrate their success with on-screen confetti.

Selected for Celebration: Closed Won
Celebration Frequency: Always
Ensure the path is Active and then click Finish
3. create opportunity record
 stage closed won

Friday, May 3, 2019

Platform Developer I Certification Maintenance (Spring '19) Answer

Platform Developer I Certification Maintenance (Spring '19) Answer

UNIT : Learn What’s New for Platform Developers in Spring ’19:-

1. Which Apex interface can be implemented to allow My Domain users to log in with something other than their username and password?
A. Auth.AuthToken

B. Auth.VerificationMethod
C. Auth.LoginDiscoveryHandler
D. Auth.MyDomainLoginDiscoveryHandler

2. With Spring '19, which method returns a list of OrgLimit instances used to investigate limits and their names, current value, and maximum value?
A. getAll() from the System.OrgLimit Class
B. getAll() from the System.OrgLimits Class
C. getInstances() from the System.OrgLimit Class
D. getInstances() from the System.OrgLimits Class

3. With Spring '19, which properties of an unhandled Apex exception are available in Event Monitoring log files?
A. Static variable state and stack trace
B. Exception type, name, and static variable state
C. Stack trace, user's location, and exception type
D. Exception message, exception type name, and stack trace


4. Which field of the SandboxInfo object is a reference to the ID of the SandboxInfo that served as the source org for a cloned sandbox?
A. SourceId
B. TemplateId
C. SandboxName
D. SandboxInfoId

5. You created a custom metadata type to handle your company's warranty policy. The custom metadata type's label is WarrantyRule. For it, you created a custom field labeled Warranty and a metadata record labeled Gold. What is the correct syntax to reference the value stored in the Gold metadata record?
A. $WarrantyRule.Gold.Warranty__c
B. $WarrantyRule__mdt.Gold.Warranty
C. $CustomMetadata.WarrantyRule.Gold.Warranty
D. $CustomMetadata.WarrantyRule__mdt.Gold.Warranty__c

Get Ready for the Hands-on Challenge:-

Challenge

Practice simplifying object- and field-level security checks with new Spring ’19 in Apex code


Solution

Challenge step 1: Create the Secret Key custom text field on the Contact object as specified in the Get Ready for the Hands-on Challenge section.


For this step, I hope you already created the field as per trailhead steps. If not follow the below.

Login to salesforce lightning

Click on the Gear icon and click the setup

Click Object manager menu item and search for Contact object, In the contact object go to Fields and relationships sub tab

Click the New button and enter below details

Choose Field type as Text and click Next button 


In the next screen, fill the details as mentioned below and click Next button

Field Label: Secret Key, Field Name: Secret_Key and Length: 255


In the next screen, Uncheck the Visible box for the “Standard User” profile when defining field-level security and click Next 

Click save



Challenge step 2: Create a new Apex class named SecureApexRest.

Click the Gear icon at the top right corner of the salesforce application and click Developer console option


In the Developer console window, click File > New > Apex class > Enter the class name SecureApexRest, click Ok



Challenge step 3: Copy and paste the SecureApexRest code provided above. This code is already secured with conventional field- and object-level access checks.


You can copy and paste the below-mentioned code in your newly created class

@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        try{
            List<Contact> results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];
            if (!results.isEmpty()) {
                result = results[0];
            }
        }catch(QueryException QE){
            throw new SecurityException('You don\'t have access to all contact fields required to use this API');
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}


Save the apex class.

No changes required for further steps of the challenge. Check the solution by clicking on Check challenge button in the trailhead page. 

Tuesday, April 23, 2019

Quick Send Email Lightning Component



In This Post We are created a salesforce lightning component. By this component we can send Emails.

Quick Email Send Lightning Component looks like :




In Gmail.

EmailSendController.apxc:  (Apex Class)


public class EmailSendController {
 @AuraEnabled 
    public static void sendMailMethod(String mMail ,String mSubject ,String mbody){
    
     List<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();     
  
     // Step 1: Create a new Email
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
    // Step 2: Set list of people who should get the email
       List<String> sendTo = new List<String>();
       sendTo.add(mMail);
       mail.setToAddresses(sendTo);
    
    // Step 3: Set who the email is sent from
       mail.setReplyTo('noreply@gmail.com'); // change it with your mail address.
       mail.setSenderDisplayName('salesforce User'); 
    
    // Step 4. Set email contents - you can use variables!
      mail.setSubject(mSubject);
      mail.setHtmlBody(mbody);
    
    // Step 5. Add your email to the master list
      mails.add(mail);
    
  // Step 6: Send all emails in the master list
     Messaging.sendEmail(mails);
   }   
}

EmailSend.cmp:   (Lightning Component)


<aura:component controller="EmailSendController" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,force:appHostable,flexipage:availableforallpagetypes">
   <!--Part 1 [for attribute declare]-->  
   <aura:attribute name="email" type="string"/>
   <aura:attribute name="subject" type="string"/>
   <aura:attribute name="body" type="string"/>
   <aura:attribute name="mailStatus" type="boolean" default="false"/>
   
   <!---Part 2 [header part] -->  
   <div class="slds-page-header" role="banner">
      <h1 class="slds-page-header__title slds-m-right--small slds-align-middle slds-truncate" title="this should match">
         Quick Email Send.
      </h1>
      <div class="slds-text-color--weak">by Saravanan</div>
   </div>
 
   <!---Part 3 [message display part] --> 
   <aura:if isTrue="{!v.mailStatus}">
      <div role="alertdialog" tabindex="-1" aria-labelledby="prompt-heading-id" aria-describedby="prompt-message-wrapper" class="slds-modal slds-fade-in-open slds-modal--prompt">
         <div class="slds-modal__container">
            <div class="slds-modal__header slds-theme--error slds-theme--alert-texture">
               <h2 class="slds-text-heading--medium" id="prompt-heading-id">Mail Status</h2>
            </div>
            <div class="slds-modal__content slds-p-around--medium">
               <div>
                  <p>Email Sent successfully to {!v.email}</p>
               </div>
            </div>
            <div class="slds-modal__footer slds-theme--default">
               <button class="slds-button slds-button--brand" onclick="{!c.closeMessage}">Close</button>
            </div>
         </div>
      </div>
      <div class="slds-backdrop slds-backdrop--open"></div>
   </aura:if>
   
   <!---Part 4 [mail fourm part]-->   
   <div class="slds-m-around--medium">
      <div class="slds-container--medium">
         <div class="slds-form--stacked">
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="CC">Email</label>
               <div class="slds-form-element__control">
                  <ui:inputEmail class="slds-input" aura:id="email"  value="{!v.email}" required="true" placeholder="abc@email.com"/>
               </div>
            </div>
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="CC">Subject</label>
               <div class="slds-form-element__control">
                  <ui:inputText class="slds-input" aura:id="subject"  value="{!v.subject}" placeholder="Subject"/>
               </div>
            </div>
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="textareaSample2">Mail Body</label>
               <div class="slds-form-element__control">
                  <lightning:inputRichText aura:id="body" value="{!v.body}" />
               </div>
            </div>
             <br></br>
            <div class="slds-form-element">    
               <button class="slds-button slds-button--brand" onclick="{!c.sendMail}">Send</button>
            </div>
         </div>
      </div>
   </div>
</aura:component>

 EmailSendController.js:  (js Controller)


({
    sendMail: function(component, event, helper) {
        // when user click on Send button 
        // First we get all 3 fields values
        var getEmail = component.get("v.email");
        var getSubject = component.get("v.subject");
        var getbody = component.get("v.body");
        // check if Email field is Empty or not contains @ so display a alert message 
        // otherwise call call and pass the fields value to helper method    
        if ($A.util.isEmpty(getEmail) || !getEmail.includes("@")) {
            alert('Please Enter valid Email Address');
        } else {
            helper.sendHelper(component, getEmail, getSubject, getbody);
        }
    },
 
    // when user click on the close buttton on message popup ,
    // hide the Message box by set the mailStatus attribute to false
    // and clear all values of input fields.   
    closeMessage: function(component, event, helper) {
        component.set("v.mailStatus", false);
        component.set("v.email", null);
        component.set("v.subject", null);
        component.set("v.body", null);
    },
})

EmailSendHelper.js:  (Helper)


({
    sendHelper: function(component, getEmail, getSubject, getbody) {
        // call the server side controller method
        var action = component.get("c.sendMailMethod");
        // set the 3 params to sendMailMethod method   
        action.setParams({
            'mMail': getEmail,
            'mSubject': getSubject,
            'mbody': getbody
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if state of server response is comes "SUCCESS",
                // display the success message box by set mailStatus attribute to true
                component.set("v.mailStatus", true);
            }
 
        });
        $A.enqueueAction(action);
    },
})
 

Test App:  (Lightning Application)


<aura:application extends="force:slds">
  <c:EmailSend/>
 <!-- here c: is org. namespace prefix-->
</aura:application>