• AK2017
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies
Hello,

I have created a visualforce to show an opportunity pulled from SOQL in Apex class.
I have a method which should save the existing opportunity and rerun the same logic above to pull the next opportunity on the page.

When the page loads initially, there is not opportunity assigned. user clicks on the button, it pulls up the opportunity.

when trying to save the opportunity after editing and rerun the same logic by clicking the same button, the method is not called , the opportunity is not saved and it is not pulling the next opportunity.

i even had the soql logic in the constructor and save/update in a seprate method, the method was not called.

can anyone throw me some light on what i making it wrong.

Here is my VF page and apex class.
 
<apex:page Controller="OpportunityListViewController" docType="html-5.0">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  th{background: #ff9999;}
  //tr{background: #ffe6e6;}
  a{font-color:blue;}
  </style>
 <apex:form >
 <apex:pageBlock >
 <div style="width:100%" class="container">
 <h3>Lead to be contacted</h3><br></br><br></br>
 <table width="100%" class="table table-bordered table-hover">
 <th>Stage</th>
 <th>Status</th>
 <th>FullName</th>
 <th>Email</th>
 <th>Home Phone</th>
 <th>Work Phone</th>
 <th>Mobile Phone</th>
 
 <apex:repeat value="{!FirstSection}" var="New">
 <tr>
  <td>{!New.StageName}</td>
  <td>{!New.Opportunity_Status__c}</td>
  <td>{!New.Account.FirstName} {!New.Account.LastName}</td>
  <td>{!New.Account.PersonEmail}</td>
  <td>{!New.Account.Home_Phone__pc}</td>
  <td>{!New.Account.Work_Phone__pc}</td>
  <td>{!New.Account.PersonMobilePhone}</td>
  </tr>
  </apex:repeat>
  </table>
  <table>
      <apex:repeat value="{!FirstSection}" var="New">
          <tr>
              <td>
                   <apex:selectList size="1" value="{!FinalDispositioncode}">
                      <apex:selectOptions value="{!dispositioncode}"></apex:selectOptions>
                  </apex:selectList>
              </td>
              <td>
                  <apex:inputField value="{!New.Callback_Time__c}" />
              </td>
          
          </tr>
      </apex:repeat>
  
  </table>  
  
  <apex:commandButton value="save1" action="{!OpportunityListViewControlle}"/> 


 </div>
  <apex:outputPanel id="Newleaddisplay">
  <apex:outputPanel rendered="{!(NewleadPopup == true)}">
             
                 
               <div id="pwdinactiveModal" class="modal show" tabindex="-1" role="dialog" style="border:0px;" >
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-center">
                                  <p style="color:#2d4366;">You have got a new lead to be contacted. If this lead is not contacted within 60 seconds, it will be routed back to next Admission advisor.</p><br></br>
                                  <p><strong>Student Name: {!Newlead.Account.Firstname}&nbsp;{!Newlead.Account.Lastname}</strong></p>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        <fieldset>                                                
                                                           <!-- <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Activate and Send My Password" action=""/> -->
                                                        </fieldset>
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                <!--  <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> -->
                                  </div>    
                              </div> 
                          </div>
                          </div>
                  </div>
       </apex:outputPanel>
       </apex:outputPanel>
 </apex:pageBlock> 
  
 </apex:form>

</apex:page>

APEX class
 
public class OpportunityListViewController {

public List<opportunity> NewOpps{get;set;}
public List<opportunity> SecondSection{get;set;}
//public List<opportunity> SecondContactOpps {get;set;}
public Opportunity FirstSection{get;set;}
Integer count = 0;
public Boolean NewleadPopup {Get;set;}
Public Opportunity Newlead {get;set;}
public datetime callbacktime {get;set;}
public datetime FinalDispositioncode{get;set;}
public datetime Notes{get;set;}
                        
    public PageReference incrementCounter() {
        count++;
        return null;
    }
                        
    public Integer getCount() {
        return count;
    }
    
    public List<SelectOption> getdispositioncode() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Left VM','Left VM'));
        options.add(new SelectOption('Spoke with Student','Spoke with Student'));
        options.add(new SelectOption('Emailed student','Emailed student'));
        options.add(new SelectOption('Scheduled callback for interview','Scheduled callback for interview'));
        return options;
    }
    

   public pagereference OpportunityListViewControlle() {
         system.debug('getting into it');
         
         if(FirstSection != null){
             system.debug('getting into it inside');
             update FirstSection;
         }
         
         Firstsection = null;
         List<Opportunity> Allopps = new List<Opportunity>();
        //Opportunity Firstsection = new List<Opportunity>();
        SecondSection = new List<Opportunity>();
        List<Opportunity> UserScheduledopps = new List<Opportunity>();
        List<Opportunity> CommonUserEncounteropps = new List<Opportunity>();
        List<Opportunity> CommonUserNewopps = new List<Opportunity>();
        List<Opportunity> CommonUserScheduledopps = new List<Opportunity>();
        String Commonuser = System.Label.Common_Pool_user;
        Allopps = [Select id,StageName, Name, Ownerid, Encounter_Time__c, Callback_Time__c, Account.Firstname, Account.Lastname, Opportunity_Status__c, Comments__c, Account.PersonEmail, Account.Home_Phone__pc, Account.Work_phone__pc, Account.PersonMobilePhone from Opportunity where( (Ownerid =: userinfo.getuserid() 
                             AND (Encounter_Time__c != null OR Opportunity_status__c =: 'New' OR Callback_Time__c != null)) OR (Ownerid =: Commonuser AND (Encounter_Time__c != null OR Opportunity_status__c =: 'New' OR Callback_Time__c != null))) and Timestamp_Qual_Applicant__c = null and StageName != 'Stale' and StageName != 'Complete' order by Encounter_Time__c DESC, Createddate DESC, Callback_Time__c DESC limit 11]; 
       
      
       
       // code to take first Encounter in the list 
        for(Opportunity Opp:Allopps){
             if(Opp.Ownerid == userinfo.getuserid() && Firstsection == null){
                  if(Opp.Encounter_Time__c != null){
                    FirstSection = Opp;                    
                  } 
             } else if(Firstsection == null) {
                 if(Opp.Encounter_Time__c != null){
                    Opp.Ownerid = userinfo.getuserid();
                    update Opp; 
                    FirstSection = Opp;                    
                  } 
             }
         }
         
        // code to take newly created lead in the list  
        for(Opportunity Opp:Allopps){
             if(Opp.Ownerid == userinfo.getuserid() && Firstsection == null){
                  if(Opp.Opportunity_status__c == 'New'){
                    FirstSection = Opp;                    
                  } 
             } else if(Firstsection == null) {
                 if(Opp.Opportunity_status__c == 'New'){
                    Opp.Ownerid = userinfo.getuserid();
                    update Opp; 
                    FirstSection = Opp;                    
                  } 
             }
         }
        
       // code to give preference to user owned Callback scheduled leads
        Opportunity TempFirstSection = New Opportunity();
        for(Opportunity Opp:Allopps){
            if(Opp.Ownerid == userinfo.getuserid() && Opp.Callback_Time__c != null && TempFirstSection.id == null){
               
                  /* Integer Timediff1 = (Opp.Callback_Time__c.time().millisecond() - System.now().time().millisecond())*24*60;
                   //integer Timediff1 = (Opp.Callback_Time__c.timeGMT() - System.now().time())*24*60;
                   integer Timediff2 = (System.now().time().millisecond() - Opp.Callback_Time__c.time().millisecond())*24*60;
                   system.debug('Timediff1 '+Timediff1 );
                   system.debug('Timediff2 '+Timediff2 );
                    if(((Timediff1 <= 5) || (Timediff2 <= 15))){
                    
                    if(Opp.Callback_Time__c.date() == System.now().date() &&  Opp.Callback_Time__c.time() - System.now().date() )
                        system.debug('Opp name'+Opp.Name);
                        TempFirstSection = Opp; 
                    } */
                    
                    if((System.now().time() <= Opp.Callback_Time__c.time() && System.now().time().addminutes(5) >= Opp.Callback_Time__c.time()) || (System.now().time() > Opp.Callback_Time__c.time() && System.now().time().addminutes(-15) <= Opp.Callback_Time__c.time())){
                         system.debug('Opp name'+Opp.Name);
                        TempFirstSection = Opp; 
                    }
           }
            
       } 
       
      // code to give preference to common user owned Callback scheduled leads 
       for(Opportunity Opp:Allopps){
            if(Opp.Callback_Time__c != null && TempFirstSection.id == null){
                             
                   /*Integer Timediff1 = (Opp.Callback_Time__c.time().millisecond() - System.now().time().millisecond())/24/60;
                   //integer Timediff1 = (Opp.Callback_Time__c.timeGMT() - System.now().time())*24*60;
                   integer Timediff2 = (System.now().time().millisecond() - Opp.Callback_Time__c.time().millisecond())/24/60;
                    if(((Timediff1 <= 5) || (Timediff2 <= 15))){
                        system.debug('Opp name later'+Opp.Name);
                        Opp.Ownerid = userinfo.getuserid();
                        update Opp;
                        TempFirstSection = Opp; 
                    }*/
                    
                     if((System.now().time() <= Opp.Callback_Time__c.time() && System.now().time().addminutes(5) >= Opp.Callback_Time__c.time()) || (System.now().time() > Opp.Callback_Time__c.time() && System.now().time().addminutes(-15) <= Opp.Callback_Time__c.time())){
                         system.debug('Opp name'+Opp.Name);
                        TempFirstSection = Opp; 
                    }
             }
             
           if(Opp != TempFirstSection && Opp != Firstsection)  SecondSection.add(Opp);
           
           
           
               //if(Firstsection == null) Firstsection = Opp;
      } 
      
      system.debug('Temp section id'+TempFirstSection.Name);
      if(TempFirstSection.ID != null) FirstSection = TempFirstSection; 
      
      if(FirstSection == null && AllOpps.size() > 0) FirstSection = Allopps[0];   
      
      if(FirstSection == null){
       
        List<opportunity>  oldopps = [Select id,StageName, Name, Ownerid, Encounter_Time__c, Callback_Time__c, Account.Firstname, Account.Lastname, Opportunity_Status__c, Comments__c, Account.PersonEmail, Account.Home_Phone__pc, Account.Work_phone__pc, Account.PersonMobilePhone from Opportunity where (Ownerid =: userinfo.getuserid() 
                      OR Ownerid =: Commonuser) and StageName != 'Stale' and StageName != 'Complete' and Timestamp_Qual_Applicant__c = null and Callback_Time__c = null order by Createddate desc limit 11]; 
                      
          if(oldopps.size() > 0){
              FirstSection = oldopps[0];
          }            
       
       
      } 
      
     /* pagereference PR = new pagereference('/apex/OpportunityListview?id='+FirstSection.id);
      PR.setRedirect(true);
      
      
      return pr; */
      
      return null;
   } 
    
}

  • September 07, 2017
  • Like
  • 0
