Friday 30 March 2018

Introducing Trailbed, the fun way to learn…while you sleep!

Did you know the average person spends one-third of their life sleeping? That’s a lot of zzz’s! Wouldn’t it be great if we could use this time to not only improve our physical health and well-being but to expand our minds at the same time?



Think about how much more productive you could be if you were actually learning while you were sleeping. Counting Cloudy the Goats, not sheep…

Don’t dream it, be it!

Now, you don’t have to waste time dreaming of your next job or promotion, you can finally achieve your goals through dreaming — literally! From the makers of Trailhead, we’re proud to introduce…Trailbed, the world’s first connected learning platform bed! Through our patented thought-recognition technology, the Trailhead profile of your dreams can be yours while you get all the beauty sleep you need.
Dreamforce was the inspiration. We thought, “How can we literally make people’s dreams come true?” The answer was so obvious. Whereas our mission to Mars added 40 minutes to your day, Trailbed can add eight hours plus of extra learning and earning to your night.

Put your REM to work

Just as memory foam is all about providing the best sleep possible, our Trailbeds are made of “memory-encoding foam.” You’ll benefit from the most productive sleep without losing any of the comfort. The top secret, mind-bending technology behind Trailbed helps focus your REM, the stage of sleep when you’re actively dreaming.
Instead of dreaming random, weird stuff like flying with a goat or conversing with a cloud, Trailbed borrows proven hacks from lucid dreaming so you can subconsciously redirect your restful sleep into effective learning.


This means, after you curl up under your Astro blankie in Trailbed, you’ll wake up not only feeling refreshed but with a refreshed profile too. Who cares about bedhead when you’ve got Trailbed? You’ll start your day with your online resume looking so sharp, you won’t even care about your hair!

And for those who like to catch 40 winks while on the go (or in the office), there’s the Trailbed Go neck pillow. Transcontinental flight? Cozy up with Trailbed Go and land in another time zone, with badges galore. Got some downtime between meetings? Get down with Trailbed Go and wake up, skilled up!

Sleeping is winning



And as if this news wasn’t big enough, we’re also giving you the chance to fall asleep with Astro! All you have to do is complete any Trailhead badge (sleeping or not) between March 30, 2018­ 12:00 a.m. PT — April 9, 2018 11:59 p.m. PT for a chance to win a set of exclusive Astro bedding*.


Plus, earning a badge during that timeframe unlocks the limited edition Trailbed community badge of your dreams.
Try the bedtime Storytelling and Communication module, learn how to chase the moon with remote teams while earning the Virtual Collaboration badge, or finally ace that dream where you’re in your birthday suit during an important presentation with Public Speaking Skills.

Whatever path you take, catch a ride with the Sandman to the land of Nod with Trailbed — and show your Trailbed love with a shout out post or video on social via #ThanksTrailbed.
Trailbed. It’s the cat app’s pajamas!
*NO PURCHASE NECESSARY TO ENTER OR WIN. VOID WHERE PROHIBITED. Sweepstakes open to eligible residents of: The United States (incl., District of Columbia), Canada (excluding Quebec), France, Germany, India, Ireland, Japan, the Netherlands, New Zealand, Spain, and United Kingdom. Must be 18+ (Japan 20+) to enter. Trailhead’s April Fools’ Day Sweepstakes starts 3/30/18 12:00 a.m. PT and ends on 4/9/18 11:59 p.m. PT (“Entry Period”). To enter the Sweepstakes you must earn badges on Salesforce Trailhead during the Entry Period in accordance with the Official Rules. The odds of winning depend on the number of eligible entries received during the Entry Period.

Friday 18 August 2017

An error occured while serving your request Email already registered in Salesforce Einstein

Whenever you are sign up for Einstein Platform Account and failed to download key

You can just reply to the same email and delete your account and again create a new one.

As I found there is no specific official document provided by the product team.


Tuesday 16 June 2015

Google Map Integration in Salesforce

VF Page Name : GMAPINT


<apex:page standardController="Account">

<script src="http://maps.google.com/maps?file=api">
</script>

<script type="text/javascript">

var map = null;
var geocoder = null;

var address = "{!Account.BillingStreet}, {!Account.BillingPostalCode} {!Account.BillingCity}, {!Account.BillingState}, {!Account.BillingCountry}";

function initialize() {
if(GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("MyMap"));
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl3D());

geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
if (!point) {
document.getElementById("MyMap").innerHTML = address + " not found";
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.bindInfoWindowHtml("Account Name : <b><i> {!Account.Name} </i></b>
Address : "+address);
}
}
);
}
}
</script>
<div id="MyMap" style="width:100%;height:300px"></div>
<script>
initialize() ;
</script>

</apex:page>


Now type in URL ".../apex/GMAPINT?id=YOUR_ACCOUNT_ID".

