• Ravikant kedia
  • NEWBIE
  • 441 Points
  • Member since 2014

  • Chatter
    Feed
  • 11
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 18
    Questions
  • 106
    Replies
Hi - when doing the challenge "Bulk Apex Trigger" in Trailhead I get the error message :"Executing against the trigger does not work as expected."

I have checked the name of the class, task name as mentioned in the challenge description.

I have copied the code below :

trigger ClosedOpportunityTrigger on Opportunity (before insert, before update) {
  List<Task> taskList = new List<Task>();

    //If an opportunity is inserted or updated with a stage of 'Closed Won'
    // add a task created with the subject 'Follow Up Test Task'.
    for (Opportunity opp : [SELECT Id,Name FROM Opportunity
                     WHERE Id IN :Trigger.new AND StageName = 'Closed Won']) {
       //add a task with subject 'Follow Up Test Task'.
       taskList.add(new Task(Subject='Follow Up Test Task', WhatId = opp.id ));                
  }
                          
    if (taskList.size() > 0) {
        insert taskList;
    }



Thank you
Pierre-Alain


 
HI All,
please help me out for the bellow method how to write test class.

   public void delWrapper(){
   
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));         system.debug('rowNum '+rowNum );         wrappers.remove(rowNum);  // here wrappers is pageblockTable method     
        system.debug('wrappers&&&&&&&&&&'+wrappers);        
        lstacc1 =[Select id,Name from Family__c where id=:dcid];         
         system.debug('lstacc1'+lstacc1 );        
        delete lstacc1;
}
IN test class it showing Error ::Arguments can not be null;
test class
obj.rowNum = Integer.valueOf(apexpages.currentpage().getparameters().put('index','1'));
obj.delWrapper();// calling method from test clss

2.constructor.

  Public deosearchpage(){
   AccountID=apexpages.currentpage().getparameters().get('accId');
  if(AccountID!=null){
try{
     Acc=[select id ,name from account where id=:AccountID];
   }
catche(){

  }
}
}
HOw to write test class for above once also
  • March 29, 2015
  • Like
  • 0
what is test class and how to write a test classes for Apex and Trigger in salesforce?

please give me deep Explanation about on it.

Thanks,
Naveen
User-added image
Hi all,
please let me know,how to get all contacts of an account on click on count of contact as show above screenshort.
please let me know what i missing in below code

apex class...........

public with sharing class sampleCode {

public List<wrapper> wrapperList{get; set;}
public List<Contact> contactsInformation { get; set; }
public Id selectedCountOfContact { get; set; }


public sampleCode(){
         wrapperList=new List<Wrapper>();
         for(Account a:[select Name,(select id,name from contacts),(select id from opportunities)  from Account limit 5])
         {
           Wrapper w1=new Wrapper();
           w1.Name=a.Name;
           w1.Con=a.contacts.size();
              
           w1.Opp=a.opportunities.size();
           wrapperList.add(w1);
         }       
}

class Wrapper{
    public String Name{get; set;}
    public Integer Con{get; set;}
    public Integer Opp{get; set;}   
 }
 
public List<Account> getMyAccounts() {
return [SELECT Id, Name,Industry, AccountNumber FROM Account ORDER BY
LastModifiedDate DESC LIMIT 10];
}

public void accountClicked() {
contactsInformation = [SELECT FirstName, LastName FROM Contact
WHERE AccountID = :selectedCountOfContact];
  }
}


and page.........



<apex:page controller="sampleCode">

<apex:form >

<apex:outputPanel id="ContactDetail">

<apex:repeat value="{!contactsInformation}" var="contact">
<p>{! contact.FirstName & ' ' & contact.LastName}</p>
</apex:repeat>
</apex:outputPanel>

<apex:pageBlock >
     <apex:pageBlockTable value="{!wrapperList}" var="b" >
                         <apex:column value="{!b.Name}" headerValue="Account Name"/>
                   
                         <apex:column headerValue="Total Contacts">  
                             <apex:commandlink action="{!accountClicked}" rerender="ContactDetail">
                             <apex:outputText value="{! b.con}"/>
                             <!--  <apex:param name="id" value="{!b.id}" assignTo="{!selectedcountofcontact}"/>-->
                         </apex:commandLink>                             
                         </apex:column>
                         
                         <apex:column headerValue="Total Opportunities">
                             <apex:commandLink value="{!b.Opp}"/>
                         </apex:column>                     

    </apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>
 
i have  created a vf  page which picks up account fields like email , contact information , mailing city,street , state etc and  edit the required field.
and wen user  clicks create case button a new case shud b created and those field should be populated inside case object (like email.mailing street et)


<apex:commandButton value="Create Case" action="{!createCase}"  rendered="{!showButton}" style="margin-left: 69%;margin-right: 22.2%;"/>

