• nihar
  • NEWBIE
  • 288 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 49
    Questions
  • 41
    Replies
Hi all,

As i am looking for Api keys for fetching the data from salesforce partner marketing center to salesforce sales or sevice cloud.

can anyone suggest me Api keys............

Thanks Inadvance...............................
  • November 25, 2020
  • Like
  • 0
Hi all,

Einstein Analytics and Discovery Insights Specialist Super Badge
Challenge 5:

Challenge Not yet complete... here's what's wrong:
We can't confirm 'Predicted Tenure' was selected as the story outcome. Confirm your story's recommendation is 'Predicted Tenure' and your story outcome field is 'Predicted Tenure'.

can any one help me.......................

Thanks inadvance..............
  • July 13, 2020
  • Like
  • 0
Hi all,

I am doing Einstein Analytics and Discovery Insights Specialist Super Badge Challenge 5..................

I am Facing error can anyone help me....................

Challenge Not yet complete... here's what's wrong:
We can't confirm 'Predicted Tenure' was selected as the story outcome. Confirm your story's recommendation is 'Predicted Tenure' and your story outcome field is 'Predicted Tenure'.

Thanks inadvance.............................
 
  • July 10, 2020
  • Like
  • 0
Hi all,

I created status field in message_log custom object.
Whenever a new message comes i want to update status field to new incoming message.
How can i achieve it can any suggest me.

Thanks InAdvance.
  • March 10, 2020
  • Like
  • 0
Hi all,

I created an visualforce page for bulk send sms.

User-added image
    I want to insert custom object field names in the message log how        can i achieve it any suggestions

My code:
 
<apex:page standardController="Campaign" extensions="Campaignbulk"  showHeader="true" sidebar="true">
    <apex:form >        
        <apex:pageBlock id="ThePage">                       
            <apex:pageBlockSection columns="1" rendered="{!firstPanel}">                
                <apex:outputText label="Campaign Name :">
                    {!campaign.name}
                </apex:outputText>                
                <apex:outputText label="Count :">
                    {!cnt}
                </apex:outputText> 
                <apex:inputTextarea value="{!smsText }" label="Text :" html-maxLength="160" rows="5" cols="40" required="true" style="resize:none;"/>
                <apex:commandButton value="send" action="{!sendbulk}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection rendered="{!secondPanel}" >                   
                <h1>
                  "Total {!cnt} Message in queue".
                    
                </h1>
            </apex:pageBlockSection> 
        </apex:pageBlock>        
    </apex:form>   
</apex:page>



Thanks inadvance......
  • March 04, 2020
  • Like
  • 0
Hi all,

How can i see new incoming  sms from contact or lead in m home message.
Like  a popup you got a new message or any ....
can any one suggest me.

Thanks inadvance..............
  • March 03, 2020
  • Like
  • 0
Hi Everyone,

Can anyone help me in test class.
I have an error in test method assert .

User-added image
Test class :
 
@isTest
public class TwnxTest {

    //this method for testing with names as "Twilio"
    public static testmethod void testSmsFromTwnxWithNameAsTwilio(){        
        
        Contact con = new Contact(LastName='test',Phone='+19343213321');
        insert con;
        
        ApexPages.StandardController sc = new ApexPages.StandardController(con);
        
        Twnx twInstance = new Twnx(sc);
        
        configuration_setting__c configSettings= new configuration_setting__c();
        configSettings.Name='Twilio';
        configSettings.AccountSid__c = 'accountId';
        configSettings.Active__c = true;
        configSettings.AuthToken__c ='auth002';
        configSettings.Bulk_SMS__c='+18559331384';
        configSettings.Contact_Phone_Number__c='+18559172384';
        configSettings.Lead_Phone_Number__c='+14154633840';        
        insert configSettings;
        
        Test.setMock(HttpCalloutMock.class, new Twilio_MockClass());
        
        
        System.Test.startTest();
        
        Twilio.sendfromtwilio(configSettings.Contact_Phone_Number__c,'test',con.Phone);
        twInstance.sendfromtwnx();
        twInstance.ok();
        
        System.Test.stopTest();
    }
    
    //this method for testing with names as "Nexmo"
    public static testmethod void testSmsFromTwnxWithNameAsNexmo(){        
        
        Contact con = new Contact(LastName='test',Phone='+19343213321');
        insert con;
        
        ApexPages.StandardController sc = new ApexPages.StandardController(con);
        
        Twnx twInstance = new Twnx(sc);
        
        configuration_setting__c configSettings= new configuration_setting__c();
        configSettings.Name='Nexmo';
        configSettings.AccountSid__c = 'accountId';
        configSettings.Active__c = true;
        configSettings.AuthToken__c ='auth002';
        configSettings.Bulk_SMS__c='+18559331384';
        configSettings.Contact_Phone_Number__c='+18559172384';
        configSettings.Lead_Phone_Number__c='+14154633840';      
        insert configSettings; 
        
       	Test.setMock(HttpCalloutMock.class, new Nexmo_MockClass());
        
        
        System.Test.startTest();
        
        Nexmo.sendMessage( con.Phone,  configSettings.Contact_Phone_Number__c,  'text',  'sms');
        twInstance.sendfromtwnx();
        twInstance.ok();
        
        System.Test.stopTest();
    }
}

 
  • February 28, 2020
  • Like
  • 0

Hi all,

I am trying to capture email bounce.
how can i send emails and capture the email bounce(field) in contact and lead........
can any suggest.............

thanking you all inadvance....................

  • February 17, 2020
  • Like
  • 0
hi all,

I am facing error: You have uncommitted work pending. Please commit or rollback before calling out and i have used @future(callout = true) method it is not working can anyone help me with these

Apex Class:
 
public class Campaignbulk {
    public campaign camp;
    public integer cnt{get;set;}
    public string Text {get;set;}
    Public list<Campaignmember> camplist=new list<Campaignmember>();
    public list<Campaign> listcamp =new list<Campaign>();
    public Campaignbulk (ApexPages.StandardController stdController)
    {
        this.camp =(Campaign)stdController.getRecord(); 
        cnt=[ SELECT count() FROM Campaignmember WHERE CampaignId =:camp.Id];   
        camplist=[ SELECT phone FROM Campaignmember WHERE CampaignId =:camp.Id];  
    }
    