e.g. ".../apex/GMAPINT?id=001k000001QUrSR".

Salesforce Visualforce Page Code Generator

Visualforce page code with a button click, reduces time to write VF page again and again.

Install the package : https://login.salesforce.com/packaging/installPackage.apexp?p0=04t90000000Pqos

After installation just append “/apex/vfgenerator__codegenerator” in URL.






Object Name : Valid object API name (include namespace if any)
Record Type : Record type Id of object selected in Object Name
Type of Page :
  1. Edit : Code will be generated for the edit page of the object (according to “Record Type” layout if selected any).
  2. Detail : Code will be generated for the detail page of the object (according to “Record Type” layout if selected any)
  3. Custom Detail : Code will be generated for detail page according to the fields selected from UI
  4. Custom Edit : Code will be generated for edit page according to the fields selected from UI

In the above screen I have selected “Edit” as the type of page and “Account” in object, also provided my email. When I click “Generate Code” it displays like this



Just copy the code and paste it in new visualforce page. For get full formatted code enter your email address in given field.

Now lets try creating some custom visualforce page. Select “Custom Edit” in “Type of Page” and “Account” in “Object Name”. It will display a section “Select Fields”. Click on “Display Fields”, it will display all fields which are up datable by present user.





Tuesday 31 March 2015

JavasScript Remoting using VisualForce and Apex (SalesForce)

Remoting allows us to perform almost any apex logic via Javascript.

Let's consider Javascript remoting as similar as AJAX call done in normal websites built using PHP, ASP.NET or so.

So, let's see how we can do this.

In this demo, I have attempted to create a drop-down list having
options created dynamically based on the data from a custom object
and then calling a javascript function(at onchange event) which
refers to a remote action of the controller positionController written in apex.


The VisualForce Page Contains the code as below

<apex:page controller="poistionController" showHeader="false">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
//Function that calls the controller written in Apex and returns the required data.

function selectPosition(id){
 
var pos = document.getElementById(id).value;

    poistionController.getPositionDetails( pos,

    function(result, event){

         if (event.status && event.result) {

         // Creating the HTML content based on

         //the data returned from positionController and getPositionDetails method.

              var html = '<table>';

           html = html + '<tr><td>Position Name :</td>';

            html = html + '<td>'+event.result[0].Name+'</td></tr>';

            html = html + '<tr><td>Min Pay :</td>';

            html = html + '<td>'+'$'+event.result[0].Min_Pay__c+'</td></tr>';

            html = html + '<tr><td>Max Pay :</td>';

            html = html + '<td>'+'$'+event.result[0].Max_Pay__c+'</td></tr>';

            html = html + '</table>';

            $('#positionDetails').html(html);

      } else {

             alert(event.message);

      }

}, {escape:true});

}

 </script>

   <div align="center" width="550px">

      <h1>Congratulations</h1>

      This is my new Page : <b>VisualForce & Apex !!!</b><br />
  <apex:outputText value="Your maximum salary could be AT MAXIMUM {!pos.Max_Pay__c}"/>

      </b>

      <apex:form >

        <apex:selectList value="{!pos}" multiselect="false" size="1" id="positionTitle" onchange="selectPosition('{!$component.positionTitle}');">

         <apex:selectOptions value="{!options}"/>

         </apex:selectList>

      </apex:form>

   </div>

   <div id="positionDetails" align="center">

         <!-- Position details is displayed here. -->

   </div>

</apex:page>

 positionController contains codes as below.

global with sharing class poistionController {

      public Position__c pos{get;set;}
      public List<Position__c> title{get;set;}
      public List<Position__c> positions{get;set;}

      public poistionController() {

         pos = [select Max_Pay__c from Position__c where Name = 'Sr. Java Developer'];
      }
       /**

      * Method that creates the select option dynamically.

      **/

      public List<SelectOption> getOptions() {

          List<SelectOption> options = new List<SelectOption>();
          title = [select Position__c.Name from Position__c];
         //Creating an NULL option.
         options.add(new SelectOption('none','--Select--'));
         for( Position__c a :title ){

            options.add(new SelectOption(a.Name,a.Name));
         }
         return options;
      }

      /**

      * Remote action involved with Javascript remoting and is made global

      **/

      @RemoteAction
      global static Position__c[] getPositionDetails(String pos) {
          return [select Position__c.Name, Max_Pay__c, Min_Pay__c, Days_Open__c from Position__c WHERE                         Position__c.Name =: pos];

      }

}

In the above code for positionController, method named getOptions() is involved with creating options for drop-down list and getPositionDetails() is involved with fetching position details and acts as the remote action and is made global.

In the VisualForce page the javascript method selectPosition() refers to the remote action getPositionDetails() of positionController.

The portion of selectPosition() method in grey and italics is used for javascript remoting.