</div>

and here is one example of a field
 <apex:inputfield value="{!account.Email__c}" style="margin-left: 30%"  rendered="{!!showField}"></apex:inputfield>
and many more are there for city ,state.

class:

public account acc{get;set;}

public void createCase()    
{  case c = new case();
  
   c.Phone_Type_1__c=acc.Phone_Type_1__c; //************line 47
   c.Phone_Type_2__c=acc.Phone_Type_2__c;
   c.Phone_Type_3__c=acc.Phone_Type_3__c;
   
   
   c.Phone_1__c=acc.Phone_1__c;
   c.Phone_2__c=acc.Phone_2__c;
   c.Phone_3__c=acc.Phone_3__c;
   
   c.Mailing_Address__c=acc.Mailing_Address__c;   
   c.Mailing_City__c=acc.Mailing_City__c;   
   c.Mailing_State__c=acc.Mailing_State__c;
   c.Mailing_Zip__c=acc.Mailing_Zip__c;
   
   c.Email__c=acc.Email__c;
   
   

}

after making the changes wen i click create a case i get this error

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!createCase}' in component <apex:commandButton> in page editaccountpage: Class.EditaccountPage.createCase: line 47, column 1 //( i hv marked this line in code )
 
Hey guys,
I am trying to create visualforce pages from existing HTML code I have. Here is my apex so far:

<apex:page showHeader="false" standardStylesheets="false" sidebar="false">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../assets/ico/favicon.ico">

    <title>Login into the blah blah</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/overrides.css" rel="stylesheet">
    <link href="css/login.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
    <div id="perc-container">
    <div id="header">
      <div class="secondary-nav" style="background-color: #fff;"> 
        <div class="container">
          <div class="row">
            <div class="col-lg-12" style="background-color: white;"> 
                <button class="show-search">Search</button>
                <div class="global-search">
                    <form class="global-search-inner">
                    <input type="text" class="search-main"> 
                    <input type="submit" class="search-main-submit" value="" >
                    <span class="search-icon"></span> 
                    </form>
                                  
                </div>
                <ul class="nav navbar-nav">
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Contact Us</a></li>
                     <li><a href="#">Visit Us</a></li>
                </ul>
            </div>               
          </div>
        </div>
      </div>
      <div class="primary-nav">
        <div class="container">
          <div class="row">
            <div class="col-lg-12">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                  </button>
                  <a href="#" class="mobile-search-btn hidden-lg"></a>
                  <a class="navbar-brand logo" href="#"></a>
                  <a href="" class="mobile-login hidden-lg">Login</a>
                </div>
                <div class="mobile-search hidden-lg clearfix">
                    <div class="global-search">
                        <form class="global-search-inner">
                        <input type="text" class="search-main"> 
                        <input type="submit" class="search-main-submit" value="" >
                        </form>                                  
                    </div>
                </div>
                <div class="collapse navbar-collapse">
                  <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">Stuff</a></li>
                    <li><a href="#contact">Stuff</a></li>
                    <li><a href="#about">Submit Your Stuff</a></li>
                    <li><a href="#contact">Make an Appointment</a></li>
                   
                  </ul>
                </div><!--/.nav-collapse -->
              </div>
            </div>
          </div>
        </div>
    </div><!-- /#header -->

    <div id="main" class="landing">      
      
      <div class="section welcome-ctr">
        <div class="container">
            <div class="row">                 
                <div class="col-lg-12">
     <div class="backg-art">
    <img src="images/StuffLogo.png" alt="Stuff">
  
      <div class="form-contain">
        <form class="form-login" role="form">
          <input type="username" class="form-control" placeholder="username" required autofocus>
          <input type="password" class="form-control" placeholder="password" required>
          <button class="btn btn-sm btn-primary btn-block forgot-password btn-width btn-shade" type="submit">Login</button>
          <label class="forgot-password"><a href="#">Forgot Password</a></label>
          <label class="checkbox">
            <input type="checkbox" value="remember-me">
            Remember me</label>
        </form>
      </div>
    </div>
                   <!-- /.row --> 
                                    
                </div>
                                
            </div>                       
        </div>
      </div><!-- /.section -->  

    </div><!-- /#main -->
    <div id="footer" class="section">
        <div class="container hidden-xs">
            <div class="row"> 
                <div class="special-col">
                    <h2>Quick Links</h2>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">Stuff</a></li>
                    <li><a href="#">Discussion</a></li>
                    <li><a href="#">Submit Your Stuff</a></li>
                    <li><a href="#">Our Process</a></li>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Site Map</a></li>
                </div>
                <div class="special-col">
                    <h2>Stufforate</h2>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Site Map</a></li>
                    <li><a href="#">Stuffs</a></li>
                    <li><a href="#">Legal</a></li>
                    <li><a href="#">Contact Us</a></li>
                    <li><a href="#">Privacy Policy</a></li>
                    <li><a href="#">Stuff Store</a></li>
                </div> 
               
               
            </div>                       
        </div>
        <div class="container visible-xs">
                <div class="row">
                    <div class="panel-group" id="accordion">
                              <div class="panel panel-default">
                                <div class="panel-heading">
                                  <h2 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Quick Links<span></span></a></h2>
                                </div>
                                <div id="collapseOne" class="panel-collapse collapse">
                                  <div class="panel-body">
                                  <li><a href="#">Home</a></li>
                    <li><a href="#">Stuff</a></li>
                    <li><a href="#">Discussion</a></li>
                    <li><a href="#">Submit Your Stuff</a></li>
                    <li><a href="#">Our Process</a></li>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Site Map</a></li>
                                  </div>
                                </div>
                              </div>
                              <div class="panel panel-default">
                                <div class="panel-heading">
                                  <h2 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">Stuff Solutions<span></span></a></h2>
                                </div>
                                <div id="collapseTwo" class="panel-collapse collapse">
                                  <div class="panel-body">
                                      <li><a href="#">About Us</a></li>
                    <li><a href="#">Site Map</a></li>
                    <li><a href="#">Stuff</a></li>
                    <li><a href="#">Legal</a></li>
                    <li><a href="#">Contact Us</a></li>
                    <li><a href="#">Privacy Policy</a></li>
                    <li><a href="#">Stuff Store</a></li>
                                  </div>
                                </div>
                              </div>
                              
                            </div>
                </div>
            
        </div>
        <div class="container">
            <div class="row"> 
                <p class="copyright">©2014 Stuff Services, Inc.</p>
            </div>                       
        </div>
    </div><!-- /.footer -->
    <div id="video-modal" role="dialog" class="modal fade">     
            <div class="modal-content">
            <button type="button" class="close" data-dismiss="modal"><span>x</span></button>        
            <video autoplay src=""></video>
            </div> 
    </div>
    </div>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/lib/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/settings.js"></script>
  </body>
