• magsy1.3942130065717605E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I want to download the specified file selected from the list. Always the first value in the select list is taken to download the file. I tried adding the onchange attribute but still could not get the desired output.

Page :

var newreportWin=null;
function openReportLookupPopup(name, id, popupType)
{

  console.debug('i am here...');
  if (popupType == "partner"){
    var url="/apex/PartnerLookupPopup?namefield=" + name + "&idfield=" + id;
  } else if (popupType == "customer") {
    var url="/apex/CustomerLookupPopup?namefield=" + name + "&idfield=" + id;
  }
  newreportWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
  if (window.focus)
  {
   newreportWin.focus();
  }
     return false;
}
     
function closeLookupPopup()
{
    if (null!=newreportWin)
    {
      var ReportcustomerId = document.getElementById('{!$Component.theForm.theReportPageBlock.theReportSection.theReportItem:customerReportTargetId}').value;
      var surveyName = document.getElementById('{!$Component.theForm.theReportPageBlock.theReportSection.theReportItems:Sname}').value;
      var dlLink = document.getElementById('{!$Component.theForm.downloadReportBlock.downloadReportLink}');
      if (ReportcustomerId != '') {
        dlLink.href = '/apex/SurveyExcelFile?cId=' + ReportcustomerId +'&SName='+surveyName;
        console.debug('i am here...'+surveyName);
      }
      newreportWin.close();
    }
}
</script>

  <apex:form id="theForm">
    <apex:pageMessages />
    <apex:pageBlock id="theReportPageBlock">
      <apex:pageBlockSection id="theReportSection" collapsible="false" columns="1">
        <apex:pageBlockSectionItem id="theReportItem">
          <apex:outputPanel id="thePanel">
           <apex:inputHidden value="{!ReportcustomerId}" id="customerReportTargetId" />
             <a href="#" onclick="openReportLookupPopup('{!URLENCODE($Component.customerReportTargetName)}', '{!$Component.customerReportTargetId}', 'customer');return false">Click here to search for a Customer</a>&nbsp;&nbsp;&nbsp;<apex:inputText size="80" value="{!ReportcustomerName}" id="customerReportTargetName" onFocus="this.blur()" disabled="false"/>
          </apex:outputPanel>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem id="theReportItems">
         <apex:outputPanel > Select Survey: </apex:outputPanel>
           <apex:selectList value="{!SurveyName}" size="1" id="Sname">
    <apex:selectOptions value="{!items}"/>
    <apex:actionSupport event="onchange" action="openReportLookupPopup('{!URLENCODE($Component.customerReportTargetName)}', '{!$Component.customerReportTargetId}', 'customer');return false" reRender="theForm" />
   </apex:selectList>
  </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      </apex:pageBlock>
 
  <apex:pageBlock id="downloadReportBlock">
    <apex:outputLink id="downloadReportLink">Download Report File</apex:outputLink>
  </apex:pageBlock>

</apex:form>

</apex:page>

Controller:

public class SurveyDownloadCOntroller {
  public String ReportcustomerName {get; set;}
     public Id ReportcustomerId {get; set;}

  public void reRenderDummy() {
    return; // do nothing. this is just to render the download link
  }
  String[] SurveyName = new String[]{};
public PageReference test() {
  return null;
}
public List<SelectOption> getItems() {
  List<SelectOption> options = new List<SelectOption>();
  options.add(new SelectOption('BCP Survey','BCP Survey'));
  options.add(new SelectOption('CSR Survey','CSR Survey'));
  options.add(new SelectOption('CM Survey','CM Survey'));
  return options;
}
public String[] getSurveyName() {
  return SurveyName;
}
public void setSurveyName(String[] SurveyName) {
  this.SurveyName = SurveyName;
}
}
Hi 
I am getting this error when I try to update my Site.
Following is the trigger.

