function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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"/>
    <style>
    .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;
    }
</style>
    <apex:remoteObjects >
        <apex:remoteObjectModel name="User" fields="Email,FirstName,LastName,Phone,Title"/>
    </apex:remoteObjects>
    
    <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>


    </div>
    
    <script>
        function sendemail(){
         var enteremail = document.getElementById("enteremail").value;
         console.log('1',document.getElementById("enteremail"))
         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;
        console.log('1',singleRequest)
        console.log('2'+singleRequest)
        var sendMailRes = sforce.connection.sendEmail([singleRequest]);
        //alert(sendMailRes);
        }
    </script>
    
</apex:page>

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.
pconpcon
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
pconpcon
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 .....