• Paul_Boiko
  • NEWBIE
  • 379 Points
  • Member since 2011

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 44
    Replies
Hi experts,

I am a newBie .I have a requirement where i have to select a range of date in visualforce page.Based on that range i have to fetch the details.I have used which is working fine.But this is not displaying a datepicker when i run in IE browser.It only works in chrome.

What coding approach i have to follow.Please help me in solving this.


Below is the visualforce page and apex code which i have written.

Visualforce page
 
<apex:page Controller="GVWS_GenerateReport" docType="html-5.0">

<apex:sectionHeader title="Reports" subtitle="Generate Report" id="sectionHeaderId"/>

 <apex:form id="ReportRegion">
    <apex:outputPanel id="msgPanel">
        <apex:pageMessages ></apex:pageMessages>
    </apex:outputPanel>
    <apex:pageblock id="pb">
    
        <apex:pageBlockSection id="SearchPanel" showHeader="true" columns="2">
           <!-- <apex:outputLabel value="Region"/>-->
            <apex:inputtext label="Region" id="rname" value="{!region}"/>
           <!-- <apex:outputLabel value="Country"/>
           <apex:outputLabel value="Close Date:"> -->
              <apex:outputLabel style="color:#666666;font-weight:bold;font-size:11px">CloseDate:
             <!-- <p font-color="Grey"><b>Close Date:</b></p>-->
              <br/>
              From &nbsp;&nbsp;<apex:input label="From" id="cdfrom" value="{!fromDate}" type="date"/>
              &nbsp;&nbsp; To &nbsp;&nbsp;<apex:input label="To" id="cdto" value="{!toDate}" type="date"/>
              </apex:outputLabel> 
              
            <apex:inputtext label="Country" id="cname" value="{!country}" />
          <!-- <apex:outputLabel value="Close Date:"/>
           <br/>
               <apex:outputLabel value="From"/>
               <apex:input id="cdfrom" value="{!fromDate}" type="date"/>
               <apex:outputLabel value="To"/>
               <apex:input id="cdto" value="{!toDate}" type="date"/>
           -->
              
        </apex:pageBlockSection>      
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!displayReport}"  value="Generate Report" ID="ENTER_BUTTON"/>
            <apex:actionStatus id="findOpportunityStatus">
                <apex:facet name="start">
                    <img src="{!$Resource.spin}" border="0" width = "20" height = "20"/>
                </apex:facet>
                <apex:facet name="stop">&nbsp;</apex:facet> 
            </apex:actionStatus>
        </apex:pageBlockButtons>
    </apex:pageblock>
    
    <apex:pageBlock id="pbb">
    
    <apex:actionStatus id="myStatusOpportunity">
            <apex:facet name="start">
                <img src="{!$Resource.spin}" border="0" width = "10" height = "10"/><b>...</b>
            </apex:facet>
            <apex:facet name="stop">&nbsp;</apex:facet> 
        </apex:actionStatus>

    
    <apex:pageBlockButtons location="top" id="pbbbuttons">
            <apex:commandButton rerender="pbb" action="{!firstPageOpportunity}"  value="|< First"  disabled="{!hasPreviousOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!previousPageOpportunity}" value="<< Previous" disabled="{!hasPreviousOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!nextPageOpportunity}" value="Next >>" disabled="{!hasNextOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!lastPageOpportunity}" value="Last >|" disabled="{!hasNextOpportunity}" status="myStatusOpportunity"></apex:commandButton>
        </apex:pageBlockButtons>


    <apex:pageBlockTable value="{!opportunityRecords}" var="opp">  >  
        <apex:column headerValue="Opportunity Name">{!opp.name}
        </apex:column> 
        <apex:column headerValue="Opportunity Owner">{!opp.owner.name}</apex:column>
        <apex:column headerValue="Region">{!opp.GEBRegion__c}</apex:column>
        <apex:column headerValue="Country">{!opp.Country__c}</apex:column>
        <apex:column headerValue="Broker/Partner">{!opp.Broker__c}</apex:column>
        <apex:column headerValue="Estimated Premium(Converted)">{!opp.Total_Actual_Sale_Amount__c}</apex:column>
        <apex:column headerValue="Close date">{!opp.CloseDate}</apex:column>
        <apex:column headerValue="Stage">{!opp.StageName}</apex:column>
        <apex:column headerValue="Created stage">{!opp.Creation_Stage_Name__c}</apex:column>
    </apex:pageBlockTable>

    </apex:pageblock>

 </apex:form> 
</apex:page>

Apex class
 
public class GVWS_GenerateReport
{
  public String region{get;set;}
  public String country{get;set;}
  public String closeDate{get;set;}
  public String hasPrevious {get;set;}
  //public Date from{get;set;}
  public Date fromDate{get;set;}
  public Date toDate{get;set;}
  public List<Opportunity> opportunityRecords{get;set;}
  