    public  void sendbulk(){
        
        List<SMS_Response__c> responseList= new List <SMS_Response__c>();
        for(Campaignmember Cpgmb: camplist ) {
            
            SMS_Response__c NewRec = new SMS_Response__c();
            NewRec.Mobile_Number__c =Cpgmb.Phone ;
            NewRec.Message__c = Text;
            NewRec.SMS_Type__c = 'OutGoing Message' ;
            NewRec.Service_Providers__c = 'Nexmo'; 
            NewRec.Campaign__c=camp.Id;
            NewRec.Status__c='Processing';
            responseList.add(NewRec);
        } 
        
        if (responseList.size()>0)
            insert(responseList);
        
        processCampaign(camp.Id, Text);
    } 
    @future(callout=true)
    public static void processCampaign(string campaignID, String smsText){
        
        configuration_setting__c conf = [select Name, Phone_Numbers__c,Lead_Phone_Number__c 
                                         FROM configuration_setting__c where Active__c =True  limit 1 ];                     
        
        List<String> lstAlpha = conf.Phone_Numbers__c.split(',');
        Integer currentPhone=0;
        
        List<Campaignmember> camplist=[ SELECT phone FROM Campaignmember WHERE CampaignId =:campaignID];
        
        for(Campaignmember Cpgmb: camplist ) {
            
            String newStatus= Nexmo.bulksms(  Cpgmb.Phone,  lstAlpha[currentPhone++],  smsText, 'sms');
            
           Campaignbulk.insertstatus(campaignID,Cpgmb.Phone,newStatus);
           
            if (currentPhone >= lstAlpha.size()){
                currentPhone=0;
            }
            
        } // end of all campaing memebers 
        
    } // end of method
    
    Public static void insertstatus(string campaignID,string Cpgmbphone,string newStatus){
         List<SMS_Response__c> smsRespList = [select id, status__c from SMS_Response__c where Campaign__c=:campaignID
                                                 and status__c='Processing' 
                                                 and Mobile_Number__c =:Cpgmbphone];
            
            if (smsRespList!= null && smsRespList.size()>0 ) {
                for(SMS_Response__c smsrp:smsRespList){
                    smsrp.status__c =newStatus;
                    
                }
                system.debug('My updated list'+smsRespList);
                 update smsRespList;
            }
    }
    
}

 
  • February 10, 2020
  • Like
  • 0
Hi all,

I am trying to add a button in Campaign Members page in lightining but it is not showing up there can anyone suggest me any ideas how to add..

Thanking you inadvance
  • January 30, 2020
  • Like
  • 0
Hi all,
I have working Code the sends an SMS  via Apex and Twilio and nexmo, Great stuff. The trouble I am having is writing the Tests and I just need a little help. I don't do near enough Apex for my liking and I am feeling it here. 

IAny help/pointers would be most appreciated. 

Apex Class:
 