We have a Third party Open cti being used. We have routing logic using Apex. Now i need to know the call status on the Open CTI using Apex, so that i can eliminate routing leads to that agent. 

Is there any way how i can access the Open CTI from Apex?

I have gone through Open CTI links from Salesforce but none provide an example on connecting open CTI from Apex.
  • August 09, 2017
  • Like
  • 0
Hello All,

I am pulling a list of opportunities from controller and running it through apex:repeat.

one of the column has a click that calls the bootstrap modal. i wanted this modal to display details related to the record i clicked.

in my case, it is always displaying details of first record even if i click 5th row of this table.

here is my code, please help me.
<apex:page controller="OpportunityListViewController">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  th{background: #ff9999;}
  tr{background: #ffe6e6;}
  a{font-color:blue;}
  </style>
 <apex:form >
 <apex:pageBlock >
 <div style="width:100%" class="container">
 <h4>New Leads - first contact</h4><br></br><br></br>
 <table width="100%" class="table table-bordered table-hover">
 <th >Action</th>
 <th>Opp ID</th>
 <th>FullName</th>
 <th>Email</th>
 <th>Home Phone</th>
 <th>Work Phone</th>
 <th>Mobile Phone</th>
 <th>Stage</th>
 <th>Status</th>
 <apex:repeat value="{!NewOpps}" var="New">
 <tr><td>
 
 <div><a href="#" data-target="#pwdModal" data-toggle="modal">Notes</a></div> 
  
  
  </td>
  <td>{!New.ID}</td>
  <td>{!New.Account.FirstName} {!New.Account.LastName}</td>
  <td>{!New.Account.PersonEmail}</td>
  <td>{!New.Account.Home_Phone__pc}</td>
  <td>{!New.Account.Work_Phone__pc}</td>
  <td>{!New.Account.PersonMobilePhone}</td>
  <td>{!New.StageName}</td>
  <td>{!New.Opportunity_Status__c}</td>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-left">
                                  <h4 style="color:#2d4366;">Providing contact feedback for {!New.Account.FirstName} {!New.Account.LastName} {!New.ID}</h4>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                        <fieldset>                                              
                                             <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                         </fieldset>
                                  </div>    
                              </div> 
                          </div>
    </div></div>
  </tr>
  </apex:repeat></table>
<!-- <apex:pageBlockTable value="{!NewOpps}" var="New" border="1">
 <apex:column headerValue="Action"><div><a href="#" data-target="#pwdModal" data-toggle="modal">Forgot my password</a></div>   </apex:column>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-center">
                                  <p style="color:#2d4366;">A temporary password will be send to . You can reset your password by logging into the application with the provided temporary password.</p>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        <fieldset>                                                
                                                            <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                                        </fieldset>
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                  <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> 
                                  </div>    
                              </div> 
                          </div>
                          </div>
  </div>
  <apex:column value="{!New.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!New.Account.FirstName} {!New.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!New.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!New.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!New.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!New.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!New.StageName}"  headerValue="Stage"/>
  <apex:column value="{!New.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> -->
 </div><br></br><br></br>
 <div style="width:100%" class="container">
 <h4>Leads -  Second contact</h4><br></br><br></br>
 <apex:pageBlockTable value="{!SecondContactOpps}" var="second" border="1">
 <apex:column headerValue="Action"/>
  <apex:column value="{!second.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!second.Account.FirstName} {!second.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!second.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!second.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!second.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!second.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!second.StageName}"  headerValue="Stage"/>
  <apex:column value="{!second.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> 
 </div>
 </apex:pageBlock> 
 
 </apex:form>
</apex:page>

 
  • April 11, 2017
  • Like
  • 1
Hello,

I downloaded an autocomplete component and it is really great. it is working as i expected in the visualforce pages.

after i am done with the development, i logged in as site user to check the functionality, it is not working.

I installed this unmanaged package for all users and verified the site user profile for the visualforce and apex class on it.

i am not getting javascrip error also.

Can anyone help me with this issue?

Here is the link where i downloaded the Autocomplete component.

http://opfocus.com/visualforce-autocomplete-lookup-fields/

I am trying to contact the developer but of no success.

Aariff
  • March 07, 2017
  • Like
  • 0
Hello.

I am trying to call a apex method and rerender a small section when radio button is changed but it is working. can anyone suggest me what wrong i am doing it here.

If i rerender it is working fine but i don't want to rerender because it has password field and rerendering makes those fields blanks.

Please suggest me an idea.
 
<apex:page controller="apexcontroller">

 <apex:outputPanel id="page">
   <div class="step selected">
<apex:outputPanel rendered="{!NewUser==true}">
             
              <div class="Container">         
             
               
                    
              <apex:outputPanel id="additional">             
             
              <div>
                <h4>Address details</h4>
               </div>
                <div class="form-group row">
                   
                                <div class="col-md-4 col-lg-3">   
                                   <label for="PrimaryAdrress1" >Address 1*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_Street_1__c}"  id="PrimaryAdrress1" type="text" html-placeholder="Address 1" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-2">   
                                   <label for="PrimaryAdrress2" >Address 2*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_Street_2__c}"  id="PrimaryAdrress2" type="text" html-placeholder="Address 1" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-2">   
                                   <label for="PrimaryCity" >City*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_City__c}"  id="Primarycity" type="text" html-placeholder="City" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-1">   
                                   <label for="PrimaryState" >State*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_State__c}"  id="PrimaryState" type="text" html-placeholder="State" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-1">   
                                   <label for="PrimaryZip" >Zip Code*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_Postal_Code__c}"  id="Primaryzip" type="text" html-placeholder="Zip" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-3">   
                                   <label for="PrimaryCountry" >Country*</label>
                                <div>
                                   <apex:inputField value="{!account.Primary_Country__c}"  id="Primarycountry" type="text" html-placeholder="Country" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                           
                
                </div>
                 <div class="form-group row">
                     <div class="col-md-8 col-lg-4 col-xs-8"> 
                         
                         <p>Is the Mailing Address same as the Primary Address?*</p> 
                     </div>
                     <div class="col-md-4 col-lg-6 col-xs-4">                                                   
                          <apex:selectRadio value="{!useprimaryasmailing}" id="sameAddresses" >
                                   <apex:selectOptions value="{!usePrimaryAsShippingValues}" />
                                   <apex:actionSupport event="onchange" action="{!updateShipping}" reRender="addresses"/>
                          </apex:selectRadio>                        
                      </div>                    
                
             </div>
             
             <apex:outputPanel id="addresses">
                     <div class="form-group row">
                    
                                <div class="col-md-4 col-lg-3">   
                                   <label for="MailingAdrress1" >Address 1*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_Street_1__c}"  id="MailingAdrress1" type="text" html-placeholder="Address 1" style="width:100%;" styleClass="form-control"/>
                                   <script>document.getElementById('{!$Component.MailingAdrress1}').disabled = {!disableInput}; </script>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-2">   
                                   <label for="MailingAdrress2" >Address 2*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_Street_2__c}"  id="MailingAdrress2" type="text" html-placeholder="Address 1" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-2">   
                                   <label for="MailingCity" >City*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_City__c}"  id="Mailingcity" type="text" html-placeholder="City" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-1">   
                                   <label for="MailingState" >State*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_State__c}"  id="MailingState" type="text" html-placeholder="State" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-1">   
                                   <label for="MailingZip" >Zip Code*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_Postal_Code__c}"  id="Mailingzip" type="text" html-placeholder="Zip" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                               <div class="col-md-4 col-lg-3">   
                                   <label for="MailingCountry" >Country*</label>
                                <div>
                                   <apex:inputField value="{!account.Shipping_Country__c}"  id="Mailingcountry" type="text" html-placeholder="Country" style="width:100%;" styleClass="form-control"/>
                                </div>
                              </div> 
                           
                
                </div>
                </apex:outputPanel> 
               </apex:outputPanel>  
             </div>             
            
             </apex:outputPanel> 
             </div>
             </apex:outputPanel>


             
  • February 16, 2017
  • Like
  • 0