escape specifies whether the response from the Apex method will be escaped or not.

By default it's TRUE.

The syntax for javascript remoting is as given below,

[<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {

     // callback function logic

}, {escape:true});

Here, namespace is optional and is required if the class comes from an installed package.

In the controller, the Apex method declaration must be preceded with @RemoteAction annotation as shown below.

@RemoteAction

global static String methodName(String objectName) {

   //Logic written in Apex.

}

The methods with @RemoteAction annotation must be global and static.

The response from the server is in JSON format.

For this demo, it's something like as given below.

[{"type":"rpc","tid":3,"action":"poistionController",

"method":"getPositionDetails","result":{"serId":1,

"value":[{"serId":2, "value":{"Days_Open__c":142,"Name":"Sr. PHP Developer",

"Max_Pay__c":2500000.00,"Id":"a0190000002RNUJAA4", "Min_Pay__c":1500000.00}}]}}]

Enable Google Talk Sidebar in Salesforce


Let's see how we can enable the google talk sidebar component in Salesforce.

Go to http://www.google.com/a to sign up your domain for Google apps.
Log in to your salesforce account.
Click on the user menu (Your name at top-right of the salesforce page.) > Setup > Administration Setup > Google Apps > Settings

Click on "Edit" in the "Configure Google Apps Domain" section and fill up the "Google App Administrative Contacts" and your "Google Apps Domain" input fields. Now click save.
Now, in the "Activate Google Apps Services" section click on "Edit" link next to "Google Talk Sidebar Component".

Select the two checkboxes "Add the Google Talk component to salesforce.com sidebar." & "I agree to the salesforce.com Terms of Use for Google Apps."


Similarly, we can enable other Google Apps like Gmail, Google Docs etc. in salesforce.

These are some of the already available features in salesforce.com and we need to enable them for use. :-)

Uploading a Document in Salesforce Using Visualforce Page


Some times we need to upload files such as image files,word document etc, and also need to use its reference to use it in our VF page .

In that case we have to follow these steps

In that case we have to follow these steps

Step 1: Click on the document Tab

Step 2: Select the file from your local system to upload & also choose the folder in which you want to save it

Step 3: Keep its reference as a record to use it, if you want to access it directly form record

Instead of following these above steps, we can do these in only one visual-force page.

In this tip we will be understanding the procedure to upload a file into "Documents" using a Visual-force Page.

Hence, this topic would only cover uploading a file to "Documents" under a folder you desire.

<apex:inputfile>
 is the tag that is used to upload a file.



Sample Code

 FileUpload : Sample Visual-force page


 <apex:page controller="FileUploadController" showHeader="true" standardStylesheets="false">

<head>

<script type="text/javascript">


function SelectFile( fileUrl )

{

// window.opener.SetUrl( url, width, height, alt);

parent.SetUrl( fileUrl ) ;

}

</script>

</head>

<apex:messages />

<apex:form >

<apex:inputFile value="{!document.body}" filename="{!document.name}"/>

<br />

<apex:commandButton value="save" action="{!doUpload}" />

</apex:form>

<apex:pageBlock rendered="{!hasImage}" >

<img src="{!url}" width="200" height="160" />

<script>

this.onload = function() {

SelectFile('{!url}');

}

</script>

</apex:pageBlock>

</apex:page>




FileUploadController: Apex Class


 public class FileUploadController{

public Document document {get; set;}

public String url {get; set;}

public boolean hasImage {get; set;}



public FileUpload() {

hasImage = false;

document = new document();

}


 public PageReference doUpload() {

if (document.body != null) {

System.debug('@@@@@@@@ document:' + document.name);

 if (document.name != null) {

System.debug('@@@@@@@@ doSave');

 Document d = document;

System.debug(document);

System.debug('@@@@@@@@ document name: '+d.name);

System.debug(d);



d.folderid = UserInfo.getUserId(); //store in Personal Documents


 /*
d.folderid
 = 'any other id you want here'; // Fetch Id dynamically by using [Select Id from Folder where Name='My Images'].*/

System.debug('@@@@@@@@ document folder id: '+d.folderid);

d.IsPublic = true;

 try {

insert d;

url = DocumentUtil.getInstance().getURL(d);

hasImage = true;

} catch (Exception e) {

ApexPages.addMessages(e);

url = '';

}

 d.body = null;

 System.debug('@@@@@@@@ document object id: '+d.id);

String url = DocumentUtil.getInstance(d).getURL();

System.debug('######## document content type: '+d.type);

}

 }

 PageReference page = new PageReference('/apex/FileUpload');

//page.setRedirect(true);

return page;

}

 static testmethod void testFileUpload() {

FileUpload fu = new FileUpload();

fu.doUpload();

 fu.document.Name = 'test1';

fu.document.Body = Blob.valueOf('test1');

 fu.doUpload();

 }

 }