public with sharing class Bulkconsms {
    public list<contact> selectedcons {set;get;}
    public list<contact> selectedcontacts = new list<Contact>();
    Public string TextMSG {get;set;}
    list<Task> ldlst=new list<Task>();
    list <SMS_Response__c>conlis=new list<SMS_Response__c>();
    public List<ConWrapper> lstWrapper {get;set;}
    public List<ConWrapper> lstSetController{get;set;}
    public Boolean displayPopup {get;set;}
    CustomIterable obj;   
    
    public Bulkconsms()      {      
        
        lstWrapper =  new List<ConWrapper>();        
        lstSetController = new List<ConWrapper>();
        
        List<Contact> lstContact = [select id,FirstName,LastName,Email,account.Name,MailingCity,MailingState,Phone,Title,MobilePhone,Account.AnnualRevenue,
                                    account.Industry,LeadSource,Fax,account.Website,Description from contact order by LastName DESC LIMIT 990]; 
        
        
        system.debug('Contact count :'+lstContact.size());
        for(Contact cont : lstContact )  
        {            
            lstWrapper.add(new ConWrapper(cont ,false));         
        }         
        obj = new CustomIterable (lstWrapper);          
        obj.setPageSize = 10;         
        next();              
    }                   
    public Boolean hasNext {             
        get {
            return obj.hasNext(); 
        }    set; 
    }                  
    public Boolean hasPrevious {
        get { 
            return obj.hasPrevious();
        }   set;
    }                 
    public void next()         
    {             
        lstSetController = obj.next();        
    }                  
    public void previous()          
    {             
        lstSetController = obj.previous();        
    }
    public pagereference homepage()
    {
        PageReference pr = new PageReference('/apex/BulkSmsHome');
        return pr;
    }    
    
    public void processSelected() {                       
        displayPopup = true;               
        selectedcons = new List<contact>();
        
        for(ConWrapper wrapconObj : lstSetController) {
            if(wrapconObj.isselected == true) {
                selectedcons.add(wrapconObj.cont);
                selectedcontacts.add(wrapconobj.cont);
                
            }
            
        }
        try{
            if(selectedcontacts.size()>0){                                                
            }
        } catch(Exception Ex){
        }
    }
    public void closePopup()
    {
        displayPopup = false;
    }
    
    
    
    public void listofcons(){
        for(contact c : selectedcontacts){
            
        }
    }
    public void ldinsert(){      
        
        for(contact con : selectedcontacts){
            configuration_setting__c conf = [select Name,AccountSid__c, Active__c,AuthToken__c,Bulk_SMS__c,Contact_Phone_Number__c,Lead_Phone_Number__c,TestPhone__c FROM configuration_setting__c where Active__c =True  limit 1 ];
            {
                if(conf.Name =='Twilio'){
                    string Text =TextMSG;
                    string tonumber =con.Phone;
                    string Fromnumber=conf.Bulk_SMS__c;
                    Twilio.sendfromtwilio(Fromnumber,Text,tonumber);
                }else if(conf.Name =='Nexmo'){
                    string tonum=con.phone;
                    integer [] tonmb= tonum.getChars();
                    tonmb.remove(0);
                    string toId=string.fromCharArray(tonmb);
                    string fromId = conf.Bulk_SMS__c;
                    string text =TextMSG;
                    string channel ='sms';
                    Nexmo.sendMessage( toId,  fromId,  text,  channel);
                }
            } 
            
            Task newTask = new Task();
            newTask.WhoId = con.Id ;
            newTask.Subject = 'SMS Send';
            newTask.priority= 'Normal' ;
            newTask.status = 'Completed';
            newTask.description = TextMSG ;
            newTask.ActivityDate = System.today() ;            
            ldlst.add(newTask);
            
            SMS_Response__c NewRec = new SMS_Response__c();
            NewRec.Mobile_Number__c =con.Phone ;
            NewRec.Message__c = TextMSG;
            NewRec.SMS_Type__c = 'OutGoing Message' ;
            NewRec.Service_Providers__c = 'Bulk sms from Twilio';
            conlis.add(NewRec);
            
            displayPopup = false;
        }
        if(ldlst.size()>0){
            
            try{
                insert ldlst ;   
                insert conlis;
                
            }
            catch(DMLException E){
                
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,E.getMessage()));
            }
            
        }
    }  
    
    public class ConWrapper {
        public Boolean isSelected {get;set;}
        public Contact cont{get;set;}            
        public ConWrapper(Contact c,Boolean isSelected)     {         
            this.cont= c;        
            this.isSelected= false;    
        }
    }
    public class  CustomIterable implements Iterator<list<ConWrapper>> {    
        list<ConWrapper> InnerList{get; set;}    
        list<ConWrapper> ListRequested{get; set;}    
        Integer i {get;set;}    
        public Integer setPageSize {get;set;}    
        public CustomIterable(List<ConWrapper> lstAccWr)    {        
            InnerList = new list<ConWrapper>();         
            ListRequested = new list<ConWrapper>();           
            InnerList = lstAccWr;       
            setPageSize = 5;       
            i = 0;    
        }       
        public boolean hasNext(){        
            if(i >= InnerList.size()) 
            {           
                return false;        
            } else {            
                return true;         
            }    
        }         
        public boolean hasPrevious(){         
            
            if(i <= setPageSize) {            
                return false;         
            } else {            
                return true;        
            }    
        }       
        public list<ConWrapper> next(){               
            
            ListRequested = new list<ConWrapper>();         
            integer startNumber;       
            integer size = InnerList.size();       
            if(hasNext())        {             
                if(size <= (i + setPageSize))  {                
                    startNumber = i;               
                    i = size;            
                }  else  {               
                    i = (i + setPageSize);                
                    startNumber = (i - setPageSize);           
                }                       
                
                for(integer start = startNumber; start < i; start++)    
                {               
                    ListRequested.add(InnerList[start]);           
                }        
            }  
            return ListRequested;    
        }         
        public list<ConWrapper> previous(){            
            ListRequested = new list<ConWrapper>();        
            
            integer size = InnerList.size();         
            if(i == size)   {            
                if(math.mod(size, setPageSize) > 0)            
                {                   
                    i = size - math.mod(size, setPageSize);          
                }  else  {                
                    i = (size - setPageSize);          
                }         
            } else  {          
                i = (i - setPageSize);       
            }               
            
            for(integer start = (i - setPageSize); start < i; ++start)        
            {            
                ListRequested.add(InnerList[start]);       
            }         
            return ListRequested;   
        }   
    }
    
}

 
  • January 20, 2020
  • Like
  • 0
Hi all,
I have working Code the sends an SMS  via Apex and Twilio, Great stuff. The trouble I am having is writing the Tests and I just need a little help. I don't do near enough Apex for my liking and I am feeling it here. 

IAny help/pointers would be most appreciated. 

Apex class:
public with sharing class Twilio {
    
    Public string text1 {get;set;}
    public boolean showmessage{get;set;}
    public string selectedvalue {get;set;} 
    
    private final contact acct;
    public Twilio(){}
    public Twilio(ApexPages.StandardController stdController) {
        this.acct = (contact)stdController.getRecord();       
    }
    
    Public static Void sendfromtwilio (string Fromnumber,string text,string tonumber) {
        
        errorResponseWrapper erw;
        configuration_setting__c cstt=new configuration_setting__c();
        cstt = [select Name,AccountSid__c, Active__c,AuthToken__c,Bulk_SMS__c,Contact_Phone_Number__c,Lead_Phone_Number__c,TestPhone__c FROM configuration_setting__c where Name='Twilio' limit 1];
        String account = cstt.AccountSid__c;
        String token = cstt.AuthToken__c;
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.twilio.com/2010-04-01/Accounts/'+account+'/SMS/Messages.json');
        
        req.setMethod('POST');
        
        String VERSION  = '3.2.0';
        
        req.setHeader('X-Twilio-Client', 'salesforce-' + VERSION);
        
        req.setHeader('User-Agent', 'twilio-salesforce/' + VERSION);
        
        req.setHeader('Accept', 'application/json');
        
        req.setHeader('Accept-Charset', 'utf-8');
        
        req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf(account+':' +token)));
        
        req.setBody('To='+EncodingUtil.urlEncode(+tonumber,'UTF-8')+'&From='+EncodingUtil.urlEncode(+Fromnumber,'UTF-8')+'&Body='+text);
        
        Http http = new Http();        
        HTTPResponse res = http.send(req);  
        System.debug(res.getBody());
        system.debug(res.getStatusCode());
        if(res.getStatusCode()==201)
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Confirm,'SMS Sent Successfully'));
        } else{
            erw =(errorResponseWrapper)json.deserialize(res.getBody(),errorResponseWrapper.class);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,erw.message));
            System.debug('ERROR');
        }
    }
    public PageReference ok(){
        PageReference acctPage = new PageReference('/' +acct.Id);
        acctPage.setRedirect(true);
        return acctPage;
    }  
    public class errorResponseWrapper{
        String code;       
        String message;        
        String moreInfo;        
        String status;    
    }
}
  • January 14, 2020
  • Like
  • 0
Hi all,

I'm trying to create a validation rule for our phone numbers. Every number has 2 parts:

Country Code (numerical, 1 digit starts with '+') --> +1

Number (numerical, no digit limit, cannot start with 0)

Examples:

+12019841724