</html>

</apex:page>

I get the following error:
Error: StuffCenterLogin line 24, column 4: The element type "link" must be terminated by the matching end-tag "</link>"
Error Error: The element type "link" must be terminated by the matching end-tag "</link>".

Any ideas?
I'm new to visualforce

Thanks!
Please explain the usage of different  scenario
Hi Guys,

Any body have using MAP Please find the code, How this code change to MAP?

Private void UpdatePriceListDate(List<Account> newAccounts){
        //Create the instance for the Account
        List<Account> ChildRecords = new List<Account>();
        //Variable Declaration
        string CurrentAccountNotes;
        string CurrentParentId;
        date PrilistCorrectdate;
       
        for (Account currentrecord : newAccounts) {
            //Getting the parentid, PriceListDate and Account notes
            CurrentParentId = currentrecord.id;
            PrilistCorrectdate = currentrecord.Price_List_Correct__c;
            CurrentAccountNotes =currentrecord.Account_Notes__c;
           
        }
      
        ChildRecords = [Select id,Parentid,Price_List_Correct__c,Account_Notes__c, from account where parentid = :CurrentParentId];
      
        for (Account childrecord : ChildRecords) {
            //Update the PriceList Date to Childrecord
            childrecord.Price_List_Correct__c = PrilistCorrectdate;
            //Update the Account Notes to Childrecord
            childrecord.Account_Notes__c = CurrentAccountNotes;
          
        }
        //Updata the Child Records
        update ChildRecords;
    }
}


Thanks...
i am creating visual force page , in which image needs to be saved taken from phone camara. i am able to take pic , but i  need help with saving these images to notes and attachment, i need to save contiuous 50 images in 50 pages linked one after another
Hi,

Can anyone explain me what the following exception refers.

'java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean'

I am not sure of where the exception occurs. Thanks in advance.

Today i found a error salesforce in salesforce  please take a look.Error like <a href=/dfghjk>
User-added image

 

Hi all,
        I am getting above problem when granting modify All permission in permission set . How i can solve above problem.
what is wrong with me? 
Thanks in Advance.
Hi all,
       In community some user not able to access report and 2 user that have modify all data permission can access that report. How i can make this report accessible for all user. I check all sharing rule  field level, and, object level security but still i am not able to access report on community how i can solve my problem , I also check roles and report flder for access. Any help appriciable.