Hello All,

How to create dataset/datatable and send it to a webservice using Apex? One of our service provider has opened its API and they have given a service URL and sample code. In the sample code they are creating datatable, column and adding values as dataset and calling a method in the service URL. i am not sure how to do this? is this even possible in Salesforce.

Below is the sample c# code provided.
 
Function InitialCallToGetQuestion()
        {
            /* column names: id, name, value -  for table to associate candidate to transaction */
            DataTable candidateInfo = new DataTable();
            candidateInfo.Columns.Add("id", typeof(int));
            candidateInfo.Columns.Add("name", typeof(string));
            candidateInfo.Columns.Add("value", typeof(string));

            /* can be anything but should identify candidate */
            /* must be at least one entry */
            candidateInfo.Rows.Add(1, "SalesForceID", "12@3934X2");
            candidateInfo.Rows.Add(2, "Name", "David Smith");
            candidateInfo.Rows.Add(3, "CallRep", "Lucy Jones");

            DataSet packageInfo = new DataSet();
            packageInfo.Tables.Add(candidateInfo);

            string clientIdentifier = "E764FCA0";  /* 
            string optionalClientTag = "Region1";  /* can be blank */
            PeerlessService.QuestionSet qs;
            using (PService.PServiceClient ps = new PService.PServiceClient())
            {
                qs = ps.GetQuestion(clientIdentifier, optionalClientTag, packageInfo);
            }

	/*   break the return table into viewable question/response combinations */
            var model = new testModel();
            model.transId = qs.transID;
            model.questPrompt = qs.quesPrompt;
            model.question = new List<testQuestion>();
            for (int i = 0; i < qs.questions.Length; i++)
            {
                var q = new testQuestion();
                q.questKey = qs.questions[i].questNbr;
                q.questTxt = qs.questions[i].questTxt;
                model.question.Add(q);
            }
            model.response = new List<testResponse>();
            for (int i = 0; i < qs.responses.Length; i++)
            {
                var r = new testResponse();
                r.respKey = qs.responses[i].respNbr;
                r.respTxt = qs.responses[i].respTxt;
                model.response.Add(r);
            }
            return View(model);
        }

 
