Friday, 11 November 2016

Comparing old and new values in a trigger





In the Below Example making check box to true if status field is changed to closed own 

// Check a checkbox only when an Opp is changed to Closed Won!
trigger Updatecheck on Opportunity (before update) {

  for (Opportunity opp : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Opportunity oldOpp = Trigger.oldMap.get(opp.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldOppIsWon = oldOpp.StageName.equals('Closed Won');
    Boolean newOppIsWon = opp.StageName.equals('Closed Won');
    
    // Check that the field was changed to the correct value
    if (!oldOppIsWon && newOppIsWon) {
      opp.I_am_Awesome__c = true;
    }
  }
}

Wednesday, 9 November 2016



Debug logs for Site Guest User


Please follow below steps

  1. Ask the user to set a browser cookie with a domain of .force.com, a name of debug_logs, and any value. Refer to the documentation for your user’s browser for information on adding cookies. To add cookies, your user probably needs a browser plug-in or extension for web development.
    • To set a cookie for API requests made with Java code, use the URLConnection class and set the cookie value as follows.
      URL url = new URL("http://yourSite.force.com/");
      URLConnection con = url.openConnection();
      con.setDoOutput(true);
      con.setRequestProperty("Cookie", "debug_logs=debug_logs,domain=.force.com");
      con.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
      con.connect();
    • To set a browser cookie in Google Chrome™:
      1. Navigate to your site.
      2. Open the Chrome DevTools Console by pressing Ctrl+Shift+J (Cmd+Opt+J on macOS).
      3. Execute this command.
        document.cookie="debug_logs=debug_logs;domain=.force.com";
    • To set a browser cookie in other browsers, install a plug-in or extension.
  2. Find the name of your site’s guest user.
    1. From Setup, enter Sites in the Quick Find box, then select Sites.
    2. Select your site from the Site Label column.
    3. Select Public Access Settings | View Users.
  3. Set a user-based trace flag on the guest user.
    1. From Setup, enter Debug Logs in the Quick Find box, then click Debug Logs.
    2. Click New.
    3. Set the traced entity type to User.
    4. Open the lookup for the Traced Entity Name field, and then find and select your guest user.
    5. Assign a debug level to your trace flag.
    6. Click Save.

Tools for Lightning Web Component Development

 Below are the tools required for Web Component Development 1. Chrome Browser (Prefered) You can download it from Google 2. Visual Studio Co...