I want to integrate salesforce with Xero how to authenticate and get access token in salesforce plese give me and idea or code to implemet it.
Thanks in advance.(Using rest api).
I want to get a custom setting value in site.com How i can do it . There are any possibility to access custom setting in site.com ??.
I want to develop a chrome extension but i have a problem that how to login in salesforce when click on button . First i made manifest file and then open popup it's working correctly . In this popup two text field one for username and other for password so now i want to login in salesforce when click on button.
I have a urgent requirement please help.
How to cover below test class code.
    String iso = userInfo.getDefaultCurrency();
        String symbol = null;
        if(iso == 'EUR'){symbol='€'; }
        else if (iso=='ALL') { symbol='Lek'; } 
        else if (iso=='USD') { symbol='$'; } 
        else if (iso=='ARS') { symbol='$'; } 
        else if (iso=='AWG') { symbol='ƒ'; } 
        else if (iso=='AUD') { symbol='$'; } 
        else if (iso=='BSD') { symbol='$'; } 
        else if (iso=='BBD') { symbol='$'; }
        return symbol;
    
I have  10 checkbox fields with  labels Checkbox1, Checkbox2, Checkbox3, Checkbox4, ------ So on .
And I have a formula field that return selected checkbox label with comma(,) separated values like Checkbox1, Checkbox2, Checkbox3, and so on.
Example : I select 4 chekbox , Checkbox 1, Checkbox 3, Checkbox 9, Checkbox 5 and formula will return Checkbox 1,Checkbox 3, Checkbox 5, Checkbox 9.
So how i can implement this functionality in minimum step as possible  .So please help me to resolve this issuse as soon as possible.
Thanks in Advance.
I want to use extjs in visualforce but i am getting error Uncaught ReferenceError: Ext is not defined i also added all library related to ext js but this time also getting same error so How to solve this error. I have a urgent requirement to solve this issue .
Hi all,
 I want to upload photo on facebook using rest api i made a request but i can't success. So how i can upload photo on facebook using rest api  i read  here https://developers.facebook.com/docs/graph-api/reference/v2.1/user/photos and made a request which is given below but i can't success.


            String bodyEncoded = EncodingUtil.base64Encode(file);
             bodyEncoded = bodyEncoded ;
             String boundary = '-------314159265358979323846';
             String delimiter = '\r\n--' + boundary +'\r\n';
             String close_delim = '\r\n--' + boundary;
              String message=''

             String body=boundary +'\r\n'+
            'Content-Disposition:form-data; name="source";filename="'+filename+'"\r\n'+
            'Content-Type: '+filetype+'\r\n'+
             bodyEncoded +'\r\n'+
             boundary;
             String encoded = EncodingUtil.urlEncode(body, 'UTF-8');
        
            System.debug('----------------------------------body is-------------\n'+body);
            HttpRequest req=new HttpRequest();
            req.setMethod('POST');
            req.setbody(body);
            
             req.setHeader('Content-Type', 'multipart/form-data; boundary="'+boundary+'"');
            req.setHeader('Content-length', String.valueOf(body.length()));
            
            req.setheader('Content-type', 'application/x-www-form-urlencoded');
            req.setHeader('Content-length',string.valueof(body.length()) );
             req.setHeader('Content-Encoding','base64');
            req.setTimeout(60000);
            req.setEndpoint('https://graph.facebook.com/v2.0/me/photos?access_token='+accesstoken );
            
            HttpResponse res = null; 
            http h= new Http();
            res= h.send(req);    
            system.debug( '------------upload photo----------------------'+res.getbody());  
    
I used Graph api for it. 
Hi all,
           I want to write cron expression for schedule job or perform some operation.
    
1)-Daily
             a)- Every week day
             b)- Every 1 days or Every 2 days so on.

2)-Weekly
             a)-  Recurs every 1 week(s) on or  Recurs every 2 week(s) on so on.
             b) - Days like sunday ,monday and so on.
3)- Monthly
              a)-On day (1-31) of every (1 or, 2,or,3 so on)   month(s).
              b)-On the (1-4, Last) day(sunday-saturday) of every  (1,2,so on )  month(s).
4)- Yearly
               a)- On every (Janury-December) (1-31)
               b)- On the (1-4, Last) day(sunday-saturday) of (Janury-December)
             

       
I want to send file on box.com using salesforce1  mobile application so i need authentication  using salesforce1 give me some idea so i can solve this issue.
I am doing integration salesforce with box.com so after uploading file i want the download that file.Like in google drive we set approval_prompt=force and response body contain webContentLink for to download that file.How i can get box.com downloadable link ?
Hello everyone,
                            I am doing integration salesforce with box.com when i uplod file that time first i convert blob into base 64 encoded string then send file using rest api after uploading  file my file in  not readable form it meanse file is encoded. And i am sending file in body as a blob and also try in body but i can't sucess. so give me some idea that how i can solve this issue.
   (Thanks in advance).
             