Hello All,

I am trying to get good code coverage for my getter setter method but i am not able to do anything.

Here is my code and test class.
 
public class PhdAppsProgressViewcontroller {
    
    public List<SelectOption> terms{ get; set;}
    public String Field {get; Set;}
    public String Fieldvalue {get; Set;}
    public Date FieldvalueDate {get; Set;}
    public Date FieldvalueEndDate {get; Set;}
    public String Query;
    public ApexPages.StandardSetController con {get; set;}
    public boolean searchPerformed{get;set;}
    public Integer queryLimit { get{return 50000;}}
    //public List<PhdOppDocuments> lstOppDocuments { get; set;}
    public class PhdOppDocuments {
    
        public String OppName {get;Set;}
        public String ProgramName {get;Set;}        
        public Boolean Resume {get; set;}
        public Boolean Recommendation {get; set;}
        public Boolean WritingSample {get; set;}
        public Boolean unoffiTranscripts {get; set;}
        public Boolean CoverLetter {get; set;}        
        public String CurrentStatus {get;set;}
        public String OppID {get;set;} 
        public String Owner {get;set;}
        public Integer Age {get;set;}   
        public String Term {get;set;}   
        
    }

    public PhdAppsProgressViewcontroller(){

        //Lstopps = [Select ID, Name, StageName, Opportunity_Status__c, Program_Name__c, Timestamp_Qual_Applicant__c from Opportunity where Program_Name__c like '%Doctor%' and Timestamp_Qual_Applicant__c = null limit ];
        
        this.terms = new List<selectOption>();
        List<Term__C> termLST = new List<Term__C>();
        termLST = [select id, Name, Term_Start__c from Term__c where Term_Start__c != null and Active__c = true order by Term_Start__c DESC Limit 10];      
        for(term__c trm:termLST){
                terms.add(new SelectOption(trm.Name,trm.Name));
        }
        
        
    
    }