Thanks for help.
  • January 08, 2020
  • Like
  • 0
hi all,
Apex class and visualforce page for
wrapper class and pagination for lead and contact records in salesforce. can anyone help mee i am new to the salesforce coding............
Thanking you all in advance....................
  • December 03, 2019
  • Like
  • 0
Hi all,
I am performing wrapper class and pagienation for all standard objects can any one help me with my code .
 apex class:
public class contactPaginationController{
 
 //variable used in page.
 Public Integer size{get;set;}
 Public Integer noOfRecords{get; set;}
 public List<SelectOption> paginationSizeOptions{get;set;}
 public static final Integer QUERY_LIMIT = 10000;
 public static final Integer PAGE_SIZE = 5;
 
 public List <WrapperClass> wrapperRecordList{get;set;}
 Map<Id, WrapperClass> mapHoldingSelectedRecords{get;set;}
 
 //constructor calling init method.
 public contactPaginationController(){
   mapHoldingSelectedRecords = new Map<Id, WrapperClass>();
   init();
 
 }
 
//Init method which queries the records from standard set controller.
 public void init() {
 wrapperRecordList = new List<WrapperClass>();
 for (Contact cont : (List<Contact>)setCon.getRecords()) {
 if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(cont.id)){
 wrapperRecordList.add(mapHoldingSelectedRecords.get(cont.id));
 
 }
 else{
   wrapperRecordList.add(new WrapperClass(cont, false));
 }
 }
 }
 
 /** Instantiate the StandardSetController from a query locater*/
 public ApexPages.StandardSetController setCon {
 get {
 if(setCon == null) {
   setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id,Name, Email, Phone FROM Contact LIMIT : QUERY_LIMIT ]));
 
   // sets the number of records to show in each page view
   setCon.setPageSize(PAGE_SIZE);
 }
   return setCon;
 }
 set;
 }
 
 /** indicates whether there are more records after the current page set.*/
 public Boolean hasNext {
 get {
   return setCon.getHasNext();
 }
 set;
 }
 
 /** indicates whether there are more records before the current page set.*/
 public Boolean hasPrevious {
 get {
   return setCon.getHasPrevious();
 }
 set;
 }
 
 /** returns the page number of the current page set*/
 public Integer pageNumber {
 get {
   return setCon.getPageNumber();
 }
 set;
 }
 
 /** return total number of pages for page set*/
   Public Integer getTotalPages(){
     Decimal totalSize = setCon.getResultSize();
     Decimal pageSize = setCon.getPageSize();
     Decimal pages = totalSize/pageSize;
     return (Integer)pages.round(System.RoundingMode.CEILING);
 }
 
 /** returns the first page of the page set*/
 public void first() {
   updateSearchItemsMap();
   setCon.first();
   init();
 }
 
 /** returns the last page of the page set*/
 public void last() {
   updateSearchItemsMap();
   setCon.last();
   init();
 }
 
 /** returns the previous page of the page set*/
 public void previous() {
   updateSearchItemsMap();
   setCon.previous();
   init();
 }
 
 /** returns the next page of the page set*/
 public void next() {
   updateSearchItemsMap();
   setCon.next();
   init();
 }
 
 //This is the method which manages to remove the deselected records, and keep the records which are selected in map.
 private void updateSearchItemsMap() {
 for(WrapperClass wrp : wrapperRecordList){
  if(wrp.isSelected){
     mapHoldingSelectedRecords.put(wrp.contactRecord.id, wrp);
  }
  if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.contactRecord.id)){
     mapHoldingSelectedRecords.remove(wrp.contactRecord.id);
  }
 }
 }
 
 //wrapper class being used for checkbox showing.
 public class WrapperClass {
 public Boolean isSelected {get;set;}
 public Contact contactRecord {get;set;}
 public WrapperClass(Contact contactRecord, Boolean isSelected) {
    this.contactRecord = contactRecord;
    this.isSelected = isSelected;
 }
 }
 
}

visualforce page :
<apex:page controller="contactPaginationController" docType="html-5.0" tabStyle="Contact">
   <apex:sectionHeader title="Contact" subtitle="Contact Pagination" />
    <apex:form id="theForm">
      <apex:pageBlock title="All Contacts" rendered="{!wrapperRecordList.size!=0}" id="pbId" >
        <apex:pageBlockTable value="{!wrapperRecordList}" var="cont">
           <apex:column headerValue="Select">
             <apex:inputCheckbox value="{!cont.isSelected}"/>
           </apex:column>
           <apex:column headerValue="Name">
             <apex:outputField value="{!cont.contactRecord.name}"/>
           </apex:column>
           <apex:column headerValue="Email">
             <apex:outputField value="{!cont.contactRecord.Email}"/>
           </apex:column>
           <apex:column headerValue="Phone">
            <apex:outputField value="{!cont.contactRecord.Phone}"/>
           </apex:column>
       </apex:pageBlockTable>
 
 <!-- Action Buttons visible on bottom of page for pagination -->
       <apex:outputPanel style="text-align:center;" layout="block">
         
          <apex:commandButton value="Previous" rerender="pbId" action="{!previous}" disabled="{!NOT(hasPrevious)}" status="paginationStatus"/>&nbsp;Page {!pageNumber} of {!totalPages}&nbsp;
          <apex:commandButton value="Next" rerender="pbId" action="{!next}" disabled="{!NOT(hasNext)}" status="paginationStatus"/>
         
          <apex:actionStatus id="paginationStatus">
             <apex:facet name="start">
                 Please wait...<img src="/img/loading32.gif" style="width: 18px;"/>
             </apex:facet>
          </apex:actionStatus>
       </apex:outputPanel>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Thanks in advance..............
  • November 29, 2019
  • Like
  • 0
Hi all ,
Can anyone help me with my code for pagienation of records........
Thanks in Advance.............
 apex class :