I have an `<apex:inputFile />` for selecting a PDF file from system. After selecting the PDF file I want to view  selected PDF. How can I do it.?
Please give me some idea for to do it.
I am making one project in which I send a file on Heroku via HttpRequest (including file in attachment) and I got response zip file now I want to store this zip file in static resources.

So how we can store zip file dynamically in static resources when we get zip file in HttpResponse ?
I am doing integration salesforce with facebook . After authentication i want to upload photo on facebook i made one visualforce page in which i select photo and pass to controller as a blob.
My code is------
public void uploadPhoto()
       {
           
             String bodyEncoded = EncodingUtil.base64Encode(file);
             System.debug('------------------------------------------'+bodyEncoded);
             // bodyEncoded='%7B'+bodyEncoded+'%7D';
           
             String boundary = '----WebKitFormBoundaryE19zNvXGzXaLvS5C'; 
            // String message=''

             String body=boundary + '\r\n'+
            'Content-Disposition : form-data; name="source"; filename="'+filename+'"\r\n'+
            'Content-Type : '+filetype+'\r\n'+
             bodyEncoded +'\r\n' +
             boundary;
        
       
            System.debug('----------------------------------body is-------------\n'+body);
            HttpRequest req=new HttpRequest();
            req.setMethod('POST');
            req.setbody(body);
       
            req.setHeader('Content-Type', 'multipart/form-data; boundary="'+boundary+'"');
            req.setHeader('Content-length', String.valueOf(body.length()));
           // req.setHeader('Content-Encoding','base64');
            req.setEndpoint('https://graph.facebook.com/v2.0/me/photos?access_token='+accesstoken);
            HttpResponse res = null;
            http h= new Http();
            res= h.send(req);   
            system.debug( '------------upload photo----------------------'+res.getbody());   
       }