    public pagereference RunReport(){
     
         
          if(Field != null){
             
          
            if(Field == 'Term__r.Name'){   
                
                if( Fieldvalue == null || Fieldvalue == ''){
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Please enter the Term.'));
                     return null;
                }
                
                String[] FieldValues = new String[]{Fieldvalue};
                Query = 'Select ID, Name, StageName, Opportunity_Status__c, Program_Name__c, Timestamp_Qual_Applicant__c, Owner.Name, Term__r.Name, (Select Id, CreatedDate, LastModifiedDate, Document_Type__c From Attachments__r) from Opportunity where (StageName = \'Lead\' OR StageName = \'Application\') and Program_Name__c like \'%Doctor%\' and Timestamp_Qual_Applicant__c = null AND Owner.Name != \'ITAdmin Trident\' AND ' +Field+' Like \''+ Fieldvalue+'\'';
            }
            
            if(Field == 'CreatedDate'){  
            
                if( FieldvalueDate == null || FieldvalueEndDate == null){
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Please enter Start date and End date.'));
                     return null;
                }
               
                Datetime dt = datetime.newInstance(FieldvalueDate.year(), FieldvalueDate.month(),FieldvalueDate.day(),0,0,0);
                //DateTime newDateTime = dt.addHours(12);
                String dateTimeFormat = dt.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');
                
                Datetime Enddt = datetime.newInstance(FieldvalueEndDate.year(), FieldvalueEndDate.month(),FieldvalueEndDate.day(),24,0,0);
                //DateTime newDateTime = dt.addHours(12);
                String EnddateTimeFormat = Enddt.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');
                Query = 'Select ID, Name, StageName, Opportunity_Status__c, Program_Name__c, Timestamp_Qual_Applicant__c, Owner.Name, Term__r.Name,(Select Id, CreatedDate, LastModifiedDate, Document_Type__c From Attachments__r) from Opportunity where (StageName = \'Lead\' OR StageName = \'Application\') and Program_Name__c like \'%Doctor%\' and Timestamp_Qual_Applicant__c = null AND Owner.Name != \'ITAdmin Trident\' AND ' +Field+' > '+dateTimeFormat +' AND '+ Field+' < '+EnddateTimeFormat;
            }
            system.debug('query'+Query );
            //List<opportunity> lstOpp = database.query(Query);
            con = new ApexPages.Standardsetcontroller(Database.getQueryLocator(Query));
            //this.lstOppDocuments = Querydata();     
            con.setPageSize(25);
            system.debug('pagenumber'+Con.getPageNumber());
         } 
         return null;
    }
    