trigger SiteTrigger on Site__c (after insert, after update, before insert, before update, before delete) {
   
    /**
    *   Calculate Latitude and Longitude of Sites after its inserted.
    *  Send Sites to all the customers that are approved by the respective Parent Partner
    **/
    if(Trigger.isAfter && Trigger.isInsert){
        Utility_Trigger.SiteAI_UpdateLatLng_SendSitesToCustomer(Trigger.new);      
    }
   
    /**
    *   copy details of Sub Contractor Site to a Partner Site, for a Sub-COntractor owned Site
    **/
    if(Trigger.isBefore && trigger.isInsert){
    
        Utility_Trigger.Site_BI_CopySCSiteDetails(Trigger.new);
        Utility_Trigger.Site_BI_verifyDuplicateSubTierSites(Trigger.new);
    }
   
    /**
    *   copy details of Sub Contractor Site to a Partner Site, for a Sub-COntractor owned Site
    **/
// Siddharth: this trigger is not being used, hence commenting it out to improve code coverage.
/*    if(Trigger.isBefore && trigger.isUpdate){
        Utility_Trigger.Site_BU_CopySCSiteDetails(Trigger.old, Trigger.new);
    } */
   
    /**
    *   Calculate Latitude and Longitude of Sites if its address is updated
    *   Update composite Keys of SAs & PPSAs on update of Site 
    **/
    if(Trigger.isAfter && Trigger.isUpdate){
        Utility_Trigger.Site_AU_UpdateLatLng(Trigger.new, Trigger.old);
        Utility_Trigger.Site_AU_updateSA_CK(Trigger.old, Trigger.new);
        //Utility_Trigger.Site_AU_SendSCAndSCSToCustomerOrg(Trigger.old, Trigger.new);  
    }

if(Trigger.isBefore && Trigger.isDelete){      
        Utility_Trigger.Site_BD_NotifyForUsedSites(Trigger.oldMap);        
    }
   
}
Below is the method in Utility Trigger

public static void Site_AU_UpdateLatLng(List<Site__c> sitesNew, List<Site__c> sitesOld){
        List<Site__c> sitesToUpdate = new List<Site__c>();
        Set<Id> siteIds = new Set<Id>();
        for(Integer i = 0; i < sitesNew.size(); i++){
            Site__c a_site = sitesNew[i];       
            if(     a_site.Full_Address__c != sitesOld[i].Full_Address__c
                ||  a_site.Country__c != sitesOld[i].Country__c){
               sitesToUpdate.add(a_site);
            }
        }
        for(Site__c a_site : sitesToUpdate){
            siteIds.add(a_site.id);    
        } 
        if(siteIds.size()>0){
            Utility_General.updateSiteLatLng(siteIds, UserInfo.getUserId());
        }
       
       
    }



Hi,

I am new to Salesforce and therefore want to know the exact functioning of escapeSingleQuotes() method.
My code uses this method as:

soql = 'Select Id, Name, Metals__c from Smelter__c where';
        soql += ' Name LIKE \''+String.escapeSingleQuotes(smelterNameQuery.trim())+'%\'';

The name consists of single quote at the end of string.
So how do I remove the single quote.?
I want to download the specified file selected from the list. Always the first value in the select list is taken to download the file. I tried adding the onchange attribute but still could not get the desired output.

Page :

var newreportWin=null;
function openReportLookupPopup(name, id, popupType)
{

  console.debug('i am here...');
  if (popupType == "partner"){
    var url="/apex/PartnerLookupPopup?namefield=" + name + "&idfield=" + id;
  } else if (popupType == "customer") {
    var url="/apex/CustomerLookupPopup?namefield=" + name + "&idfield=" + id;
  }
  newreportWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
  if (window.focus)
  {
   newreportWin.focus();
  }
     return false;
}
     
function closeLookupPopup()
{
    if (null!=newreportWin)
    {
      var ReportcustomerId = document.getElementById('{!$Component.theForm.theReportPageBlock.theReportSection.theReportItem:customerReportTargetId}').value;
      var surveyName = document.getElementById('{!$Component.theForm.theReportPageBlock.theReportSection.theReportItems:Sname}').value;
      var dlLink = document.getElementById('{!$Component.theForm.downloadReportBlock.downloadReportLink}');
      if (ReportcustomerId != '') {
        dlLink.href = '/apex/SurveyExcelFile?cId=' + ReportcustomerId +'&SName='+surveyName;
        console.debug('i am here...'+surveyName);
      }
      newreportWin.close();
    }
}
</script>

  <apex:form id="theForm">
    <apex:pageMessages />
    <apex:pageBlock id="theReportPageBlock">
      <apex:pageBlockSection id="theReportSection" collapsible="false" columns="1">
        <apex:pageBlockSectionItem id="theReportItem">
          <apex:outputPanel id="thePanel">
           <apex:inputHidden value="{!ReportcustomerId}" id="customerReportTargetId" />
             <a href="#" onclick="openReportLookupPopup('{!URLENCODE($Component.customerReportTargetName)}', '{!$Component.customerReportTargetId}', 'customer');return false">Click here to search for a Customer</a>&nbsp;&nbsp;&nbsp;<apex:inputText size="80" value="{!ReportcustomerName}" id="customerReportTargetName" onFocus="this.blur()" disabled="false"/>
          </apex:outputPanel>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem id="theReportItems">
         <apex:outputPanel > Select Survey: </apex:outputPanel>
           <apex:selectList value="{!SurveyName}" size="1" id="Sname">
    <apex:selectOptions value="{!items}"/>
    <apex:actionSupport event="onchange" action="openReportLookupPopup('{!URLENCODE($Component.customerReportTargetName)}', '{!$Component.customerReportTargetId}', 'customer');return false" reRender="theForm" />
   </apex:selectList>
  </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      </apex:pageBlock>
 
  <apex:pageBlock id="downloadReportBlock">
    <apex:outputLink id="downloadReportLink">Download Report File</apex:outputLink>
  </apex:pageBlock>