   ApexPages.StandardSetController regionStandardSetController{get;set;}
  
  public GVWS_GenerateReport()
  {
    opportunityRecords = new list<Opportunity>();
    regionStandardSetController=new ApexPages.StandardSetController(new list<Opportunity>());
  
  }
  
    //List<Opportunity> reportQuery=new List<Opportunity>();
   //reportQuery='SELECT Id,Name,Owner,Broker__c,GVWS_Region__c,GVWS_Country__c ,CloseDate,StageName FROM Opportunity';
   String reportQuery1 ='SELECT Id,Name,Owner.Name,Broker__c,Country__c,GEBRegion__c,CloseDate,StageName,Creation_Stage_Name__c,Total_Actual_Sale_Amount__c FROM Opportunity WHERE StageName NOT IN (';
   String reportQuery2 = 'Ommitted';
   String reportQuery3 = 'Inforce';
   String reportQuery4 = 'Lost';
   String reportQuery5 = 'Declined';
   String reportQuery6 = ')';
   String reportQuery = reportQuery1+':'+'reportQuery2'+','+':'+'reportQuery3'+','+':'+'reportQuery4'+','+':'+'reportQuery5'+reportQuery6;
  
   
     
    
   public void displayReport()
 {
        String checkQuery = reportQuery;
        String checkInput = reportQuery;
        if(region!= null && !region.equalsIgnoreCase(''))
        {
          
            checkQuery = checkQuery + 'and GEBRegion__c like :region';
            system.debug('***********1'+checkQuery);
        }
        
        if(country!= null && !country.equalsIgnoreCase(''))
        {
         
            checkQuery = checkQuery + ' '+'and Country__c like :country';
            system.debug('***********2'+checkQuery);
        }
        
        if((fromDate!= null)&&(toDate!=null))
        {
          checkQuery=checkQuery+' '+'and (closeDate>=:fromDate AND closeDate<= :toDate)';
          system.debug('************3'+checkQuery);
        }
        
        if(((fromDate!=null)&&(toDate==null))||((fromDate==null)&&(toDate!=null)))
        {
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Please Enter value in both From and To search criteria'));
            opportunityRecords = new list<Opportunity>();
            return;
        }
        if(checkQuery.equals(checkInput)){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Please Enter value in at least one search criteria'));
            opportunityRecords = new list<Opportunity>();
            return;
        }
     
      
      //   system.debug('***********1'+checkQuery);
       
        
       
       regionStandardSetController=new ApexPages.StandardSetController(Database.getQueryLocator(checkQuery));
       
        opportunityRecords= regionStandardSetController.getRecords();
        
}
  