     /*Public Methods */
    public List<PhdOppDocuments> lstOppDocuments { // This is used to Populate VF Search Results Table. If con is NULL, no records are returned.     
      
      get{
            //System.debug('***con.getResultSize()'+con.getResultSize());
         if(con != null)   {
           system.debug('inside page pagenumber');
            List<PhdOppDocuments> lstPhdOppDocuments = new List<PhdOppDocuments>();
            for (Opportunity Opp: (List<Opportunity>)con.getRecords()){
              PhdOppDocuments oppdoc = new PhdOppDocuments();
              Datetime LOR1;
              Datetime LOR2;
              Date LastModifieddate;
              for(Attachment__c att:Opp.Attachments__r){
                  If(att.Document_Type__c == 'Resume/CV'){
                      oppdoc.Resume = true;
                  }                  
                  
                  If(att.Document_Type__c == 'Letter of Recommendation' && LOR1 == null){
                      LOR1 = att.CreatedDate;                     
                  }
                  
                   If(att.Document_Type__c == 'Letter of Recommendation' && LOR1 != null && LOR1 != att.CreatedDate){
                      LOR2 = att.CreatedDate;
                      oppdoc.Recommendation = true;
                  }
                  
                  If(att.Document_Type__c == 'PhD-Writing Sample'){
                      oppdoc.WritingSample = true;
                  }
                  
                  If(att.Document_Type__c == 'Unofficial Transcript'){
                      oppdoc.UnoffiTranscripts = true;
                  }
                  
                  If(att.Document_Type__c == 'PhD-Short Essay'){
                      oppdoc.CoverLetter = true;
                  } 
                  
                  if(LastModifieddate == null){
                      LastModifieddate  = date.valueof(att.LastModifiedDate);
                  }  else if(att.LastModifiedDate > LastModifieddate && (att.Document_Type__c == 'Resume/CV' || att.Document_Type__c == 'Letter of Recommendation' || att.Document_Type__c == 'PhD-Writing Sample'
                              || att.Document_Type__c == 'Unofficial Transcript' || att.Document_Type__c == 'PhD-Short Essay')){
                      LastModifieddate  = date.valueof(att.LastModifiedDate);
                  }               
              
              }
              
              if(LastModifieddate != null){
                  oppdoc.Age = LastModifieddate.daysBetween(date.today());
              } else {
                  oppdoc.Age = 0;
              }
              
              oppdoc.CurrentStatus = Opp.Opportunity_Status__c;
              oppdoc.OppID = Opp.ID;
              oppdoc.OppName = Opp.Name; 
              oppdoc.Owner= Opp.Owner.Name;
              oppdoc.ProgramName = opp.Program_Name__c; 
              oppdoc.Term = Opp.term__r.Name;             
              lstPhdOppDocuments.add(oppdoc); 
            }             
              return lstPhdOppDocuments; 
            } else  
              return new List<PhdOppDocuments>(); 
          } set;
    }  
   