I am gettung error each time ({"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}})
please tell me sir what i have to do for uploading photo on facebook.
thanks in advance

I want code for to upload file on dropbox using httprequest and httpresponse after authentication and getting access point.
I want to use extjs in visualforce but i am getting error Uncaught ReferenceError: Ext is not defined i also added all library related to ext js but this time also getting same error so How to solve this error. I have a urgent requirement to solve this issue .
Hi,

May be my question is silly but I recently heard about Trailhead so want to know what it is and for which purpose it is used?
From the Trailhead site, i came to know that it provides tutorial on various topics of SFDC. What additional things we can do with Trailhead?

Thanks in advance

Thanks
Manan Shah
Below is the image of Configure States and Countries in pick list but i want to create same page for my application. Is there any idea how to create this?

User-added image

When i would click my custom button, at that time want to show this page.
 
diff b/w force.com and salesforce.com
when do we use without sharing keyword.......(by default if a class is without any keyword then that class considered as a without sharing..) ,
Hi - when doing the challenge "Bulk Apex Trigger" in Trailhead I get the error message :"Executing against the trigger does not work as expected."

I have checked the name of the class, task name as mentioned in the challenge description.

I have copied the code below :

trigger ClosedOpportunityTrigger on Opportunity (before insert, before update) {
  List<Task> taskList = new List<Task>();

    //If an opportunity is inserted or updated with a stage of 'Closed Won'
    // add a task created with the subject 'Follow Up Test Task'.
    for (Opportunity opp : [SELECT Id,Name FROM Opportunity
                     WHERE Id IN :Trigger.new AND StageName = 'Closed Won']) {
       //add a task with subject 'Follow Up Test Task'.
       taskList.add(new Task(Subject='Follow Up Test Task', WhatId = opp.id ));                
  }
                          
    if (taskList.size() > 0) {
        insert taskList;
    }



Thank you
Pierre-Alain


 
Hi, I'm struggling to get a test class to work. Any help would be much appreciated!

Where I'm stuck is with the apex page parameter. In the test class I am trying to define this parameter and then pass it into the class (the last section of the test class). But I am totally stuck on how to get this to work.

Apex Class
public class InterviewsListDataTable {
    String Id = ApexPages.currentPage().getParameters().get('Id');
    public List<Interview_Time_Slot__c> interviewList {
        get {
            if (interviewList == null) {
                interviewList = [SELECT Interviewer_Name__c, Date_and_Time_of_Slot__c, Interviewer_Email__c, Interviewer_Skype_Name__c, Program__r.Program_Public_Name__c FROM Interview_Time_Slot__c WHERE Program__c =: Id ORDER BY Date_and_Time_of_Slot__c Asc];
            }
            return interviewList;
        }
        set;
    }
}

Test Class (work in progress)
@isTest
 private class TestInterviewsListDataTable {static testMethod void myUnitTest() {Profile pf = [Select Id from Profile where Name = 'System Administrator'];User u = new User();
 u.FirstName = 'Test';
 u.LastName = 'User';
 u.Email = 'testuser@test123456789.com';
 u.CompanyName = 'test.com';
 u.Title = 'Test User';
 u.Username = 'testuser@test123456789.com';
 u.Alias = 'testuser';
 u.CommunityNickname = 'Test User';
 u.TimeZoneSidKey = 'America/Mexico_City';
 u.LocaleSidKey = 'en_US';
 u.EmailEncodingKey = 'ISO-8859-1';
 u.ProfileId = pf.Id;
 u.LanguageLocaleKey = 'en_US';
 insert u;
system.runAs(u){


//Set RecordTypeId variable CA
 String strpRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Fellowship' AND sobjectType = 'Program__c'].Id;

    
    Program__c program = new Program__c();
    program.Name = 'TestProgram';
    program.RecordTypeId = strpRecordTypeId;
    Insert program;
    
        Interview_Time_Slot__c objInterviewSlot = new Interview_Time_Slot__c();
        objInterviewSlot.Program__c = program.Id;
        Insert objInterviewSlot;
        
     
     PageReference PageRef = Page.Interviews;
     Test.setCurrentPage(PageRef);
     ApexPages.currentPage().getParameters().put('Id', 'program.Id'); 

     InterviewsListDataTable testlist = new InterviewsListDataTable();
     testlist.Id = program.Id;
     
     testlist.interviewList();

    }
}
}

 
  • April 21, 2015
  • Like
  • 0
HI All,
How to call Paypal Refund transaction() Method from apex class.
am new to paypal.
please help me
 I have a vf page and controller.
My pagination is not working properly.I need to display 20 recors per page and then clicking on next will show next 20 and so on.similarly for previous also.I have put 4 command button for my pagination Next,Last,Previous,First. When I am clicking on next the same 20 records are appearing.It means only buttons are appearing on UI but there functionality is not working.
Below are the codes for my page and controller.
public class HarjeetWrapper{
             private Set<Id> selectedContactIds;
            public ApexPages.StandardSetController setCon {
            get {
                if(setCon == null) {
                    setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select Id, Name,csord__Status__c, csord__Account__c from csord__Subscription__c where csord__Account__c=:accountid ]));
                             }
                        return setCon;
                }
        set;
    }
    public List<csord__Subscription__c > getWrapSubscriptionList() {
         
          setCon.setpagesize(20);
         setCon.setpageNumber(1);
         return (List<csord__Subscription__c >) setCon.getRecords();
    }
    public Integer getPageNumber(){
 
        return this.setCon.getPageNumber();
 
    }
    

 


   Public Integer getTotalPages(){
 
        Decimal totalSize = this.setCon.getResultSize();
        Decimal pageSize = this.setCon.getPageSize();
 
        Decimal pages = totalSize/pageSize;
 
        return (Integer)pages.round(System.RoundingMode.CEILING);
     }
 

    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapSubscription> wrapSubscriptionList {get; set;}
    public List<csord__Subscription__c> selectedSubscriptions{get;set;}
    public Boolean isCancel{get;set;}
    public string accountid;
    
    
    public HarjeetWrapper(){
      accountid=ApexPages.currentPage().getParameters().get('id');
        if(wrapSubscriptionList == null) {
           wrapSubscriptionList= new List<wrapSubscription>();
            for(csord__Subscription__c s: [select Id, Name,csord__Status__c, csord__Account__c from csord__Subscription__c where csord__Account__c=:accountid LIMIT 20]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapSubscriptionList.add(new wrapSubscription(s));
            }
        }
    }
    
    
    public void processSelected() {
    selectedSubscriptions = new List<csord__Subscription__c>();
 
        for(wrapSubscription wrapSubscriptionObj : wrapSubscriptionList) {
            if(wrapSubscriptionObj.selected == true) {
                selectedSubscriptions.add(wrapSubscriptionObj.sub);
            }
        }
    }
    
    public PageReference cancel(){
        return new PageReference('/'+accountid);
    }
    
    public void next(){

    if(this.setCon.getHasNext())
        this.setCon.next();

}

 public void previous(){

    if(this.setCon.getHasPrevious())
        this.setCon.previous();

}


                         
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapSubscription {
        public csord__Subscription__c sub {get; set;}
        public Boolean selected {get; set;}
 
        public wrapSubscription(csord__Subscription__c s) {
            sub = s;
            selected = false;
        }
    }
}
<apex:page controller="HarjeetWrapper" sidebar="false" showHeader="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
   
        <apex:pageBlock title="Select Subscription"  >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Proceed " action="{!processSelected}" />
                <apex:commandButton value="Cancel" action="{!cancel}" immediate="true" />
            </apex:pageBlockButtons>
       <apex:pageblockSection title="Subscriptions" collapsible="false" columns="1" >
             <apex:pageBlockTable value="{!wrapSubscriptionList}" var="subWrap">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')" />
                        </apex:facet>
                        <!--<apex:inputCheckbox value="{!subWrap.selected}" id="inputId"/>-->
                                <apex:inputCheckbox value="{!subWrap.selected}" id="inputId" disabled="{!NOT(subWrap.sub.csord__Status__c=='Active')}" />
                    </apex:column>
                   
                    <!--<apex:column value="{!subWrap.sub.Name}" />-->
                    <apex:column headerValue="Subscription Name" >
                        <!--<apex:commandLink value="{!subWrap.sub.Name}" action="/{!subWrap.sub.Id}"/>-->
                       <apex:outputLink value="/{!subWrap.sub.Id}" target="_blank"> {!subWrap.sub.Name} </apex:outputLink>
                   </apex:column>
                     <apex:column value="{!subWrap.sub.csord__Status__c}" />
                    <apex:column value="{!subWrap.sub.csord__Account__c}" />
                </apex:pageBlockTable>
                </apex:pageblockSection>
             <apex:commandButton rendered="{!setCon.hasPrevious}" value="first" action="{!setCon.first}"/>
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="Previous" action="{!setCon.previous}"/>
            <apex:outputLabel value=" (page {!pageNumber} of {!totalPages})"/>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) < setCon.ResultSize}" value="{!setCon.pageNumber * setCon.pageSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) >= setCon.ResultSize}" value="{!setCon.ResultSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:commandButton rendered="{!setCon.hasNext}" value="next" action="{!setCon.next}"/>
            <apex:commandButton rendered="{!setCon.hasNext}" value="last" action="{!setCon.last}"/>

     <apex:pageBlock />
               
               
                <apex:pageblockSection title="Selected Subscriptions" collapsible="false" columns="1" >
                   <apex:pageBlockTable value="{!selectedSubscriptions}" var="c" id="table2" title="Selected Subscriptions" width="100%">
                    <!--<apex:column value="{!c.Name}" headerValue="Subscription Name"/>-->
                    <apex:column headerValue="Subscription Name" >
                        <apex:commandLink value="{!c.Name}" action="/{!c.Id}" target="_blank"/>
                      </apex:column>
                    <apex:column value="{!c.csord__Status__c}" headerValue="Status"/>
                    <apex:column value="{!c.csord__Account__c}" headerValue="Account"/>
                </apex:pageBlockTable>
           

            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>


I  am attaching screen snaps to refer that also
screen shot
I have businees demo on Friday and need to be resolve this before that at any cost.
Many thanks in advance.
Hope this time also you people came up with solution for me...
 
Hi all,

I have requirement with add 1 & 5 row. it is ok with attachment in there. but it is not worked with the delete function.It show the error apex input file with conjuntion. Can any one help. This is my VF page :

<apex:page controller="LobbyEditRelatedContactController" tabStyle="Clients_Employees__tab" title="Clients & Employees">
    
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"/>
    
    <script>
        
        $(document).ready(function() {
        $("#GvCHX").click(function() {
            $("#GvCHXDetails").toggle(this.checked);
        }).triggerHandler('click');
    });
    
    </script>
    
    <apex:form >
        <apex:pageBlock title="Client"  rendered="{!$CurrentPage.parameters.RecordType==recordTypesMap['Client']}">
            <apex:pageBlockTable value="{!lstContactWrappers}" var="wrapper" id="wtable">
                <apex:column headerValue="Appointment">
                    <apex:inputField value="{!wrapper.contact.Lobbyists_Appointment__c}"/>
                </apex:column>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!wrapper.contact.Client_NameUSER__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="ABN">
                    <apex:inputField value="{!wrapper.contact.ABNUSER__c}"/>
                </apex:column>
                <apex:column headerValue="Action">
                    <apex:commandButton value="Delete" action="{!delRow}" rerender="wtable" immediate="true">
                        <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelrow}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:pageBlockTable>
            <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable" immediate="true">
                <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
            </apex:commandButton>
            <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable" immediate="true">
                <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
            </apex:commandButton>
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlock>
        <apex:pageBlock title="Employee" rendered="{!$CurrentPage.parameters.RecordType==recordTypesMap['Employee']}">
            <apex:pageBlockTable value="{!lstContactWrappers}" var="wrapper" id="wtable1">
                <apex:column headerValue="Appointment">
                    <apex:inputField value="{!wrapper.contact.Lobbyists_Appointment__c}" />
                </apex:column>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!wrapper.contact.Employee_NameUSER__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="Position">
                    <apex:inputField value="{!wrapper.contact.Position__c}"/>
                </apex:column>
                <apex:column headerValue="NSW Gov board ?">
                    <apex:inputCheckbox id="GvCHX" value="{!wrapper.contact.Government_Board_or_Committee_Member__c}" immediate="true"/>
                </apex:column>
                <apex:column headerValue="Details">
                    <apex:inputField id="GvCHXDetails" label="details" value="{!wrapper.contact.Details__c}"/>
                </apex:column>
                <apex:column headerValue="Add Declaration" >
                    <apex:inputFile value="{!wrapper.att.body}" filename="{!wrapper.att.name}"/>                    
                </apex:column>
                <apex:column headerValue="Action">
                    <apex:actionRegion >
                        <apex:commandButton value="Delete" action="{!delRow}" reRender="wtable1">
                            <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelrow}"/>
                        </apex:commandButton>
                    </apex:actionRegion>
                </apex:column>
            </apex:pageBlockTable>
            <!-- apex:actionregion tag is required in case using apex:inputFile with any apex tag with 'rerender' attribute within the same apex:form -->
            <apex:actionregion >
                <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable1" immediate="true">
                    <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
                </apex:commandButton>
                <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable1" immediate="true">
                    <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
                </apex:commandButton>
            </apex:actionregion>
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
How to prevent a record save if two fields on an object have same values?
user is created in salesforce after that creating visualforce page  with a form and add 6 user fields remaining fields in controller when i click submit button new user should be created.how to solve the above solution please give some examples.
Hi folks,
      Can anyone tell me how to create a zip file in salesforce via apex?