</apex:form>

</apex:page>

Controller:

public class SurveyDownloadCOntroller {
  public String ReportcustomerName {get; set;}
     public Id ReportcustomerId {get; set;}

  public void reRenderDummy() {
    return; // do nothing. this is just to render the download link
  }
  String[] SurveyName = new String[]{};
public PageReference test() {
  return null;
}
public List<SelectOption> getItems() {
  List<SelectOption> options = new List<SelectOption>();
  options.add(new SelectOption('BCP Survey','BCP Survey'));
  options.add(new SelectOption('CSR Survey','CSR Survey'));
  options.add(new SelectOption('CM Survey','CM Survey'));
  return options;
}
public String[] getSurveyName() {
  return SurveyName;
}
public void setSurveyName(String[] SurveyName) {
  this.SurveyName = SurveyName;
}
}
Hi 
I am getting this error when I try to update my Site.
Following is the trigger.

trigger SiteTrigger on Site__c (after insert, after update, before insert, before update, before delete) {
   
    /**
    *   Calculate Latitude and Longitude of Sites after its inserted.
    *  Send Sites to all the customers that are approved by the respective Parent Partner
    **/
    if(Trigger.isAfter && Trigger.isInsert){
        Utility_Trigger.SiteAI_UpdateLatLng_SendSitesToCustomer(Trigger.new);      
    }
   
    /**
    *   copy details of Sub Contractor Site to a Partner Site, for a Sub-COntractor owned Site
    **/
    if(Trigger.isBefore && trigger.isInsert){
    
        Utility_Trigger.Site_BI_CopySCSiteDetails(Trigger.new);
        Utility_Trigger.Site_BI_verifyDuplicateSubTierSites(Trigger.new);
    }
   
    /**
    *   copy details of Sub Contractor Site to a Partner Site, for a Sub-COntractor owned Site
    **/
// Siddharth: this trigger is not being used, hence commenting it out to improve code coverage.
/*    if(Trigger.isBefore && trigger.isUpdate){
        Utility_Trigger.Site_BU_CopySCSiteDetails(Trigger.old, Trigger.new);
    } */
   
    /**
    *   Calculate Latitude and Longitude of Sites if its address is updated
    *   Update composite Keys of SAs & PPSAs on update of Site 
    **/
    if(Trigger.isAfter && Trigger.isUpdate){
        Utility_Trigger.Site_AU_UpdateLatLng(Trigger.new, Trigger.old);
        Utility_Trigger.Site_AU_updateSA_CK(Trigger.old, Trigger.new);
        //Utility_Trigger.Site_AU_SendSCAndSCSToCustomerOrg(Trigger.old, Trigger.new);  
    }

if(Trigger.isBefore && Trigger.isDelete){      
        Utility_Trigger.Site_BD_NotifyForUsedSites(Trigger.oldMap);        
    }
   
}
Below is the method in Utility Trigger

public static void Site_AU_UpdateLatLng(List<Site__c> sitesNew, List<Site__c> sitesOld){
        List<Site__c> sitesToUpdate = new List<Site__c>();
        Set<Id> siteIds = new Set<Id>();
        for(Integer i = 0; i < sitesNew.size(); i++){
            Site__c a_site = sitesNew[i];       
            if(     a_site.Full_Address__c != sitesOld[i].Full_Address__c
                ||  a_site.Country__c != sitesOld[i].Country__c){
               sitesToUpdate.add(a_site);
            }
        }
        for(Site__c a_site : sitesToUpdate){
            siteIds.add(a_site.id);    
        } 
        if(siteIds.size()>0){
            Utility_General.updateSiteLatLng(siteIds, UserInfo.getUserId());
        }
       
       
    }



Hi I have to update more then 100 records in my update call but the limit of the trigger is just to update only 100 records in a trigger. Please let me know how i can update more then 100 records in my trigger. Thanks Divya Prakash Goel