 //#################################### Prev/Next Page Coding Starts######################################
     
    public Boolean hasNext //Boolean to check if there are more records after the present displaying records
    {
        get
        {            
           
            return con.getHasNext();
        }
        set;
    }
 
    public Boolean hasPrevious //Boolean to check if there are more records before the present displaying records
    {
        get
        {
            return con.getHasPrevious();
        }
        set;
    }
 
    public Integer pageNumber //Page number of the current displaying records
    {
        get
        {
            return con.getPageNumber();
        }
        set;
    }

    public void previous() //Returns the previous page of records
    {
        con.previous();
        //showNoRecord = false;
    }
 
    public void next() //Returns the next page of records
    {
        con.next();
        //showNoRecord = false;
    }
    
    //#################################### Prev/Next Page Coding Ends###################################### 

}

test class snippet
 
List<PhdOppDocuments> tstphddocs = new List<PhdOppDocuments>();
        PageReference pref = page.PhdAppsProgressView; 
        Test.setCurrentPage(pref);
        List<Opportunity> opplist = [select id from Opportunity where AccountID =: acc.Id];
        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(opplist);
               
        PhdAppsProgressViewcontroller  repPOC = new PhdAppsProgressViewcontroller();
        
        
        repPOC.Field = 'Term__r.Name';
        repPOC.Fieldvalue = 'Fall 2014';
        pref = repPOC.runreport();        
        //List<PhdOppDocuments> lstOppDocuments = repPOC.getlstOppDocuments(); 
        
        //tstphddocs = new List<PhdOppDocuments>();
        
        PhdOppDocuments tstphddocs1 = new PhdOppDocuments();
        tstphddocs1.OppName = 'test';
        tstphddocs1.ProgramName= 'test';     
        tstphddocs1.Resume = true;
        tstphddocs1.Recommendation = true;
        tstphddocs1.WritingSample = true;
        tstphddocs1.unoffiTranscripts = true;
        tstphddocs1.CoverLetter = true;  
        tstphddocs1.CurrentStatus = 'test';
        tstphddocs1.OppID = '897898979'; 
        tstphddocs1.Owner = 'test';
        tstphddocs1.Age = 56;  
        tstphddocs1.Term = 'Fall 2015';
        tstphddocs.add(tstphddocs1);
        
        repPOC.Field = 'CreatedDate';
        repPOC.FieldvalueDate = Date.Today();
        repPOC.FieldvalueEndDate  = Date.Today();
        //repPOC.lstOppDocuments = tstphddocs;
        //repPOC.lstOppDocuments = tstphddocs1;
       // tstphddocs = repPOC.lstOppDocuments;
        pref = repPOC.runreport();
        
        
        repPOC.next();
        repPOC.previous();



 
  • April 28, 2016
  • Like
  • 0
Hello All,

I am pulling a list of opportunities from controller and running it through apex:repeat.

one of the column has a click that calls the bootstrap modal. i wanted this modal to display details related to the record i clicked.

in my case, it is always displaying details of first record even if i click 5th row of this table.

