• Simi Tresa Antony
  • NEWBIE
  • 40 Points
  • Member since 2015
  • Software Engg


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 7
    Replies
When I am trying to fetch the Billing Address in the Account In , it gives such an error..
What is the fix for this if I have to dispaly the Account Address?

User-added image

VF Code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
          #result{color:green;font-size:25px;font-style:bold;margin:5px; width:100%;}
          
         
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                  
                       document.getElementById('result').innerHTML="<p>   Name :"+result.Name+"</p>"+
                                                                    "<p>   Website :"+result.Site+"</p>"+
                                                                    "<p>   Address :"+result.BillingAddress+"</p>" ; ????????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>
 
I am trying out  JS RemoteAction with the help of Apex dev guide.
I am trying to return the result of account , but the result.id or result.name is coming as null whereas result is not null. What is the reason? Please help..

VF code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                      
                       document.getElementById('result').innerHTML=result.id; --> null ????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock title="Javascript Remote Sample" >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>

Apex code
global with sharing class VFRemoteAction {
    
    public static Account account{get;set;}
    
    public  String accountName{get;set;}
    
    public VFRemoteAction(){
    }
    
    
    
    @RemoteAction
    global static Account  getAccount(String accountName){
      
         account = [SELECT id,name ,site FROM ACCOUNT where name=:accountName];
          return account; 

    } 
}
Question :

Create an Apex class that returns contacts based on incoming parameters

My answer: 

public class ContactSearch {
    public static  List<Contact> searchForContacts(String lastName,String postalCode){
     
       List<Contact> contacts = new List<Contact>();
        
       contacts = [Select Id, Name from Contact
                        where LastName = :lastName 
                        and    MailingPostalCode  like :('%'+postalCode+'%') ];

         return contacts;  
        
        }
}

I tested the answer from dev console. it works fine..

But I get this error from Trialhead , why? and it is saying about deletion why?

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0031a00000EiCzvAAF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Not authorized !!! : []
It is the first time I am using this feature.
I cannot save a new Cache Partition.
Whatever I type in, the Save button is shaded out.

User-added image
When I am trying to fetch the Billing Address in the Account In , it gives such an error..
What is the fix for this if I have to dispaly the Account Address?

User-added image

VF Code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
          #result{color:green;font-size:25px;font-style:bold;margin:5px; width:100%;}
          
         
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                  
                       document.getElementById('result').innerHTML="<p>   Name :"+result.Name+"</p>"+
                                                                    "<p>   Website :"+result.Site+"</p>"+
                                                                    "<p>   Address :"+result.BillingAddress+"</p>" ; ????????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>
 
I am trying out  JS RemoteAction with the help of Apex dev guide.
I am trying to return the result of account , but the result.id or result.name is coming as null whereas result is not null. What is the reason? Please help..

VF code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                      
                       document.getElementById('result').innerHTML=result.id; --> null ????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock title="Javascript Remote Sample" >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>

Apex code
global with sharing class VFRemoteAction {
    
    public static Account account{get;set;}
    
    public  String accountName{get;set;}
    
    public VFRemoteAction(){
    }
    
    
    
    @RemoteAction
    global static Account  getAccount(String accountName){
      
         account = [SELECT id,name ,site FROM ACCOUNT where name=:accountName];
          return account; 

    } 
}
Question :

Create an Apex class that returns contacts based on incoming parameters

My answer: 

public class ContactSearch {
    public static  List<Contact> searchForContacts(String lastName,String postalCode){
     
       List<Contact> contacts = new List<Contact>();
        
       contacts = [Select Id, Name from Contact
                        where LastName = :lastName 
                        and    MailingPostalCode  like :('%'+postalCode+'%') ];

         return contacts;  
        
        }
}

I tested the answer from dev console. it works fine..

But I get this error from Trialhead , why? and it is saying about deletion why?

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0031a00000EiCzvAAF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Not authorized !!! : []
Hi,

I am new to Angular js.......i have been building new vf page with angular page ..Facing to not getting output 

Here is my Page

<apex:page applyHtmlTag="false" sidebar="false" showHeader="false">
 <apex:form>
  <apex:includescript value= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/>

 <body>
  <script>
   angular.module('app',[]);
   .controller('Basic Controller', function()){
       this.name ="siva";
   
   }
   this.Hello: = function Hello:(){
   
   return this.name}
  </script>
   
   <div ng-app="app" ng-controller="Basic Controller">
   <p>Type the Your Name: </p>
   <p>Name: <input type="text" ng-model="name" placeholder="Enter your name"/></p>
       Hello: {{name}} 
   </div>
  </body>
   
</apex:form>
</apex:page>

Here am not getting my name as siva in Hello: siva

User-added image
  • October 20, 2015
  • Like
  • 1
Hi,

I am new to Angular js.......i have been building new vf page with angular page ..Facing to not getting output 

Here is my Page

<apex:page applyHtmlTag="false" sidebar="false" showHeader="false">
 <apex:form>
  <apex:includescript value= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/>

 <body>
  <script>
   angular.module('app',[]);
   .controller('Basic Controller', function()){
       this.name ="siva";
   
   }
   this.Hello: = function Hello:(){
   
   return this.name}
  </script>
   
   <div ng-app="app" ng-controller="Basic Controller">
   <p>Type the Your Name: </p>
   <p>Name: <input type="text" ng-model="name" placeholder="Enter your name"/></p>
       Hello: {{name}} 
   </div>
  </body>
   
</apex:form>
</apex:page>

Here am not getting my name as siva in Hello: siva

User-added image
  • October 20, 2015
  • Like
  • 1