+ Start a Discussion
saran kumar 9saran kumar 9 

Please help me out on this - Implementing Global Actions with Visualforce Pages

where i am going wrong .......error i am getting  "

User-added image
here is the code

<apex:page docType="html-5.0" controller="sendbusinesscard">
<apex:includeScript value="/soap/ajax/24.0/connection.js"/>
<apex:includeScript value="/soap/ajax/24.0/apex.js"/>
    .mypage {
        font-family: "ProximaNovaSoft-Regular", Calibri;
        font-size: 110%;
        padding-top: 12px;
        width: 100%;
    .mypage input[type=text] {
        width: 100%;
        height: 35px;
        -webkit-appearance: none;
        padding: 0 8px;
        margin: 4px 0;
        line-height: 21px;
        background-color: #fff;
        border: 1px solid #ddd;
        border-radius: 3px;
        outline: none;
    .mypage button {
        -webkit-appearance: button;
        border-radius: 3px;
        display: block;
        padding: 12px;
        margin: 4px 0;
        width: 100%;
        background: #eee;
        border: solid 1px #ccc;
    <apex:remoteObjects >
        <apex:remoteObjectModel name="User" fields="Email,FirstName,LastName,Phone,Title"/>
    <div class="mypage">
        Title: <apex:outputText value="{!$User.Title}" /><br></br>
        First Name: <apex:outputText value="{!$User.FirstName}"/><br></br>
        Last Name: <apex:outputText value="{!$User.LastName}"/><br></br>
        Phone: <apex:outputText value="{!$User.Phone}" /><br></br>
        Email: <apex:outputText value="{!$User.Email}" /><br></br>
        Enter email: <input type="email" id="enteremail" /><br></br>
        <button onclick="sendemail()">Send Email</button>

        function sendemail(){
         var enteremail = document.getElementById("enteremail").value;
         sforce.connection.sessionId = "{!$Api.Session_ID}";

        var singleRequest = new sforce.SingleEmailMessage();
        singleRequest.replyTo = "jsmith@acme.com";
        singleRequest.subject = "sent through ajax test driver";
        var fName = "{!$User.FirstName}";
                var lName = "{!$User.LastName}";
        singleRequest.plainTextBody = "this test went through ajax - "+fName+' - '+lName;
        singleRequest.toAddresses = enteremail;
        var sendMailRes = sforce.connection.sendEmail([singleRequest]);

this is when i clicked check challenge

Challenge Not yet complete... here's what's wrong:
The 'BusinessCard' page isn't using the $User global variable.
Do you have a Apex class called 'sendbusinesscard' like your page references?
saran kumar 9saran kumar 9
@pcon ..no ...please give me the code for the apex class ...."sendbusinesscard" ..will create
Asking for this type of code is the opposite of what Trailhead is suppose to do.  Based on your code above (since you have a "sendemail" javascript method) you do no need a controller.  I would simply remove the 'controller="sendbusinesscard"' portion.  This should allow you to save your Visualforce page.
saran kumar 9saran kumar 9
thanks @pcon to remind me .....i have figured it out on how to do it .and will make sure from now that i will do each exercises and learn the required prming skills before attempting .....