I have seen the below link but it doesnt work for me.
http://www.valnavjo.com/blog/compressing-files-in-salesforce/

Please someone give me the working code sinppet for creating zipfile.

Thanks in advance
Karthick
could anyone please provide me a PDF for Salesforce Integration basic concepts
Hi, 

I turn on Allow Support to Activate Multiple Currencies in Company Information page.  However, I don't see Manage Currencies page or any place where I can manage currencies.  Does anyone know how to turn this feature on in developer version?  Please help.

Thanks,
KJ
  • April 01, 2015
  • Like
  • 0
I am having requirment like 
I am using Pageblocktable in which i have some data and in one column i have given the link called view after clicking on view that particular detail should be viewd..
But it is not working correctly..
I am sharing my code with you

Visualforce
<apex:PageBlockSection columns="1" >
     <apex:pageBlockTable value="{!getc}" var="a">
         <apex:column value="{!a.Name}"/>
         <apex:column value="{!a.customer__c}"/>
         <apex:column value="{!a.E_mail__c}"/>
         <apex:column value="{!a.Phone_Number__c}"/>
         <apex:column headerValue="Action">
         <apex:commandLink value="view" reRender="imagepopup" action="{!addcomp}">
             <apex:param id="custid" value="{!a.id}"/>
         </apex:commandLink>
         </apex:column>
     </apex:pageBlockTable>
 </apex:PageBlockSection>