public class objectcontroller
{
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public list<wrapcontact> wrapcon{get;set;}
    public list<wrapLead> wrapLd{get;set;}
    public objectcontroller()
    {
        obj1Status=false;
        obj2Status=false;
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
        wrapcon = new List<wrapcontact>();
        wrapLd = new list<wrapLead>();
    }
    public pageReference getRecordofObject()
    {
         if(selected=='contact')
        {
            for(contact c :[select id,lastname,Email from contact limit 100]){
            wrapcon.add(new wrapcontact(c));
            }
            obj1Status=true;
            obj2status=false;
        }   
        else
        {
            for(lead l:[select name,company,Status from lead limit 100]){
                wrapLd.add(new wrapLead(l));
            }
            obj1status=false;
            obj2Status=true;
        }
        return null;
    }
    public class wrapcontact {
        public contact con {get; set;}
        public Boolean selected {get; set;}
 
        public wrapcontact(contact a) {
            con = a;
            selected = false;
        }
    }
    public class wraplead{
        public lead Ld {get; set;}
        public Boolean selected {get; set;}
 
        public wraplead(lead a) {
            Ld = a;
            selected = false;
        }
    }
    
}

Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            </apex:selectList>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob1.con.id}"/>
                        <apex:column value="{!ob1.con.lastname}"/>
                        <apex:column value="{!ob1.con.Email}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>  
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob2.Ld.id}"/>
                        <apex:column value="{!ob2.Ld.company}"/>
                        <apex:column value="{!ob2.Ld.status}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>

Thanks in advance........
  • November 27, 2019
  • Like
  • 0
Hi all,
Can any one suggest any email unsubscribed optout and optin guide or app exchange tool............

Thanks in advance...............
  • November 25, 2019
  • Like
  • 0
Hi all,
I generate the code for displaying the records of object choosen in picklist field (Lead and Contact)
Actually i want to add Previous and Next buttons after dipalying the records..
Example if have 50 records first it will displayed only 10 records for next records we should have Next Or previous buttons...........
Here is my code...
Apex class :
public class objectcontroller
{
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public list<wrapcontact> wrapcon{get;set;}
    public list<wrapLead> wrapLd{get;set;}
    public objectcontroller()
    {
        obj1Status=false;
        obj2Status=false;
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
        wrapcon = new List<wrapcontact>();
        wrapLd = new list<wrapLead>();
    }
    public pageReference getRecordofObject()
    {
         if(selected=='contact')
        {
            for(contact c :[select id,lastname,Email from contact limit 100]){
            wrapcon.add(new wrapcontact(c));
            }
            obj1Status=true;
            obj2status=false;
        }   
        else
        {
            for(lead l:[select name,company,Status from lead limit 100]){
                wrapLd.add(new wrapLead(l));
            }
            obj1status=false;
            obj2Status=true;
        }
        return null;
    }
    public class wrapcontact {
        public contact con {get; set;}
        public Boolean selected {get; set;}
 
        public wrapcontact(contact a) {
            con = a;
            selected = false;
        }
    }
    public class wraplead{
        public lead Ld {get; set;}
        public Boolean selected {get; set;}
 
        public wraplead(lead a) {
            Ld = a;
            selected = false;
        }
    }
    
}
Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            </apex:selectList>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob1.con.id}"/>
                        <apex:column value="{!ob1.con.lastname}"/>
                        <apex:column value="{!ob1.con.Email}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>  
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob2.Ld.id}"/>
                        <apex:column value="{!ob2.Ld.company}"/>
                        <apex:column value="{!ob2.Ld.status}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>

Thanks in advance.......
  • November 19, 2019
  • Like
  • 0
Hi All,
How to add select check box after displaying Lead and Contact records in visualforce page.
I have written the apex class and visual force page for displaying records both leads and contacts here is my code..........
apex class:
public class objectcontroller
{
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public objectcontroller()
    {
        obj1Status=false;
        obj2Status=false;
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
    }
    public pageReference getRecordofObject()
    {
         if(selected=='contact')
        {
            obj1=[select id,lastname,Email from contact limit 100];
            obj1Status=true;
        }   
        else
        {
            obj2=[select name,company,Status from lead limit 100];
            obj2Status=true;
        }
        return null;
    }
    
}

Visualforce page:
<apex:page controller="objectcontroller" showHeader="false">
    
    <apex:form >
        
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            </apex:selectList>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!obj1}" var="ob1" rendered="{!obj1Status}">
                        <apex:column value="{!ob1.id}"/>
                        <apex:column value="{!ob1.lastname}"/>
                        <apex:column value="{!ob1.Email}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>  
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!obj2}" var="ob2" rendered="{!obj2Status}">
                        <apex:column value="{!ob2.id}"/>
                        <apex:column value="{!ob2.company}"/>
                        <apex:column value="{!ob2.status}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>
  • November 18, 2019
  • Like
  • 0

When i select the drop down the Lead or Contact object how can we see all Lead and contact records in visual force page. will you Plz suggest how to write code & How to create VF Page ?

Thank You
  • November 18, 2019
  • Like
  • 0
Hi all,

I created status field in message_log custom object.
Whenever a new message comes i want to update status field to new incoming message.
How can i achieve it can any suggest me.

Thanks InAdvance.
  • March 10, 2020
  • Like
  • 0
Hi all,
I have working Code the sends an SMS  via Apex and Twilio, Great stuff. The trouble I am having is writing the Tests and I just need a little help. I don't do near enough Apex for my liking and I am feeling it here. 

IAny help/pointers would be most appreciated. 

