• Arish_Khan
  • 0 Points
  • Member since 2011

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 13

I have functionality in our application that creates three PDF attachments and sets the parentId of the attachments to a custom object.  If I do not mark the Visualforce Pages with a renderAs="PDF" and then do a getContentAsPDF() it would seem that only ONE of the PDFs is correctly created (even though I see three insert statements -- one for each PDF).  HOWEVER, if I DO mark the page as renderAs="PDF" and then just do "getContent ()" all three are created and inserted.  What in the world could be causing this issue?  I'm happy I have a work-around, but not happy about the extra 60 to 90 minutes it took me to find this issue.  Is there some unknown governor limit that restricts the number of calls to getContentAsPDF()?


What works (renderAs="PDF"):

  Page.PDF1, getContent ()

  Page.PDF2, getContent ()

  Page.PDF3, getContent ()


What does NOT work (no renderAs="PDF" in the Visualforce page)

  Page.PDF1, getContentAsPDF ()

  Page.PDF2, getContentAsPDF ()

  Page.PDF3, getContentAsPDF ()


Thanks in advance.

  • February 16, 2012
  • Like
  • 0

Is it possible to use apex code for sending an email  after an interval of time.???

Actually I want to update a field using apex/record,that is achievable I guess but I want that after sometime of this update, mail should be send,
is it possible??? 

  • February 03, 2012
  • Like
  • 0