    public PageReference firstPageOpportunity() {
        regionStandardSetController.first();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity = !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows last set of records in account search result.
    */
    public PageReference lastPageOpportunity() {
        regionStandardSetController.last();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows next set of records in account search result.
    */
    public PageReference nextPageOpportunity() {
        regionStandardSetController.next();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows previous set of records in account search result.
    */
   public PageReference previousPageOpportunity() {
        regionStandardSetController.previous();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
   public Boolean hasNextOpportunity{
        get {
            if(regionStandardSetController==null&&regionStandardSetController.getHasNext()==true)
                return true;
            return !regionStandardSetController.getHasNext();
        }
        set;
    }
    
    
    public Boolean hasPreviousOpportunity{
        get {
            if(regionStandardSetController==null)
               return true;
            return !regionStandardSetController.getHasPrevious();
        }
        set;
    }  
 
  }

Thanks & regards,
Lahari


 
Friends- I am not sure how to write a test class for below menthod. Can you help ?
@RemoteAction public static RemoteSaveResult saveSignature(Id ehsId, String signatureBody) {
    Attachment a = new Attachment(ParentId=ehsId, name='Signature.png', ContentType='image/png', Body=EncodingUtil.base64Decode(signatureBody));
    Database.saveResult result = Database.insert(a,false);
    RemoteSaveResult newResult = new RemoteSaveResult();
    newResult.success = result.isSuccess();
    newResult.attachmentId = a.Id;
    newResult.errorMessage = result.isSuccess()?'':result.getErrors()[0].getMessage();
    
    return newResult;
}

public class RemoteSaveResult {
    public Boolean success;
    public Id attachmentId;
    public String errorMessage;
}

 
Click the + Add Action button.

For Action Type, select Post to Chatter.

Enter Post to Chatter as the Action Name.

For Post to, select This Record.

"This Record" value is not availalbe in pick list. 
 
If I am using below Query
SELECT CaseNumber from Case where  ClosedDate > LAST_N_DAYS:31

To get all case numbers  which have been closed within last 30 days , It is not giving any result , even though Some cases exist in Database closed within the 30 days.

I could not understand , why I am not getting correct result.
Thanks
Yogendra Rishishwar
 
I have a trigger that updates the contact owner to whoever the account owner is when the account owner is changed.  I also need the trigger to allow for account teams and dataloading the account owner changes.  Trigger works on a 1 for 1 basis but still has 0% coverage and test class fails.  Any help is really greatly appreciated.

Trigger:
trigger reassignContactOwnerToAccountOwner on Contact ( after insert ) {

    List<Id> accountIds = new List<Id>();
    Map<Id, Id> accountOwnerIdMap = new Map<Id, Id>();

    // all the accounts whose owner ids to look up
    for ( Contact c : Trigger.new ) {
        accountIds.add( c.accountId );
    }
    
    // look up each account owner id
    for ( Account acct : [ SELECT id, ownerId FROM account WHERE id IN :accountIds ] ) {
        accountOwnerIdMap.put( acct.id, acct.ownerId );
    }
    
    // change contact owner to its account owner
    for ( Contact c : Trigger.new ) {
        c.ownerId = accountOwnerIdMap.get( c.accountId );
    }
   
}

Test Class:
@IsTest
private class AccountContactOwner {
    static TestMethod void testTrigger()
    { 
        test.StartTest();
        
        //Step 1 : Data Insertion
        Account a=new Account(Name='Test Account');
           insert a;
           Contact c = new Contact(Account=a, FirstName='John',LastName='Doe');
        update c;
        
        
        test.startTest();
        
        
        //Perform the dml action on which trigger gets fired , like insert, update ,delete , undelete, in your case you have to update account record that you created in above  
        //create test user
            Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
      User u1 = new User(Alias = 'standa', Email='saplingstandarduser@testorg.com',
      EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
      LocaleSidKey='en_US', ProfileId = p.Id,
      TimeZoneSidKey='America/Los_Angeles', UserName='saplingstandarduser@testorg.com');


      System.runAs(u1) {
      // The following code runs as user 'u'  
       // create test contact
        Contact c1 = new Contact(FirstName='Jane',LastName='Doe', Account=a);
        insert c1;
        
        //assert your results using system.assert and system.asserEquals

//reload objects to make sure values are loaded
   a= [select id, ownerId from Account where id=:a.id];
                
        
        
        test.stopTest();
    }
}
}
Hi there,

I am trying to run a Task trigger on a Lead as follows.  
If Task Subject is A, then update the Lead Status upon Closure of Task.
If Task Subject is B, then check value of Description field on Lead.  
     If null, return an error.  
     If not null, then update the Status of the Lead upon closure of the Task.

Code is below, however it doesnt seem to be working.  Would appreciate any advice.  

Many thanks

trigger LeadTrigger on Task (before insert, before update) 
{
    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new)
    {
        if(t.Status=='Completed')
        {
            if(t.whoId != null && String.valueOf(t.whoId).startsWith('00Q')==TRUE) //check if the task is associated with a lead
            {
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
        
    map<id,Lead> LeadtaskMap = new map<id,Lead>([SELECT Id, Description, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE]);
    
    for(Task tsk:trigger.new)
    {
    
      if(LeadtaskMap.keyset().contains(tsk.whatid))
      {
            if(tsk.Status == 'Completed' && tsk.Subject == 'Make contact with Lead')
            {
                LeadtaskMap.get(tsk.whatid).Status = 'Contacted';
            }
            
            if(LeadtaskMap.get(tsk.whatid).Description == null && tsk.Status == 'Completed' && tsk.Subject == 'Qualify Opportuntity')
            {
                tsk.adderror('Task cannot be completed until the following fields have been populated: Description');
            }
            Else 
            {
                LeadtaskMap.get(tsk.whatid).Status = 'Qualified';
            }
      }
        
    } 
    
Hello,

i need help with best practices from experienced salesforce developers.

For Update our Object we have Process Builder, Worfklow Rules and Triggers.

But we also know that if Process Builder or WFR have to change Object, then all triggers will be executed one more time.

So my example is:
I have Case Object
It already have 10-15 update triggers (before + after) (actually it's only 1 trigger but with a lot of other methods to run)
So i can see in debug log, that full work of this triggers, for example take 30 of 100 SOQL Querrys

Now i need to Stop Entitlement process for "Pending" Cases. (or another simple task, what can be accomplished with WFR/PB)
Ok. i have 2 ways:
1. Add WFR/PB with start/stop case for case status is changed = true && status = pending, etc.
2. Add more logic in Before Trigger.

And if i will use first way, then my triggers will be exucuted twice.
So, instead of 30 of 100 SOQL querries it will be 60 of 100... And for me it looks awful.

Main question: Am I right that if we already have complex structure with triggers, then using WFR/PB is undesirable (if they are update same object)?

Sorry for my english.
I've been trying to do a bulk update of records using the data loader and I keep getting the following error:
"rfp: execution of BeforeInsert
caused by: System.QueryException: List has more than 1 row for assignment to SObject
Class.setRfpOwner.setOwners: line 15, column 1
Trigger.rfp: line 4, column 1 "

After looking at my code and the records I'm querying, I the query in line 15 of my service class should only yield one result, which leads me to believe that my service class is somehow not bulk safe. Can anyone point me in the right direction:

Trigger:
trigger rfp on RFP_Response__c (before insert, before update) {

    if(trigger.isBefore && trigger.isInsert){
        setRfpOwner.setOwners(trigger.new);
        rfpKwBuilder.buildKeyWords(Trigger.new);
    }
    if(trigger.isBefore && trigger.isUpdate){
        if(checkRecursive.flag == true){
            rfpKwBuilder.buildKeyWords(Trigger.new);
            for(RFP_Response__c rfp : Trigger.new){
                RFP_Response__c oldRfp = Trigger.oldMap.get(rfp.Id);
                if(oldRfp.Response__c != rfp.Response__c){
                    setResponseToggle.toggleResponse(trigger.new);      
                }                              
            }
            for(RFP_Response__c rfp : Trigger.new){
                RFP_Response__c oldRfp = Trigger.oldMap.get(rfp.Id);
                if(oldRfp.Category__c != rfp.Category__c){
                    setRfpOwner.setOwners(trigger.new);
                }                              
            }            
            
        } 
        checkRecursive.flag = false;
    }    
    
}

Class:
public class setRfpOwner {

    public static void setOwners(list<RFP_Response__c> rfpUpdateList){
        List<String> listCategories = new List<String>();

        for (RFP_Response__c rfp : rfpUpdateList) {
            if(rfp.Category__c == null){
                return;
            }
            if(rfp.Category__c != null){
                listCategories.add(rfp.Category__c);              
            }
        }
            RFP_Owner_Mappings__c mapping = [SELECT Name, RFP_Category_Owner__c, RFP_Category_Backup_Owner__c,RFP_Category_Owner__r.Email__c,RFP_Category_Backup_Owner__r.Email__c 
                                            FROM RFP_Owner_Mappings__c  
                                            WHERE Name IN :listCategories];
            for (RFP_Response__c rfp2 : rfpUpdateList){
                if(rfp2.Category__c == mapping.Name ){
                    rfp2.RFP_Category_Owner__c = mapping.RFP_Category_Owner__c;
                    rfp2.RFP_Category_Backup_Owner__c  = mapping.RFP_Category_Backup_Owner__c ;
                    rfp2.Category_Owner_Email__c = mapping.RFP_Category_Owner__r.Email__c;
                    rfp2.Category_Backup_Owner_Email__c  = mapping.RFP_Category_Backup_Owner__r.Email__c ;                    
                }          
            }
        
    }
    
}



 
I am in the process of completing the Create a Guest Administrator and deactivate it challenge however within my developer org I have no option on profile other than 'Standar Platform User'. 

How do I assign a System Administrator Profile?

Thanks, 
Preena
Hi experts,

I am a newBie .I have a requirement where i have to select a range of date in visualforce page.Based on that range i have to fetch the details.I have used which is working fine.But this is not displaying a datepicker when i run in IE browser.It only works in chrome.

What coding approach i have to follow.Please help me in solving this.


Below is the visualforce page and apex code which i have written.

Visualforce page
 
<apex:page Controller="GVWS_GenerateReport" docType="html-5.0">

<apex:sectionHeader title="Reports" subtitle="Generate Report" id="sectionHeaderId"/>

 <apex:form id="ReportRegion">
    <apex:outputPanel id="msgPanel">
        <apex:pageMessages ></apex:pageMessages>
    </apex:outputPanel>
    <apex:pageblock id="pb">
    
        <apex:pageBlockSection id="SearchPanel" showHeader="true" columns="2">
           <!-- <apex:outputLabel value="Region"/>-->
            <apex:inputtext label="Region" id="rname" value="{!region}"/>
           <!-- <apex:outputLabel value="Country"/>
           <apex:outputLabel value="Close Date:"> -->
              <apex:outputLabel style="color:#666666;font-weight:bold;font-size:11px">CloseDate:
             <!-- <p font-color="Grey"><b>Close Date:</b></p>-->
              <br/>
              From &nbsp;&nbsp;<apex:input label="From" id="cdfrom" value="{!fromDate}" type="date"/>
              &nbsp;&nbsp; To &nbsp;&nbsp;<apex:input label="To" id="cdto" value="{!toDate}" type="date"/>
              </apex:outputLabel> 
              
            <apex:inputtext label="Country" id="cname" value="{!country}" />
          <!-- <apex:outputLabel value="Close Date:"/>
           <br/>
               <apex:outputLabel value="From"/>
               <apex:input id="cdfrom" value="{!fromDate}" type="date"/>
               <apex:outputLabel value="To"/>
               <apex:input id="cdto" value="{!toDate}" type="date"/>
           -->
              
        </apex:pageBlockSection>      
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!displayReport}"  value="Generate Report" ID="ENTER_BUTTON"/>
            <apex:actionStatus id="findOpportunityStatus">
                <apex:facet name="start">
                    <img src="{!$Resource.spin}" border="0" width = "20" height = "20"/>
                </apex:facet>
                <apex:facet name="stop">&nbsp;</apex:facet> 
            </apex:actionStatus>
        </apex:pageBlockButtons>
    </apex:pageblock>
    
    <apex:pageBlock id="pbb">
    
    <apex:actionStatus id="myStatusOpportunity">
            <apex:facet name="start">
                <img src="{!$Resource.spin}" border="0" width = "10" height = "10"/><b>...</b>
            </apex:facet>
            <apex:facet name="stop">&nbsp;</apex:facet> 
        </apex:actionStatus>

    
    <apex:pageBlockButtons location="top" id="pbbbuttons">
            <apex:commandButton rerender="pbb" action="{!firstPageOpportunity}"  value="|< First"  disabled="{!hasPreviousOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!previousPageOpportunity}" value="<< Previous" disabled="{!hasPreviousOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!nextPageOpportunity}" value="Next >>" disabled="{!hasNextOpportunity}" status="myStatusOpportunity"></apex:commandButton>
            <apex:commandButton rerender="pbb" action="{!lastPageOpportunity}" value="Last >|" disabled="{!hasNextOpportunity}" status="myStatusOpportunity"></apex:commandButton>
        </apex:pageBlockButtons>


    <apex:pageBlockTable value="{!opportunityRecords}" var="opp">  >  
        <apex:column headerValue="Opportunity Name">{!opp.name}
        </apex:column> 
        <apex:column headerValue="Opportunity Owner">{!opp.owner.name}</apex:column>
        <apex:column headerValue="Region">{!opp.GEBRegion__c}</apex:column>
        <apex:column headerValue="Country">{!opp.Country__c}</apex:column>
        <apex:column headerValue="Broker/Partner">{!opp.Broker__c}</apex:column>
        <apex:column headerValue="Estimated Premium(Converted)">{!opp.Total_Actual_Sale_Amount__c}</apex:column>
        <apex:column headerValue="Close date">{!opp.CloseDate}</apex:column>
        <apex:column headerValue="Stage">{!opp.StageName}</apex:column>
        <apex:column headerValue="Created stage">{!opp.Creation_Stage_Name__c}</apex:column>
    </apex:pageBlockTable>

    </apex:pageblock>

 </apex:form> 
</apex:page>

Apex class
 
public class GVWS_GenerateReport
{
  public String region{get;set;}
  public String country{get;set;}
  public String closeDate{get;set;}
  public String hasPrevious {get;set;}
  //public Date from{get;set;}
  public Date fromDate{get;set;}
  public Date toDate{get;set;}
  public List<Opportunity> opportunityRecords{get;set;}
  
   ApexPages.StandardSetController regionStandardSetController{get;set;}
  
  public GVWS_GenerateReport()
  {
    opportunityRecords = new list<Opportunity>();
    regionStandardSetController=new ApexPages.StandardSetController(new list<Opportunity>());
  
  }
  
    //List<Opportunity> reportQuery=new List<Opportunity>();
   //reportQuery='SELECT Id,Name,Owner,Broker__c,GVWS_Region__c,GVWS_Country__c ,CloseDate,StageName FROM Opportunity';
   String reportQuery1 ='SELECT Id,Name,Owner.Name,Broker__c,Country__c,GEBRegion__c,CloseDate,StageName,Creation_Stage_Name__c,Total_Actual_Sale_Amount__c FROM Opportunity WHERE StageName NOT IN (';
   String reportQuery2 = 'Ommitted';
   String reportQuery3 = 'Inforce';
   String reportQuery4 = 'Lost';
   String reportQuery5 = 'Declined';
   String reportQuery6 = ')';
   String reportQuery = reportQuery1+':'+'reportQuery2'+','+':'+'reportQuery3'+','+':'+'reportQuery4'+','+':'+'reportQuery5'+reportQuery6;
  
   
     
    
   public void displayReport()
 {
        String checkQuery = reportQuery;
        String checkInput = reportQuery;
        if(region!= null && !region.equalsIgnoreCase(''))
        {
          
            checkQuery = checkQuery + 'and GEBRegion__c like :region';
            system.debug('***********1'+checkQuery);
        }
        
        if(country!= null && !country.equalsIgnoreCase(''))
        {
         
            checkQuery = checkQuery + ' '+'and Country__c like :country';
            system.debug('***********2'+checkQuery);
        }
        
        if((fromDate!= null)&&(toDate!=null))
        {
          checkQuery=checkQuery+' '+'and (closeDate>=:fromDate AND closeDate<= :toDate)';
          system.debug('************3'+checkQuery);
        }
        
        if(((fromDate!=null)&&(toDate==null))||((fromDate==null)&&(toDate!=null)))
        {
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Please Enter value in both From and To search criteria'));
            opportunityRecords = new list<Opportunity>();
            return;
        }
        if(checkQuery.equals(checkInput)){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Please Enter value in at least one search criteria'));
            opportunityRecords = new list<Opportunity>();
            return;
        }
     
      
      //   system.debug('***********1'+checkQuery);
       
        
       
       regionStandardSetController=new ApexPages.StandardSetController(Database.getQueryLocator(checkQuery));
       
        opportunityRecords= regionStandardSetController.getRecords();
        
}
  
    public PageReference firstPageOpportunity() {
        regionStandardSetController.first();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity = !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows last set of records in account search result.
    */
    public PageReference lastPageOpportunity() {
        regionStandardSetController.last();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows next set of records in account search result.
    */
    public PageReference nextPageOpportunity() {
        regionStandardSetController.next();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
    /*
        Shows previous set of records in account search result.
    */
   public PageReference previousPageOpportunity() {
        regionStandardSetController.previous();
        opportunityRecords = regionStandardSetController.getRecords();
        hasPreviousOpportunity= !regionStandardSetController.getHasPrevious();
        hasNextOpportunity= !regionStandardSetController.getHasNext();
        
        return null;
    }
    
   public Boolean hasNextOpportunity{
        get {
            if(regionStandardSetController==null&&regionStandardSetController.getHasNext()==true)
                return true;
            return !regionStandardSetController.getHasNext();
        }
        set;
    }
    
    
    public Boolean hasPreviousOpportunity{
        get {
            if(regionStandardSetController==null)
               return true;
            return !regionStandardSetController.getHasPrevious();
        }
        set;
    }  
 
  }

Thanks & regards,
Lahari


 

From Account, I click on New button in the Opportunity related list to create a new Opportunity.  The Create popup is prepopulated with the Account Name, but I also need to prepopulate some fields in Opportunity (standard and custom) from some fields in the Account (which may also be standard or custom field).  

I read that the URL hack in Salesforce Classic that helps in prepopulating does not work in Lightning. How do you prefill fields in Lightning then? Has anyone accomplished this?  I'd appreciate it if you'd illustrate how.  Thanks very much.

Friends- I am not sure how to write a test class for below menthod. Can you help ?
@RemoteAction public static RemoteSaveResult saveSignature(Id ehsId, String signatureBody) {
    Attachment a = new Attachment(ParentId=ehsId, name='Signature.png', ContentType='image/png', Body=EncodingUtil.base64Decode(signatureBody));
    Database.saveResult result = Database.insert(a,false);
    RemoteSaveResult newResult = new RemoteSaveResult();
    newResult.success = result.isSuccess();
    newResult.attachmentId = a.Id;
    newResult.errorMessage = result.isSuccess()?'':result.getErrors()[0].getMessage();
    
    return newResult;
}

public class RemoteSaveResult {
    public Boolean success;
    public Id attachmentId;
    public String errorMessage;
}

 
Click the + Add Action button.

For Action Type, select Post to Chatter.

Enter Post to Chatter as the Action Name.

For Post to, select This Record.

"This Record" value is not availalbe in pick list. 
 
How to get current Date time in Salesforce Object Query Language .
Suppose I want to get all cases which have been closed in last 30 days then what should be query .

Select CaseNumber from Case where ClosedDate >= CURRENT_DATE - 30 Days ;
 
What date function will return cirrent date in SOQL?

Thanks
Yogendra Rishishwar
 
If I am using below Query
SELECT CaseNumber from Case where  ClosedDate > LAST_N_DAYS:31

To get all case numbers  which have been closed within last 30 days , It is not giving any result , even though Some cases exist in Database closed within the 30 days.

I could not understand , why I am not getting correct result.
Thanks
Yogendra Rishishwar
 
Challenge Not yet complete... here's what's wrong:
The 'Day_of_the_Week__c' is not reporting the correct day of the week (Monday, Tuesday, etc.)

I created the field on the Contact object  per the requirements and created the formula to return a text field with the day of the for "today". I tested my formula and it works but it does not pass the check challenge. The formula I am using is:
CASE(MOD(Today()- DATE(1900,1,7), 7), 0, 'Sunday', 1, 'Monday',2,'Tuesday',3,'Wednesday',4,'Thursday',5,'Friday',6,'Friday','error')


 
What am I missing here?

trigger updateLastCallDate on Task (after insert, after update, after delete) {

    Set<Id> con_set = new Set<Id>();
    
    List<Contact> con_list = new List<Contact>();
    
    for(Task T: Trigger.new()){
        if(String.valueof(T.WhatId).startsWith('001') && T.Status=='Completed' && T.Subject=='Call' ){
            con_set.add(T.WhatId);
        }
        
     }
     
     for(AggregateResult aggregateResult:[SELECT max(createdDate)MaxCDate,WhatId FROM Task WHERE WhatID IN: con_set AND Status ='Completed' AND Subject ='Call' Group By WhatId]){
         con_list.add(new Contact(Id=(id)aggregateResult.get('WhatId'),Last_Call__c=date.valueof(aggregateResult.get('MaxCDate'))));
         
     }
     
     try{
     
         if(con_list !=null && con_list.size()>0){
             update con_list;
         }
     
     }Catch(Exception e){
         system.debug('Exception ***'+e.getMessage());
      
      }

}
I'm so close to building my first Visualforce Email Template. I've resolved a bunch of errors and am now stuck with a syntax error of an extra right brace. However, I can't find it anywhere in my code. Can you help me sleuth?

Thanks!

<pre>
<messaging:emailTemplate recipientType="Contact"
    relatedToType="Opportunity"
    subject="Thank you for your donation to Nourish!"
    replyTo="gratitude@wildernesstorah.org" >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
<p style="text-align: center;">
    <img alt="User-added image" height="193" src="https://c.na14.content.force.com/servlet/rtaImage?eid=a0pd0000006DBex&feoid=00Nd0000007bCrt&refid=0EMd00000001WEE" width="500" /></p>
<table align="center" cellpadding="0" cellspacing="0" class="bodytbl" style="font-family: Helvetica,Arial,sans-serif; font-size: 12px; color: #787878;" width="80%">
    <tbody>
        <tr style="font-size: 12px; font-family: arial,helvetica,sans-serif;">
            <td colspan="1" rowspan="1" style="" valign="top" width="25%">
                <p>
                    <a href="http://www.slingshotfund.org/directory/wilderness-torah/" target="_blank"><img align="left" alt="" border="0" src="https://c.na14.content.force.com/servlet/servlet.ImageServer?id=015d0000005vUvm&oid=00Dd0000000borB" /></a><br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    &nbsp;</p>
                <p>
                    <span style="font-size: 14px;"><strong><em>“One of the nation’s<br />
                    most innovative<br />
                    Jewish nonprofits.”</em></strong></span><br />
                    <strong style="font-size: smaller;"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~ Slingshot Fund, 2011–2015</em></strong><br />
                    &nbsp;</p>
                <p>
                    <strong>Wilderness Torah</strong><br />
                    2095 Rose Street<br />
                    Suite 202<br />
                    Berkeley, CA 94709<br />
                    <a href="http://wildernesstorah.org/" target="_blank">wildernesstorah.org</a><br />
                    &nbsp;</p>
                <p>
                    <strong><em>Board of Directors</em></strong><br />
                    Adam Weisberg,<br />
                    &nbsp;&nbsp;<em>President</em><br />
                    Terry Cumes,<br />
                    &nbsp;&nbsp;<em>Treasurer</em><br />
                    Susie Aaron<br />
                    Leah Katz Ahmadi<br />
                    Jim Gilbert<br />
                    Sam Goldman<br />
                    Shira Weissman<br />
                    Brian Williams<br />
                    Julie Wolk<br />
                    &nbsp;</p>
                <p>
                    <strong><em>Staff</em></strong><br />
                    Zelig Golden,<br />
                    &nbsp;&nbsp;<em>Founding Director</em><br />
                    Nancy Shaw,<br />
                    &nbsp;&nbsp;<em>Managing Director</em><br />
                    Aya Baron<br />
                    Flora Goldman<br />
                    Sam Pashall<br />
                    Suzannah Sosman<br />
                    &nbsp;</p>
                <p>
                    <strong><em>Wilderness Torah</em></strong><br />
                    a 501(c)(3) organization<br />
                    Federal Tax ID<br />
                    45-4437061</p>
            </td>
                        <td colspan="1" rowspan="1" style="padding-left: 5%;" valign="top" width="95%">
                <div class="h" style="font-size: 12px; font-family: arial,helvetica,sans-serif;">
                    <p style="text-align: right;">
                    {!relatedTo.<DateToday__c>}</p>
        
                    <p>
Dear {!relatedTo.PrimaryContact__r.FirstName},</p>
            <p>
Thank you so much for donating the item(s) below to Wilderness Torah’s online silent auction this year! We so appreciate your support of Wilderness Torah with your fabulous gift. This letter serves as your tax acknowledgement letter.</p>
                    <p>
We’re thrilled to have raised $6,700 from over 50 wonderful items. This year, your item was promoted via:</p>
                    <ul>
                        <li>
Facebook ads, seen by more than 20,000 people</li>
<li>Many posts on our Facebook page, which has more than 3,000 fans</li>
<li>The auction website, which was viewed by nearly 3,500 people and received almost 200 bids</li>
<li>Our e-newsletter, sent to over 2,500 subscribers</li>
                    </ul>
                    <p>
Your donation supports thousands of people to unplug and reconnect to nourishing, earth-based Jewish traditions and education. Thank you!</p>
                    <p>
With great appreciation,</p>
                    <table style="">
                        <tbody>
                            <tr>
                                <td colspan="1" rowspan="1">
<img align="left" alt="" border="0" src="https://c.na14.content.force.com/servlet/servlet.ImageServer?id=015d0000005vUxZ&oid=00Dd0000000borB" style="" /><br />
                                    Nancy Shaw<br />
                                    Managing Director</td>
                                <td colspan="1" rowspan="1">
<img align="none" alt="" border="0" src="https://c.na14.content.force.com/servlet/servlet.ImageServer?id=015d0000005vwF0&oid=00Dd0000000borB" /><br />
                                    Zelig Golden<br />
                                    Founding Director</td>
                            </tr>
                        </tbody>
                    </table>
                                <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td>{!opp.PriceBookEntry.name}</td>
           <td>{!ROUND(opp.TotalPrice,0)}</td>
       </tr>
    </apex:repeat>                 

                    <p style="font-size: 10px;">
                        We acknowledge that no goods or services were received in connection to this donation. Wilderness Torah is a registered 501(c)(3) organization. Contributions to Wilderness Torah are tax-deductible. Please keep this letter as a record of your donation for your tax purposes.</p>
                    <p style="text-align: center;">
-------------------------For your tax records-------------------------</p>
                    <dl>
                        <dt>
<strong>Donor Name</strong>:&nbsp;{!relatedTo.Account__r.Name}</dt>
                        <dt>
<strong>Donation Amount</strong>: ${!relatedTo.Amount}</dt>
                        <dt>
                           <strong>Transaction Date</strong>: {!relatedTo.<CloseDateSpelledOut__c>}</dt>
                    </dl>
                </div>
            </td>
        </tr>
    </tbody>
</table>
       
        </body>
    </html>
</messaging:htmlEmailBody> 
            
</messaging:emailTemplate>
</pre>
Hi

I have a visualforce page with a apex controller connected. There is no connection / lookup to the user object.

On that page I need a <apex:inputField that has a standard lookup to the user object.

Right now my include field is not shown because I don't have it connected to a user object. 

Can someone tell me how to do this ?

Maybe it needs to be solved by creating a dummy field that has that lookup but I fail it getting it to work.

If somebody could help what is needed in the vfp and in the apex controller that would be great.

I tried to create a brand new vfp and apex controller to get a better understanding of the problem :

Vfp :

<apex:page controller="JpkTestController">
    <apex:form id="form">
    <apex:pageBlock title="View as" id="viewAs">
        <apex:pageBlockSection >    
               <apex:inputField id="TestUser" value="{!user1.Id}" required="false"/>       
         </apex:pageBlockSection>
    </apex:pageBlock>   
    </apex:form>
</apex:page>

Apx controller :

public class JpkTestController {

  public User user1 {get;set;}  

  public JpkTestController() {
        user1= new User(); 
  }
}
 
Hello,

I get the following error when trying to complete a challenge - on TRAILHEAD.

*****
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, User: id value of incorrect type: 00561000000lBQ4AAM: [User__c]
*****
Any assistance would be appreciated.

Thank you
Once i get the Task associated with my Lead record, i want to perform the following operations:

If Task is "A" and Status = Completed
   Update Lead Status to 'Contacted.'

If Task is "B" and Status = Completed and Lead Description field is Null
    Throw an error - 'Task cannot be completed while description is Null.
Else
    Update Lead Status to 'Qualified'.

The issue i've encountered is that when i complete Task "A", the Lead Status directly updates to 'Qualified'.  When i complete Task "B" and Lead Description is Null, nothing happens.  I dont receive an error message.  My code is below. 

Any suggestions are very welcome.

Thank you.



trigger LeadTrigger on Task (before insert, before update) {
    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new) {
        if(t.Status=='Completed') {
            if(t.whoId != null && String.valueOf(t.whoId).startsWith('00Q')==TRUE) //check if the task is associated with a lead {
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
        
    map<id,Lead> LeadtaskMap = new map<id,Lead>([SELECT Id, Description, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE]);
      
    for(Task tsk:trigger.new){
      if(LeadtaskMap.keyset().contains(tsk.whoid)) {
            if(tsk.Status == 'Completed' && tsk.Subject == 'Make contact with Lead') {
                LeadtaskMap.get(tsk.whoid).Status = 'Contacted';
            }
            
            if(LeadtaskMap.get(tsk.whoid).Description == null && tsk.Status == 'Completed' && tsk.Subject == 'Qualify Opportuntity') {
                tsk.adderror('Task cannot be completed until the following fields have been populated: Description');
            }
            Else {
                LeadtaskMap.get(tsk.whoid).Status = 'Qualified';
            }
      }    
    } 
    
    List<Lead> leadList = LeadtaskMap.values();
     update leadList;
    }