Apex class:
public with sharing class Twilio {
    
    Public string text1 {get;set;}
    public boolean showmessage{get;set;}
    public string selectedvalue {get;set;} 
    
    private final contact acct;
    public Twilio(){}
    public Twilio(ApexPages.StandardController stdController) {
        this.acct = (contact)stdController.getRecord();       
    }
    
    Public static Void sendfromtwilio (string Fromnumber,string text,string tonumber) {
        
        errorResponseWrapper erw;
        configuration_setting__c cstt=new configuration_setting__c();
        cstt = [select Name,AccountSid__c, Active__c,AuthToken__c,Bulk_SMS__c,Contact_Phone_Number__c,Lead_Phone_Number__c,TestPhone__c FROM configuration_setting__c where Name='Twilio' limit 1];
        String account = cstt.AccountSid__c;
        String token = cstt.AuthToken__c;
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.twilio.com/2010-04-01/Accounts/'+account+'/SMS/Messages.json');
        
        req.setMethod('POST');
        
        String VERSION  = '3.2.0';
        
        req.setHeader('X-Twilio-Client', 'salesforce-' + VERSION);
        
        req.setHeader('User-Agent', 'twilio-salesforce/' + VERSION);
        
        req.setHeader('Accept', 'application/json');
        
        req.setHeader('Accept-Charset', 'utf-8');
        
        req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf(account+':' +token)));
        
        req.setBody('To='+EncodingUtil.urlEncode(+tonumber,'UTF-8')+'&From='+EncodingUtil.urlEncode(+Fromnumber,'UTF-8')+'&Body='+text);
        
        Http http = new Http();        
        HTTPResponse res = http.send(req);  
        System.debug(res.getBody());
        system.debug(res.getStatusCode());
        if(res.getStatusCode()==201)
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Confirm,'SMS Sent Successfully'));
        } else{
            erw =(errorResponseWrapper)json.deserialize(res.getBody(),errorResponseWrapper.class);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,erw.message));
            System.debug('ERROR');
        }
    }
    public PageReference ok(){
        PageReference acctPage = new PageReference('/' +acct.Id);
        acctPage.setRedirect(true);
        return acctPage;
    }  
    public class errorResponseWrapper{
        String code;       
        String message;        
        String moreInfo;        
        String status;    
    }
}
  • January 14, 2020
  • Like
  • 0
hi all,
Apex class and visualforce page for
wrapper class and pagination for lead and contact records in salesforce. can anyone help mee i am new to the salesforce coding............
Thanking you all in advance....................
  • December 03, 2019
  • Like
  • 0
Hi all,
I am performing wrapper class and pagienation for all standard objects can any one help me with my code .
 apex class:
public class contactPaginationController{
 
 //variable used in page.
 Public Integer size{get;set;}
 Public Integer noOfRecords{get; set;}
 public List<SelectOption> paginationSizeOptions{get;set;}
 public static final Integer QUERY_LIMIT = 10000;
 public static final Integer PAGE_SIZE = 5;
 
 public List <WrapperClass> wrapperRecordList{get;set;}
 Map<Id, WrapperClass> mapHoldingSelectedRecords{get;set;}
 
 //constructor calling init method.
 public contactPaginationController(){
   mapHoldingSelectedRecords = new Map<Id, WrapperClass>();
   init();
 
 }
 
//Init method which queries the records from standard set controller.
 public void init() {
 wrapperRecordList = new List<WrapperClass>();
 for (Contact cont : (List<Contact>)setCon.getRecords()) {
 if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(cont.id)){
 wrapperRecordList.add(mapHoldingSelectedRecords.get(cont.id));
 
 }
 else{
   wrapperRecordList.add(new WrapperClass(cont, false));
 }
 }
 }
 
 /** Instantiate the StandardSetController from a query locater*/
 public ApexPages.StandardSetController setCon {
 get {
 if(setCon == null) {
   setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id,Name, Email, Phone FROM Contact LIMIT : QUERY_LIMIT ]));
 
   // sets the number of records to show in each page view
   setCon.setPageSize(PAGE_SIZE);
 }
   return setCon;
 }
 set;
 }
 
 /** indicates whether there are more records after the current page set.*/
 public Boolean hasNext {
 get {
   return setCon.getHasNext();
 }
 set;
 }
 
 /** indicates whether there are more records before the current page set.*/
 public Boolean hasPrevious {
 get {
   return setCon.getHasPrevious();
 }
 set;
 }
 
 /** returns the page number of the current page set*/
 public Integer pageNumber {
 get {
   return setCon.getPageNumber();
 }
 set;
 }
 
 /** return total number of pages for page set*/
   Public Integer getTotalPages(){
     Decimal totalSize = setCon.getResultSize();
     Decimal pageSize = setCon.getPageSize();
     Decimal pages = totalSize/pageSize;
     return (Integer)pages.round(System.RoundingMode.CEILING);
 }
 
 /** returns the first page of the page set*/
 public void first() {
   updateSearchItemsMap();
   setCon.first();
   init();
 }
 
 /** returns the last page of the page set*/
 public void last() {
   updateSearchItemsMap();
   setCon.last();
   init();
 }
 
 /** returns the previous page of the page set*/
 public void previous() {
   updateSearchItemsMap();
   setCon.previous();
   init();
 }
 
 /** returns the next page of the page set*/
 public void next() {
   updateSearchItemsMap();
   setCon.next();
   init();
 }
 
 //This is the method which manages to remove the deselected records, and keep the records which are selected in map.
 private void updateSearchItemsMap() {
 for(WrapperClass wrp : wrapperRecordList){
  if(wrp.isSelected){
     mapHoldingSelectedRecords.put(wrp.contactRecord.id, wrp);
  }
  if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.contactRecord.id)){
     mapHoldingSelectedRecords.remove(wrp.contactRecord.id);
  }
 }
 }
 
 //wrapper class being used for checkbox showing.
 public class WrapperClass {
 public Boolean isSelected {get;set;}
 public Contact contactRecord {get;set;}
 public WrapperClass(Contact contactRecord, Boolean isSelected) {
    this.contactRecord = contactRecord;
    this.isSelected = isSelected;
 }
 }
 
}

visualforce page :
<apex:page controller="contactPaginationController" docType="html-5.0" tabStyle="Contact">
   <apex:sectionHeader title="Contact" subtitle="Contact Pagination" />
    <apex:form id="theForm">
      <apex:pageBlock title="All Contacts" rendered="{!wrapperRecordList.size!=0}" id="pbId" >
        <apex:pageBlockTable value="{!wrapperRecordList}" var="cont">
           <apex:column headerValue="Select">
             <apex:inputCheckbox value="{!cont.isSelected}"/>
           </apex:column>
           <apex:column headerValue="Name">
             <apex:outputField value="{!cont.contactRecord.name}"/>
           </apex:column>
           <apex:column headerValue="Email">
             <apex:outputField value="{!cont.contactRecord.Email}"/>
           </apex:column>
           <apex:column headerValue="Phone">
            <apex:outputField value="{!cont.contactRecord.Phone}"/>
           </apex:column>
       </apex:pageBlockTable>
 
 <!-- Action Buttons visible on bottom of page for pagination -->
       <apex:outputPanel style="text-align:center;" layout="block">
         
          <apex:commandButton value="Previous" rerender="pbId" action="{!previous}" disabled="{!NOT(hasPrevious)}" status="paginationStatus"/>&nbsp;Page {!pageNumber} of {!totalPages}&nbsp;
          <apex:commandButton value="Next" rerender="pbId" action="{!next}" disabled="{!NOT(hasNext)}" status="paginationStatus"/>
         
          <apex:actionStatus id="paginationStatus">
             <apex:facet name="start">
                 Please wait...<img src="/img/loading32.gif" style="width: 18px;"/>
             </apex:facet>
          </apex:actionStatus>
       </apex:outputPanel>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Thanks in advance..............
  • November 29, 2019
  • Like
  • 0