here is my code, please help me.
<apex:page controller="OpportunityListViewController">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  th{background: #ff9999;}
  tr{background: #ffe6e6;}
  a{font-color:blue;}
  </style>
 <apex:form >
 <apex:pageBlock >
 <div style="width:100%" class="container">
 <h4>New Leads - first contact</h4><br></br><br></br>
 <table width="100%" class="table table-bordered table-hover">
 <th >Action</th>
 <th>Opp ID</th>
 <th>FullName</th>
 <th>Email</th>
 <th>Home Phone</th>
 <th>Work Phone</th>
 <th>Mobile Phone</th>
 <th>Stage</th>
 <th>Status</th>
 <apex:repeat value="{!NewOpps}" var="New">
 <tr><td>
 
 <div><a href="#" data-target="#pwdModal" data-toggle="modal">Notes</a></div> 
  
  
  </td>
  <td>{!New.ID}</td>
  <td>{!New.Account.FirstName} {!New.Account.LastName}</td>
  <td>{!New.Account.PersonEmail}</td>
  <td>{!New.Account.Home_Phone__pc}</td>
  <td>{!New.Account.Work_Phone__pc}</td>
  <td>{!New.Account.PersonMobilePhone}</td>
  <td>{!New.StageName}</td>
  <td>{!New.Opportunity_Status__c}</td>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-left">
                                  <h4 style="color:#2d4366;">Providing contact feedback for {!New.Account.FirstName} {!New.Account.LastName} {!New.ID}</h4>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                        <fieldset>                                              
                                             <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                         </fieldset>
                                  </div>    
                              </div> 
                          </div>
    </div></div>
  </tr>
  </apex:repeat></table>
<!-- <apex:pageBlockTable value="{!NewOpps}" var="New" border="1">
 <apex:column headerValue="Action"><div><a href="#" data-target="#pwdModal" data-toggle="modal">Forgot my password</a></div>   </apex:column>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-center">
                                  <p style="color:#2d4366;">A temporary password will be send to . You can reset your password by logging into the application with the provided temporary password.</p>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        <fieldset>                                                
                                                            <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                                        </fieldset>
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                  <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> 
                                  </div>    
                              </div> 
                          </div>
                          </div>
  </div>
  <apex:column value="{!New.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!New.Account.FirstName} {!New.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!New.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!New.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!New.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!New.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!New.StageName}"  headerValue="Stage"/>
  <apex:column value="{!New.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> -->
 </div><br></br><br></br>
 <div style="width:100%" class="container">
 <h4>Leads -  Second contact</h4><br></br><br></br>
 <apex:pageBlockTable value="{!SecondContactOpps}" var="second" border="1">
 <apex:column headerValue="Action"/>
  <apex:column value="{!second.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!second.Account.FirstName} {!second.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!second.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!second.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!second.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!second.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!second.StageName}"  headerValue="Stage"/>
  <apex:column value="{!second.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> 
 </div>
 </apex:pageBlock> 
 
 </apex:form>
</apex:page>

 
  • April 11, 2017
  • Like
  • 1
Hello,

I downloaded an autocomplete component and it is really great. it is working as i expected in the visualforce pages.

after i am done with the development, i logged in as site user to check the functionality, it is not working.

I installed this unmanaged package for all users and verified the site user profile for the visualforce and apex class on it.

i am not getting javascrip error also.

Can anyone help me with this issue?

Here is the link where i downloaded the Autocomplete component.

http://opfocus.com/visualforce-autocomplete-lookup-fields/

I am trying to contact the developer but of no success.

Aariff
  • March 07, 2017
  • Like
  • 0
Hello all, 

I have a class structure like below:
 
Public void MainClass {
     Public String a;
     Public Strnig b;
     Public void SubClass{
          Public String x;
          Public String y;
      }
}

I'm Using this class to deserelize JSON. Once I deserelize I'm getting all the details in MainClass instance.
For eg:
JSONPareser jp = (JSONPareser) JSON.deserelize(JSONString,JSONParser.class);
jp object contains value of all the variables.
Now, I want to access value of x and y variables. How could I do that?? 
I'm only able to access jp.a and jp.b ..... What can be done to access x and y..

Thanks in advance 
Saurabh
I need to get a list of all users who are currently logged into my org.

This idea (https://success.salesforce.com/ideaView?id=08730000000BpPOAA0) explains that, as of a few months ago, this is possible. It explains where to find this information via the browser (Setup | Security Controls | Session Management), and also says that it's available through the API. Can anyone point me to documentation that explains how to get it via the API?

Thanks!

I want to pass some data captured in Salesforce to my Open CTI softphone and may have to invoke some event from Salesforce like hangup, transfer etc. Any idea how to achieve that? I can use jQuery to do so. Is there any better way to do so or any inbuilt feature?

I have problems testing my getter/setter. I'm rather new to it and am missing the nuances.

 

I have a class that looks like this:

  

public with sharing class clsCheckDuplicateSerials {
	public string CheckDuplicateSerials{get; set;}
	  String srchText;
	  	  
	  public String getSearchText() {
	    return srchText;
	  }
	  public void setSearchText(String s) {
	    srchText = s;
	  }
}

 The test method looks like this:

@isTest
private class TestDuplicateISerials {
    static testMethod void myUnitTest() {
        String sText ='ABX9043092058';
        CheckDuplicateSerials mm= new CheckDuplicateSerials();
        mm.getSearchText =sText;
        String s = mm.getSearchText ;
        systemAssert(sText,s)
    }
}

 

This doesn't work, I get "Variable does not exist: getSearchText". I have tried different methods of assignment but only the error messages change.

 

It's the test class that fails, the first one doesn't throw any errors.

 

I'm aware of the issue with execution order of the getter and setter but ignoring it for the moment, just want to be able to get the testing going.

 

Any advice?

 

/Mats

I am having the following problem. When I use TODAY literal in my SOQL statements comparing with ActivityDate for some reason the records where date = tomorrow are returned. Here are the details:

Code:
Select e.ActivityDate, e.ActivityDateTime, e.Id, e.Subject from Event e  
Where e.OwnerId = '<myId>' AND e.ActivityDate = TODAY

Today is 05/18/2007


The statement does not return events where ActivityDate is 05/18/2007. Instead in returns events where ActivityDate is 05/19/2007.

When I filter by a Datetime field (Event.ActivityDatetime) this does not occur and correct records are returned.


For now, I just simply modified my SOQL to use YESTERDAY instead of TODAY. But I would like to know the reason for this behavior. Am I missing something here or this could be an issue?


Thank you.