trigger contactDuplicatePreventer on Contact (before insert, before update) {

    Map<String, Contact> contactMap = new Map<String, Contact>();

    for (Contact contact : System.Trigger.new) {
        // Make sure we don't treat an email address that
        // isn't changing during an update as a duplicate.
        if ((contact.Email != null) && (System.Trigger.isInsert || (contact.Email != System.Trigger.oldMap.get(contact.Id).Email))) {
            // Make sure another new contact isn't also a duplicate
            if (contactMap.containsKey(contact.Email)) {
                contact.Email.addError('Another new Contact has the same email address.');
            } else {
                contactMap.put(contact.Email, contact);
    // Using a single database query, find all the contacts in
    // the database that have the same email address as any
    // of the contacts being inserted or updated.
for (Contact contact : [SELECT Email FROM Contact WHERE Email IN :contactMap.KeySet()]) { if(contact.email != null){
        Contact newContact = contactMap.get(contact.Email);
        newContact.Email.addError('A Contact with this email address already exists.'); }


I found the above trigger online and have implemented it into our production instance of SFDC. It appears to work except I occasionally get emails with the following error:



Subject: Developer script exception from iSqFt : contactDuplicatePreventer : contactDuplicatePreventer: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.contactDuplicatePreventer: line 25, column 9


Apex script unhandled trigger exception by user/organization: 005600000019X1a/00D6000000077GT


contactDuplicatePreventer: execution of BeforeUpdate


caused by: System.NullPointerException: Attempt to de-reference a null object


Trigger.contactDuplicatePreventer: line 25, column 9"


Can anyone tell me what I need to do to fix the trigger to prevent this? The user is also seeing a similar error on screen which is quite confusing to them.

Thank you.



This is probably a very simple question but I cant seem to find an answer to it. I have a list of type String and I have a loop which assigns the relevent item in the list to the string but I always get an error.

It is looking for a list type variable, an example is below:

List<String> task_names = new List<String>();

for (Integer task_number = 0; i < task_names.size(); i++) {

Task t1 = new task();

t1.Subject =  task_names.get[i];




I have tried a few ways of assign the value in the list to the string but it always seems to cause an error. When I used just task_names[i] on its own there was no error when I compliled but there was an array out of bounds exception when I tested it on our sandbox?

  • February 01, 2012
  • Like
  • 0



We have many roles in the system and this is my customers requirement:

Role-1: Royalty admin

Role-2: Temp Royalty

Role-3: Royalty User

 Hierarchy level : Role1,2,3 are in same hierrachy: I.E: Reporting to one particular role

Object: X

The records which are created by Royalty Admin should be visible to 'Temp Royalty' and ' Royalty User' and the users should have only read only access for the records.

On object X there is a check box named 'Duplicate' and the records which are created with the check box=True, these records should be visible only to 'Royalty Admin' users.


I have created 2 public groups where in the first group contains Role-1 and the 2nd Group contains Role-2&3.

I have written a sharing rule where in Group-1 is shared with Group-2 with only read only permission.

But when i create another criteria based sharing rule where in only the records which have duplicate = True to be visible to Group-1. When i do this the records which have duplicate=True is visible to Group-2 also. can anyone check and let me know if i am doing correct or is there any alternative solution for this.


Thanks for help......




I have created a dynamic search page using isualforce which functions exactly how I want it to.  However, the only issue I have is that I want the search page to only display records for a particular recordType.  Any idea how this can be achieved?


I would greatly appreciate any help please.


Thanks in advance.   


Here is my Apex coding...

public with sharing class RemedySearchController {
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of cases to display
  public List<Case> cases {get;set;}
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
  // the current field to sort by. defaults to Account Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'account.name'; } return sortField;  }
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
  // init the controller and display some sample data when the page loads
  public RemedySearchController() {
    soql = 'select CaseNumber, Model_Number__c, Engine_s_n__c, contact.Name, Serial_Number_New__r.Name, Product_Group__c, Status, THD_Team__c, Priority, Group_Brand__c, X2wd_4w__c, Affected_Area__c, Part__c, Dealer_Customer_Question__c, Information_Source__c, Call_Source__c, Origin, Customer_Number__c, account.Name from case where account.name != null';
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
  // runs the actual query
  public void runQuery() {
    try {
      cases = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Results Found!'));
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
    String modelNumber = Apexpages.currentPage().getParameters().get('Model_Number__c');
    String engineNumber = Apexpages.currentPage().getParameters().get('Engine_s_n__c'); 
    String contactName = Apexpages.currentPage().getParameters().get('contactName');
    String accountName = Apexpages.currentPage().getParameters().get('accountName');
    String serialNumber = Apexpages.currentPage().getParameters().get('serialNumber');
    String thdTeam = Apexpages.currentPage().getParameters().get('thdTeam');
    String productGroup = Apexpages.currentPage().getParameters().get('productGroup');
    String status = Apexpages.currentPage().getParameters().get('status');
    String priority = Apexpages.currentPage().getParameters().get('priority');
    String groupBrand = Apexpages.currentPage().getParameters().get('groupBrand');
    String wheelDrive = Apexpages.currentPage().getParameters().get('wheelDrive');
    String affectedArea = Apexpages.currentPage().getParameters().get('affectedArea');
    String partNumber = Apexpages.currentPage().getParameters().get('partNumber');
    String caseNumber = Apexpages.currentPage().getParameters().get('caseNumber');
    String customerQuestion = Apexpages.currentPage().getParameters().get('customerQuestion');
    String infoSource = Apexpages.currentPage().getParameters().get('infoSource');
    String callSource = Apexpages.currentPage().getParameters().get('callSource');
    String caseOrigin = Apexpages.currentPage().getParameters().get('caseOrigin');
    String customerNumber = Apexpages.currentPage().getParameters().get('customerNumber');
    soql = 'select CaseNumber, Model_Number__c, Engine_s_n__c, contact.Name, Serial_Number_New__r.Name, Product_Group__c, Status, THD_Team__c, Priority, Group_Brand__c, X2wd_4w__c, Affected_Area__c, Part__c, Dealer_Customer_Question__c, Information_Source__c, Call_Source__c, Origin, Customer_Number__c, account.name from case where account.name != null';
    if (!modelNumber.equals(''))
      soql += ' and Model_Number__c LIKE \''+String.escapeSingleQuotes(modelNumber)+'%\'';
    if (!engineNumber.equals(''))
      soql += ' and Engine_s_n__c LIKE \''+String.escapeSingleQuotes(engineNumber)+'%\'';
    if (!accountName.equals(''))
      soql += ' and Account.name LIKE \''+String.escapeSingleQuotes(accountName)+'%\'';
    if (!contactName.equals(''))
      soql += ' and contact.Name LIKE \''+String.escapeSingleQuotes(contactName)+'%\'';
    if (!serialNumber.equals(''))
      soql += ' and Serial_Number_New__r.name LIKE \''+String.escapeSingleQuotes(serialNumber)+'%\'';
    if (!thdTeam.equals(''))
      soql += ' and THD_Team__c LIKE \''+thdTeam+'\'';
    if (!productGroup.equals(''))
      soql += ' and Product_Group__c LIKE \''+productGroup+'\'';
    if (!status.equals(''))
      soql += ' and status LIKE \''+status+'\'';
    if (!priority.equals(''))
      soql += ' and Priority LIKE \''+priority+'\'';
    if (!groupBrand.equals(''))
      soql += ' and Group_Brand__c LIKE \''+groupBrand+'\'';
    if (!wheelDrive.equals(''))
      soql += ' and X2wd_4w__c LIKE \''+wheelDrive+'\'';
    if (!affectedArea.equals(''))
      soql += ' and Affected_Area__c LIKE \''+affectedArea+'\'';
    if (!partNumber.equals(''))
      soql += ' and Part__c LIKE \''+String.escapeSingleQuotes(partNumber)+'%\'';
    if (!caseNumber.equals(''))
      soql += ' and CaseNumber LIKE \''+String.escapeSingleQuotes(caseNumber)+'%\'';
    if (!customerQuestion.equals(''))
      soql += ' and Dealer_Customer_Question__c LIKE \''+customerQuestion+'\'';
    if (!infoSource.equals(''))
      soql += ' and Information_Source__c LIKE \''+infoSource+'\'';
    if (!callSource.equals(''))
      soql += ' and Call_Source__c LIKE \''+callSource+'\'';
    if (!caseOrigin.equals(''))
      soql += ' and Origin LIKE \''+caseOrigin+'\'';
    if (!customerNumber.equals(''))
      soql += ' and Customer_Number__c LIKE \''+String.escapeSingleQuotes(customerNumber)+'%\'';
    // run the query again
     return null;

 // use apex describe to build the picklist values
  public List<String> productGroups {
    get {
      if (productGroups == null) {
        productGroups = new List<String>();
        Schema.DescribeFieldResult field = Case.Product_Group__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return productGroups;          
    public List<String> statuses {
    get {
      if (statuses == null) {
        statuses = new List<String>();
        Schema.DescribeFieldResult field = Case.Status.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return statuses;          

    public List<String> thdTeams {
    get {
      if (thdTeams == null) {
        thdTeams = new List<String>();
        Schema.DescribeFieldResult field = Case.THD_Team__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return thdTeams;          
    public List<String> priorities {
    get {
      if (priorities == null) {
        priorities = new List<String>();
        Schema.DescribeFieldResult field = Case.Priority.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return priorities;          

    public List<String> groupBrands {
    get {
      if (groupBrands == null) {
        groupBrands = new List<String>();
        Schema.DescribeFieldResult field = Case.Group_Brand__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return groupBrands;          
    public List<String> wheelDrives {
    get {
      if (wheelDrives == null) {
        wheelDrives = new List<String>();
        Schema.DescribeFieldResult field = Case.X2wd_4w__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return wheelDrives;          

    public List<String> affectedAreas {
    get {
      if (affectedAreas == null) {
        affectedAreas = new List<String>();
        Schema.DescribeFieldResult field = Case.Affected_Area__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
      return affectedAreas;          

   public List<String> customerQuestions {
    get {
      if (customerQuestions == null) {
        customerQuestions = new List<String>();
        Schema.DescribeFieldResult field = Case.Dealer_Customer_Question__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          return customerQuestions;          
    public List<String> infoSources {
    get {
      if (infoSources == null) {
        infoSources = new List<String>();
        Schema.DescribeFieldResult field = Case.Information_Source__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          return infoSources;          
    public List<String> callSources {
    get {
      if (callSources == null) {
        callSources = new List<String>();
        Schema.DescribeFieldResult field = Case.Call_Source__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          return callSources;          
    public List<String> caseOrigins {
    get {
      if (caseOrigins == null) {
        caseOrigins = new List<String>();
        Schema.DescribeFieldResult field = Case.Origin.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          return caseOrigins;          
  • January 31, 2012
  • Like
  • 0



is it possible to use Translation Workbench for trigger error message translation, please?


Thanks for any proposals.


Best Regards


     I have VF page where it displays the related cases upon selecting the case owner on top , the case owner drop down appears on left hand side of screen now i want to add the todays date on the right hand side? is it possible to add the date ?


This is what i have for case owner drop down now how to add date to the below?


<apex:pageBlockSection >
 <apex:inputField id="own" value="{!case.Case_Owner__c}"  onChange="getSelectedId('{!$Component.own}');"/>




I am trying to bulid a tabbed page using TabPanel control. For each tab I have few fields as well few buttons. Say I have a button called edit at Tab 3, When I click the button it refreshes the page and puts me on the Tab 1 rather than Tab 3. I would like to know this is how the Tab panel behaves or I am doning nothing wrong.
So I looking for the solution for this to fix or any work around for this(Like getting tab id from page to controller)

Please provide me a better solution for this.


Thanks in advance.





I have utilised the excellent demo from Jeff Douglas at http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/ for building a custom dynamic search page in visual force. There is a great demo app there.


I have amended the code so that it works from my custom object. The page works fine, but I have an extra function that I would like but am not sure how to develop. 


In the search results on my VF page I want to be able to click on the name of each custom objects record so that it opens the record in the normal layout for the custom object. The custom object has a master detail relationship to Contacts and the field for this relationship has the link automatically displayed. Can anyone enlighten me as to the peice of code I need to allow the Name field to be clickable?


The code I have in the VF page for this field is:



<apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="name" assignTo="{!sortField}"/>
                <apex:outputField value="{!counselling_practice.name}"/>



Many thanks in advance