Hi all ,
Can anyone help me with my code for pagienation of records........
Thanks in Advance.............
 apex class :
public class objectcontroller
{
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public list<wrapcontact> wrapcon{get;set;}
    public list<wrapLead> wrapLd{get;set;}
    public objectcontroller()
    {
        obj1Status=false;
        obj2Status=false;
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
        wrapcon = new List<wrapcontact>();
        wrapLd = new list<wrapLead>();
    }
    public pageReference getRecordofObject()
    {
         if(selected=='contact')
        {
            for(contact c :[select id,lastname,Email from contact limit 100]){
            wrapcon.add(new wrapcontact(c));
            }
            obj1Status=true;
            obj2status=false;
        }   
        else
        {
            for(lead l:[select name,company,Status from lead limit 100]){
                wrapLd.add(new wrapLead(l));
            }
            obj1status=false;
            obj2Status=true;
        }
        return null;
    }
    public class wrapcontact {
        public contact con {get; set;}
        public Boolean selected {get; set;}
 
        public wrapcontact(contact a) {
            con = a;
            selected = false;
        }
    }
    public class wraplead{
        public lead Ld {get; set;}
        public Boolean selected {get; set;}
 
        public wraplead(lead a) {
            Ld = a;
            selected = false;
        }
    }
    
}

Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            </apex:selectList>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob1.con.id}"/>
                        <apex:column value="{!ob1.con.lastname}"/>
                        <apex:column value="{!ob1.con.Email}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>  
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column value="{!ob2.Ld.id}"/>
                        <apex:column value="{!ob2.Ld.company}"/>
                        <apex:column value="{!ob2.Ld.status}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>

Thanks in advance........
  • November 27, 2019
  • Like
  • 0
Hi All,
How to add select check box after displaying Lead and Contact records in visualforce page.
I have written the apex class and visual force page for displaying records both leads and contacts here is my code..........
apex class:
public class objectcontroller
{
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public objectcontroller()
    {
        obj1Status=false;
        obj2Status=false;
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
    }
    public pageReference getRecordofObject()
    {
         if(selected=='contact')
        {
            obj1=[select id,lastname,Email from contact limit 100];
            obj1Status=true;
        }   
        else
        {
            obj2=[select name,company,Status from lead limit 100];
            obj2Status=true;
        }
        return null;
    }
    
}

Visualforce page:
<apex:page controller="objectcontroller" showHeader="false">
    
    <apex:form >
        
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            </apex:selectList>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!obj1}" var="ob1" rendered="{!obj1Status}">
                        <apex:column value="{!ob1.id}"/>
                        <apex:column value="{!ob1.lastname}"/>
                        <apex:column value="{!ob1.Email}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>  
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!obj2}" var="ob2" rendered="{!obj2Status}">
                        <apex:column value="{!ob2.id}"/>
                        <apex:column value="{!ob2.company}"/>
                        <apex:column value="{!ob2.status}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>
  • November 18, 2019
  • Like
  • 0
I'm stuck on step #2 of Einstein Analytics and Discovery Insights Specialist superbadge.  I'm getting this warning while checking the challenge:
Challenge #2 Not complete
The step "Churn Tenure' is in compact form, so the filter values need to be specifed as a minimum and maximum
The static step that feeds has the following the value:
 
"Tenure_Length": {
                "broadcastFacet": false,
                "label": "Tenure Length",
                "selectMode": "single",
                "type": "staticflex",
                "values": [
                    {
                        "display": "High Risk",
                        "value": "1 to 12 months",
                        "min": 1,
                        "max": 12
                    },
                    ...
                ]
            }


I'm using selection binding for min and max values.  The dashboard is correctly filtering:
User-added image
User-added image
Any ideas? 
I've tried a non-compact form step where I inject a saql fragment into the query, as well as where I inject min/max values using a range filter serialization...All these efforts end in the same challenge failure message.

Any help/suggesitions are welcome!
Hi All,
My task is  to create a visual force page by using apex class. In visualforce page there should be only id field and search butoon 
and my requirment as follows
there are 6 objects obj1,obj2,obj3,obj4,obj5,obj6
in which obj1 has realtion with obj2 & obj2 has realtion with obj3
& obj3 has realtion with obj4 & obj4 has realtion with obj5 & obj5 has realtion with obj6
but when i paste an record id in the search box i must get the related lists of all 6objects in one page.............

Thanks inadvance..........
  • May 14, 2018
  • Like
  • 0
Hi all,
My requirment is to create a visual force page (apex class) in that an id field and search button should be inserted........
when i paste an record id   in the   id field of visualforce page record should be displayed and related lists should be also displayed
  • May 10, 2018
  • Like
  • 0
Hi all ,
My requirment is to create sort order for tasks .........
the tasks are created when opportyunity record is created ........
Example : 3)Task3  but i want output has 1)Task1, 2)Task2, 3)Task3  in order
                 2)Task2
                 1)task1