apex code
public Complaint__c add{get;set;}

public List<Shan__Complaint__c> getc{get;set;}

  public refreshctrl ()
    {
         
        
         getc= [Select id,Name,Shan__customer__c,Shan__E_mail__c,Shan__Phone_Number__c,Shan__Issue_Details__c,Shan__Issue_Summary__c from Shan__Complaint__c]; 
          
    }

public void addcomp()
    {
        ID fid=ApexPages.currentpage().getparameters().get('custid');
        add=[Select id,name,customer__c,E_mail__c,Phone_Number__c,Issue_Summary__c,Issue_Details__c from Complaint__c where id=:fid];
        displayPopUp=true;
       // return new Pagereference('/apex/viewcomp?id='+lid);
        
        
    
    }

It is giving me error:
Visualforce ErrorHelp for this Page
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!addcomp}' in page shan:cust_complaint: Class.Shan.refreshctrl.addcomp: line 37, column 1
Class.Shan.refreshctrl.addcomp: line 37, column 1     
 
suppose a recurting app as a adminstration object which consist of v.f pages connected to it ,a person who have all cerdentials same as system admin if he login in to that object ,he couldnt see home page,,,why and how he can see home page ...
why do we use junction object
in a oppurtunity object a standard filed called stage (picklist) with a value lose...and a custom filed in same object itself
now when the stage ===lose;
i want custom filed as a required filed automatic  how u will acheive this
ANS:i said using trigger 
if this is correct ans any one of u can show me how the code looks

if it
Hi guys,

I have a object with records:
Name        form_no         createddate
test1         2222              23/03/2015
test1         2222              24/03/2015

test2         3333              23/03/2014
test2         3333              24/03/2014

test3          4444             22/03/2014

In my report i want to display latest created record  and should elminate the other records from report
like this:-
test1         2222              24/03/2015
test2         3333              24/03/2014
test3          4444             22/03/2014

Can please any one help me to achieve this with standard report

Thanks