My code :
public class CompsureTasks_helper{
    //Create tasks
    public static void createTasks(List<id> oppId){
    List<Opportunity> oppList = [select id,name,closedate,ownerid,Opportunity_Period__c from Opportunity where id IN : oppId];
    List<Task> insertTasks = new List<Task>();
    for(Opportunity opp : oppList){
    //for Task1
        task t = new task(OwnerId = opp.ownerid,Subject = 'Task1',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
           integer tt = (integer)Math.round((15*opp.Opportunity_Period__c)/100);
           system.debug('$$$'+tt);
           t.activitydate = system.today().adddays((integer)Math.round((15*opp.Opportunity_Period__c)/100));
           t.IsReminderSet = true;
           t.ReminderDateTime = t.activitydate;  
        insertTasks.add(t);
    //For Task2   
        task t1 = new task(OwnerId = opp.ownerid,Subject = 'Task2',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
            t1.activitydate = system.today().adddays((integer)Math.round((20*opp.Opportunity_Period__c)/100));
            t1.IsReminderSet = true;
            t1.ReminderDateTime = t1.activitydate;  
        insertTasks.add(t1);
      
    //For Task3   
        task t2 = new task(OwnerId = opp.ownerid,Subject = 'Task3',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
            t2.activitydate = system.today().adddays((integer)Math.round((25*opp.Opportunity_Period__c)/100));
            t2.IsReminderSet = true;
            t2.ReminderDateTime = t2.activitydate;  
        insertTasks.add(t2);
        
   
    }
    insert insertTasks;
    }
    }
  • May 10, 2018
  • Like
  • 0
hi all,
My Task is to change the due date or closed date of opportunity records under account object 
1st opportunity record to 75 days == created date + 75 days
2nd and 3rd or more to 180 days == created date +180 days



thanks in advance...
  • May 02, 2018
  • Like
  • 0
Hi All,
         I have this piece of code given below , Its a search page that displays results depending on search parametres and shows resuls with a checkbox next to them (Using Wrapper class). I wanna implement pagination here , Can anyone plz help me with the code?
Wrapper class line are highlighted.

public class AccountSearchController{

public List<Contact> ContactObjects {get;set;}
public List<Account> AccountObjects {get;set;}
public List<Account> AccountObjectsx {get;set;}
public Account AccObj {get;set;}
public Contact ContactObj {get;set;}
private String soql {get;set;}
//Our collection of the class/wrapper objects cContact 
public List<cContact> contactList {get; set;}
public ApexPages.StandardSetController con{get; set;}


////////////////////////////////////////////////////Constructor//////////////////////
public AccountSearchController(ApexPages.StandardController controller) {
  Value='Contact';
  ContactObj = new Contact();
  AccObj = new Account();
  // makes the defalut in the VF page for contact type as 'Main'
  ContactObj.Contact_Type__c ='Main';
  //pass value for picklist conatct type in query
  String slist = 'Main';
 
  // strings to pass defalut value of account segment and contact status and recordtype of account and contact as sales in query
  String defaultAccSegemnt= 'Regional';
  String defaultConStatus= 'Active';

  //list strings to pass account type in query as ('Active','Inactive','New')
  List <String> defaultAccType=new List<String>();
  String active= '\'Active\'';

  //userid = Userinfo.getUserId();
  userid='00550000000rgCd';
  system.debug('logged in user id>>>>>>>>>>'+ userid);
  
 
  soql ='SELECT Id,FirstName,LastName,Position__c,Contact.Account.IsPersonAccount,Contact.Account.Other_Address_Street_1__pc,Contact.Account.Phone ,Contact_Master_Policy_Mailing__c,Contact.Account.Type,Contact.Account.PY_Total_Ins_Volume__c,Contact_Type__c ,Phone,Email,Title, Contact.Account.Segment__c,Contact.Account.Parent_Name__c,Contact.Account.Branch_Org__c,Contact.Account.Name FROM Contact  ';

  runQuery();
 

}
public  PageReference runSearch() {
 
 

 
   Boolean masterPolicyBoolean=AccObj.Master_Policy__c;
  String masterPolicy;
  RecordType recordTypeValue= AccObj.RecordType;
  String recordType=String.valueof(recordTypeValue);

  if(Value == 'Contact'){
      soql ='SELECT Id,FirstName,LastName,Contact.Account.IsPersonAccount,Position__c,Contact.Account.Other_Address_Street_1__pc,Contact.Account.Phone,Contact_Master_Policy_Mailing__c,Contact.Account.Type,Contact.Account.PY_Total_Ins_Volume__c,Contact_Type__c ,Phone,Email,Title, Contact.Account.Parent_Name__c,Contact.Account.Segment__c,Contact.Account.Branch_Org__c,Contact.Account.Name FROM Contact WHERE  Contact.Account.Name!=null';
      soql += ' and Contact.Account.RecordTypeId =\''+String.escapeSingleQuotes(recordtypeAccount_sales)+'\'';
      soql += ' and Contact.RecordTypeId = \''+String.escapeSingleQuotes(recordtypeContact_sales)+'\'';
 
            if(AccountOwnerValue!=null && !AccountOwnerValue.equals('') && AccountOwnerValue.equals('My'))
                {soql += ' and Account.ownerId = \''+String.escapeSingleQuotes(userid)+'\'';
                system.debug('AccountOwnerValue soql -----------------------------'+AccountOwnerValue);
                system.debug('soql AccountOwnerValue -----------------------------'+soql );}


                }  
        }

                
   
  runQuery(); 
  return null;

}

public void runQuery() {


      soql+=  'Order By Contact.Account.Name';
          ContactObjects =Database.query(soql + ' limit 30');
          getContacts();
     

}

////////////////////////////Code Of Wrapper Class Starts here///////////

public List<cContact> getContacts() {
        system.debug('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
        //if(contactList == null) {
            contactList = new List<cContact>();
            for(Contact c:ContactObjects ) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                contactList.add(new cContact(c));
            }
            
        // }
        return contactList;
    }
// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cContact(Contact c) {
        con = c;
        selected = false;
      }
}

public PageReference processSelected() {
    //We create a new list of Contacts that we be populated only with Contacts if they are selected
      List<Contact> selectedContacts = new List<Contact>();
      Set<Account> selectedAccounts = new Set<Account>();
      List<Account> selectedAccountList = new List<Account>();
      //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
      //for(cContact cCon: gatContacts()) {
      for(cContact cCon: contactList) {
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
                selectedAccounts.add(cCon.con.Account);
            }
        }
      // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
      for(Account acs: selectedAccounts){
          selectedAccountList.add(acs);
       }
       update selectedAccountList;
       update selectedContacts;
       contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
       return null;
   }




     

}