• MRDJ
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 7
    Replies
Need to add four more columns to the table which have dynamic columns in the visual force page.
The four new columns that need to be added are from different object.
In the current dynamic table there are five columns C1, C2, C3, C4 and C5 belongs to custom_obj__1. The four new columns (N1, N2, N3, N4) belonging to object custom_obj__2 should be placed next to C2, that is in between C2 and C3 and the result of the columns should be C1, C2, N1, N2, N3, N4, C3, C4, C5.
 
As I said, it's a dynamic table based on the SOQL query the columns are displayed currently and in the order C1, C2, C3, C4 and C5. The new columns data is in different object.
 
Can someone provide me guidance to achieve this requirement. Thanks.
  • April 19, 2017
  • Like
  • 0
Can someone provide me guidance on column header wrapping in visual force page with Java Script?
  • March 01, 2017
  • Like
  • 0
Can someone share the sample code how to perform the upsert operation with trigger if the record already exists in the object then it should just update (and shouldn't insert to avoid duplicate) and if the record doesn't exist then insert the record. Using external id field on the object, but I do not want to display any error message in the UI saying the record already exists/duplicate. It should simply update the existing one or skip the record.
  • December 12, 2016
  • Like
  • 0
I need help on the below requirement.
Project_Creation__c is custom object,
Identifier_pcm__c is the external id field on that object.

In this object, records are created from online and Mobile.
If the record is created from online and the same record already exists based on external id field (Identifier_pcm__c) match, then should throw error message in online
If the record is created from Mobile and the same record already exists based on external id field (Identifier_pcm__c) match, then delete the existing (old) record and replace with new record.

Here is the code I have written but not working. Can someone help me.
trigger Project_Creation_Duplicate_Check on Project_Creation__c (before insert) 
{
    //Map to store the id and Identifier (field) of each Project Creation record that comes into the trigger so we can use that to do a SOQL query later when its time to see if it already exists.  add the 'trigger.isBefore' even though we know this will only occur before, so that this can be easily extended in the future and we wont have to go back and change code.
    //Map<String, Project_Creation__c> mappcm = new Map<String, Project_Creation__c>();
    
    //create a list of all related accounts
    //List<id> relatedAccounts = new List<id>();
    //for(Project_Creation__c pcm : Trigger.new)
    //{
        //relatedAccounts.add(pcm.Identifier_pcm__c);
    //}
    //create a map of Account with Project Creation data
    Map<id, List<Project_Creation__c>> mapAccounttopcms = new Map<id, List<Project_Creation__c>>();
    for(Project_Creation__c pcmRecords : Trigger.new)
    {
        if((pcmRecords.Identifier_pcm__c != null) && (Trigger.isInsert || (pcmRecords.Identifier_pcm__c != Trigger.oldMap.get(pcmRecords.Id).Identifier_pcm__c)))
        {
            if(mapAccounttopcms.containsKey(pcmRecords.Identifier_pcm__c) && pcmRecords.Mobile_ID__c == null)
            {
                pcmRecords.Identifier_pcm__c.addError('You are creating a duplicate record. ' + 'We recommend you use an existing record instead.');
            }
            if(mapAccounttopcms.containsKey(pcmRecords.Identifier_pcm__c) && pcmRecords.Mobile_ID__c != null)
            {
                mapAccounttopcms.get(pcmRecords.Identifier_pcm__c).add(pcmRecords);
            }
            else
            {
                mapAccounttopcms.put(pcmRecords.Identifier_pcm__c, new List<Project_Creation__c>{pcmRecords});
            }
        }
    }
    
    // Using a single database query, find all the project creations in  
    // the database that have the same Identifier as any  
    // of the project creations being inserted or updated.  
    
        for(Project_Creation__c pcm : [Select Identifier_pcm__c FROM Project_Creation__c WHERE Identifier_pcm__c IN :mappcm.keySet()])
        {
            Project_Creation__c newpcm = mapAccounttopcms.get(pcm.Identifier_pcm__c);
            newpcm.Identifier_pcm__c.addError('You are creating a duplicate record. ' + 'We recommend you use an existing record instead.');
        }
        
    //iterate over the map mapAccounttopcms and add any duplicate values to a list
    List<Project_Creation__c> toDelete = new List<Project_Creation__c>();
    for(Project_Creation__c pcm : trigger.new)
    {
        List<Project_Creation__c> pcmRecordList = new List<Project_Creation__c>();
        pcmRecordList = mapAccounttopcms.get(pcm.Identifier_pcm__c);
        
        if(pcmRecordList!=null && pcmRecordList.size()>0)
        {
            for(Project_Creation__c am : pcmRecordList)
            {
                if(pcm.Identifier_pcm__c == am.Identifier_pcm__c)
                {
                    toDelete.add(am);
                }
            }
        }
    }
    if(!toDelete.isEmpty())
    {
        try
        {
            Database.delete(toDelete);
        }
        catch(DMLException e)
        {
            String logMsg = '';
            for (Integer i=0; i<e.getNumDml(); i++) 
            {
                logMsg = e.getDmlType(i) + ': ' + e.getDmlMessage(i);
                String[] errFlds = e.getDmlFieldNames(i);
                if (errFlds != null) 
                {
                    logMsg += '(';
                    for (Integer j=0; j<errFlds.size(); j++) 
                    {
                        if (j>0)logMsg += ', ';
                        logMsg += errFlds[j];
                    }
                }
            }
            // Error found, keep user on same page to display messages
            System.debug('SFDC Project Creation Record deletion Trigger threw the following exception: ' + e.getMessage() + logMsg);
        }
    }
}

 
  • December 12, 2016
  • Like
  • 0
Hello,

I have followed the below code not to allow duplicates. But I don't want to display the error message. If there is duplicate record is created or existing record updated then shouldn't throw error simply skip that record. I mean do not insert the record in the object. 

Can someone help me
 
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()]) {
        Contact newContact = contactMap.get(Contact.Email);
        newContact.Email.addError('A Contact with this email '
                               + 'address already exists.');
    }
}

 
  • December 09, 2016
  • Like
  • 0
I need to bring the User Language (like English, Chinese, Polish) before creating a record on custom object. Whoever creates the record, that user language need to be populated on the custom object field. Can someone help me how to get user language (not local like en_US, pl) with trigger
  • March 16, 2016
  • Like
  • 0
Hello,

I am trying to upload the below three components, JS and CSS in static resources to reference in VF page.

When I use like this, working great! no issues.

<apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
    <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />

But when I use like this, create a zip file and then subfolders js and css then refrence the static resource in vf page is not working.

<apex:includeScript value="{!URLFOR($Resource.DataTable, 'js/jquery-1.11.1.min.js')}"/>

<apex:includeScript value="{!URLFOR($Resource.DataTable, 'js/jquery.dataTables.min.js')}"/>

<apex:stylesheet value="{!URLFOR($Resource.DataTable, 'css/jquery.dataTables.css')}"/>

 Please help me how to work them using as statis resource. Thanks,
  • September 16, 2015
  • Like
  • 0
Hello,
I am using Standard Set controller to display the list views using VF page.
In the list view there is input field, Yes/No. Once the option either Yes or No is selected for records then save button is clicked.
I would like to know once the save is clicked, record should be saved and the list view should refresh and then the records that are saved shouldn't be displayed again.

Thanks.
  • September 16, 2015
  • Like
  • 0
There are 3 objects, Object1, Objec2 and Object3.

Object 1 and Object2 have relationship, Object 1 is parent and Object 2 is child. 
Need to update records on Object 3 based on the results from Object 1 and Object 2

Need apex batch class to update the flag on object 3.

Object 1: Parent Object
Field1: Id
Field2: OwnerId
Field3: Status

Fetch all the records from parent object: Select Id, OwnerId from Parent Object where Status='Submitted'
From this OwnerId is required

Object 2: Child Object
Field1: Id
Field2: Name (this is parent object Id, Field2)
Field3: Item Number
Field4: Item Name
Field5: COunt

Fetch all the child records of the corresponding soql result: Select Item Number, Item Name from Child Object where count=0 and Name in (above soql result of Ids)
From this Item Number, Item Name are required to map the OwnerId

Object 3: Different Object
Field 1: OwnerId (this ownerId is same as Field 2 in Object 1)
Field 2: Item Number (this Item number is same as Field3 in Object 2)
Field 3: Item Name (this Item name is same as Field4 in Object 2)
Field 4: Active

In this, active field should be set to false based on the corresponding OwnerId records of respective item numbers and names.
  • July 20, 2015
  • Like
  • 0
There are 3 objects, Object1, Objec2 and Object3.

Object 1 and Object2 have relationship, Object 1 is parent and Object 2 is child. 
Need to update records on Object 3 based on the results from Object 1 and Object 2

Need apex batch class to update the flag on object 3.
  • July 16, 2015
  • Like
  • 0
This is the scenario , filter records based on a picklist or a lookup field in visual force page where I am looking for solution.

There is an object objA, it has 4 lookup fields.
Lookup Field1 (LF1) - This field is lookup to ObjB
Lookup Field2 (LF2) - This field is lookup to ObjC
Lookup Field3 (LF3) - This field is lookup to ObjD
Lookup Field4 (LF4) - This field is lookup to ObjE

in the visual force page, all the above lookup fields are dependent on one another. Once LF1 is entered, then LF2 is dependent on LF1 value, LF3 is dependent on LF2 value and LF4 value is dependent on LF3 value

Can someone help me in writing visual force page and apex controller for this scenario
  • March 05, 2015
  • Like
  • 0
I need help on the below requirement.
Project_Creation__c is custom object,
Identifier_pcm__c is the external id field on that object.

In this object, records are created from online and Mobile.
If the record is created from online and the same record already exists based on external id field (Identifier_pcm__c) match, then should throw error message in online
If the record is created from Mobile and the same record already exists based on external id field (Identifier_pcm__c) match, then delete the existing (old) record and replace with new record.

Here is the code I have written but not working. Can someone help me.
trigger Project_Creation_Duplicate_Check on Project_Creation__c (before insert) 
{
    //Map to store the id and Identifier (field) of each Project Creation record that comes into the trigger so we can use that to do a SOQL query later when its time to see if it already exists.  add the 'trigger.isBefore' even though we know this will only occur before, so that this can be easily extended in the future and we wont have to go back and change code.
    //Map<String, Project_Creation__c> mappcm = new Map<String, Project_Creation__c>();
    
    //create a list of all related accounts
    //List<id> relatedAccounts = new List<id>();
    //for(Project_Creation__c pcm : Trigger.new)
    //{
        //relatedAccounts.add(pcm.Identifier_pcm__c);
    //}
    //create a map of Account with Project Creation data
    Map<id, List<Project_Creation__c>> mapAccounttopcms = new Map<id, List<Project_Creation__c>>();
    for(Project_Creation__c pcmRecords : Trigger.new)
    {
        if((pcmRecords.Identifier_pcm__c != null) && (Trigger.isInsert || (pcmRecords.Identifier_pcm__c != Trigger.oldMap.get(pcmRecords.Id).Identifier_pcm__c)))
        {
            if(mapAccounttopcms.containsKey(pcmRecords.Identifier_pcm__c) && pcmRecords.Mobile_ID__c == null)
            {
                pcmRecords.Identifier_pcm__c.addError('You are creating a duplicate record. ' + 'We recommend you use an existing record instead.');
            }
            if(mapAccounttopcms.containsKey(pcmRecords.Identifier_pcm__c) && pcmRecords.Mobile_ID__c != null)
            {
                mapAccounttopcms.get(pcmRecords.Identifier_pcm__c).add(pcmRecords);
            }
            else
            {
                mapAccounttopcms.put(pcmRecords.Identifier_pcm__c, new List<Project_Creation__c>{pcmRecords});
            }
        }
    }
    
    // Using a single database query, find all the project creations in  
    // the database that have the same Identifier as any  
    // of the project creations being inserted or updated.  
    
        for(Project_Creation__c pcm : [Select Identifier_pcm__c FROM Project_Creation__c WHERE Identifier_pcm__c IN :mappcm.keySet()])
        {
            Project_Creation__c newpcm = mapAccounttopcms.get(pcm.Identifier_pcm__c);
            newpcm.Identifier_pcm__c.addError('You are creating a duplicate record. ' + 'We recommend you use an existing record instead.');
        }
        
    //iterate over the map mapAccounttopcms and add any duplicate values to a list
    List<Project_Creation__c> toDelete = new List<Project_Creation__c>();
    for(Project_Creation__c pcm : trigger.new)
    {
        List<Project_Creation__c> pcmRecordList = new List<Project_Creation__c>();
        pcmRecordList = mapAccounttopcms.get(pcm.Identifier_pcm__c);
        
        if(pcmRecordList!=null && pcmRecordList.size()>0)
        {
            for(Project_Creation__c am : pcmRecordList)
            {
                if(pcm.Identifier_pcm__c == am.Identifier_pcm__c)
                {
                    toDelete.add(am);
                }
            }
        }
    }
    if(!toDelete.isEmpty())
    {
        try
        {
            Database.delete(toDelete);
        }
        catch(DMLException e)
        {
            String logMsg = '';
            for (Integer i=0; i<e.getNumDml(); i++) 
            {
                logMsg = e.getDmlType(i) + ': ' + e.getDmlMessage(i);
                String[] errFlds = e.getDmlFieldNames(i);
                if (errFlds != null) 
                {
                    logMsg += '(';
                    for (Integer j=0; j<errFlds.size(); j++) 
                    {
                        if (j>0)logMsg += ', ';
                        logMsg += errFlds[j];
                    }
                }
            }
            // Error found, keep user on same page to display messages
            System.debug('SFDC Project Creation Record deletion Trigger threw the following exception: ' + e.getMessage() + logMsg);
        }
    }
}

 
  • December 12, 2016
  • Like
  • 0
Hello,

I have followed the below code not to allow duplicates. But I don't want to display the error message. If there is duplicate record is created or existing record updated then shouldn't throw error simply skip that record. I mean do not insert the record in the object. 

Can someone help me
 
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()]) {
        Contact newContact = contactMap.get(Contact.Email);
        newContact.Email.addError('A Contact with this email '
                               + 'address already exists.');
    }
}

 
  • December 09, 2016
  • Like
  • 0
Hello,

I am trying to upload the below three components, JS and CSS in static resources to reference in VF page.

When I use like this, working great! no issues.

<apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
    <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />

But when I use like this, create a zip file and then subfolders js and css then refrence the static resource in vf page is not working.

<apex:includeScript value="{!URLFOR($Resource.DataTable, 'js/jquery-1.11.1.min.js')}"/>

<apex:includeScript value="{!URLFOR($Resource.DataTable, 'js/jquery.dataTables.min.js')}"/>

<apex:stylesheet value="{!URLFOR($Resource.DataTable, 'css/jquery.dataTables.css')}"/>

 Please help me how to work them using as statis resource. Thanks,
  • September 16, 2015
  • Like
  • 0
if found duplicates records based on customer number field unique,so update to exiting record and new record need to delete?please help me on this

trigger GE_LGT_EM_AvoidDuplicateAccount on Account (before insert,before update) {

    Map<String, Account> AccountMap = new Map<String, Account>();
    set<string> deleteAccountMap = new set<string>();
    Map<id,account>updateacc=new Map<id,Account>();
    List<recordtype> rt=[select id,name from recordtype where sobjecttype='Account' and name='EMEA Account'];
        for (Account acc :System.Trigger.new)
        {
        if ((acc.GE_LGT_EM_SAP_Customer_Number__c != null) && acc.RecordTypeid==rt[0].id && (System.Trigger.isInsert ))
        AccountMap.put(acc.GE_LGT_EM_SAP_Customer_Number__c, acc);
         deleteAccountMap.add(acc.id);
        }
      
    list<account> acclist=[SELECT id,
    Name,
    GE_LGT_EM_Partner_Function__c,
    BillingStreet,
    BillingCity,
    BillingState,
    BillingPostalCode,
    GE_LGT_EM_CustomerActiveFlag__c,
    GE_LGT_EM_Tax_Number_1__c,
    GE_LGT_EM_Tax_Number_2__c,
    CurrencyIsoCode,
    GE_LGT_EM_Plant__c,
    GE_LGT_EM_PF_Type__c,
    GE_LGT_EM_SAP_Customer_Number__c FROM Account WHERE RecordTypeid=:rt[0].id and GE_LGT_EM_SAP_Customer_Number__c IN:AccountMap.KeySet()];
        system.debug('-------->acclist'+acclist);
        for(Account c :Trigger.new)
        {
            for(Account acct:acclist)
           {
           system.debug('----------->inside for loop');
               if(c.GE_LGT_EM_SAP_Customer_Number__c==acct.GE_LGT_EM_SAP_Customer_Number__c && AccountMap.containsKey(c.GE_LGT_EM_SAP_Customer_Number__c) && c.RecordTypeid==rt[0].id)
                {
                    acct.Name=c.Name;
                    acct.GE_LGT_EM_Partner_Function__c=c.GE_LGT_EM_Partner_Function__c;
                    acct.BillingStreet=c.BillingStreet;
                    acct.BillingCity=c.BillingCity;
                    acct.BillingState=c.BillingState;
                    acct.BillingPostalCode=c.BillingPostalCode;
                    acct.GE_LGT_EM_CustomerActiveFlag__c=c.GE_LGT_EM_CustomerActiveFlag__c;
                    acct.GE_LGT_EM_Tax_Number_1__c=c.GE_LGT_EM_Tax_Number_1__c;
                    acct.GE_LGT_EM_Tax_Number_2__c=c.GE_LGT_EM_Tax_Number_2__c;
                    acct.CurrencyIsoCode=c.CurrencyIsoCode;
                    acct.GE_LGT_EM_Plant__c=c.GE_LGT_EM_Plant__c;
                    acct.GE_LGT_EM_PF_Type__c=c.GE_LGT_EM_PF_Type__c;
                    updateacc.put(acct.id,acct);
                }
                        
            }      
        }
   
   if(updateacc.size()>0){
     system.debug('----------->update final');
   update updateacc.values();
   }
  
  /**************delete duplicate account**************/
   set<string> uniqueIds = new set<string>();

    for (Account s : Trigger.new)
        uniqueIds.add(s.GE_LGT_EM_SAP_Customer_Number__c);

    list<Account> existingAccounts = [select id,GE_LGT_EM_SAP_Customer_Number__c from Account where GE_LGT_EM_SAP_Customer_Number__c in :uniqueIds and RecordTypeid=:rt[0].id];

    list<Account> dupestodelete = new list<Account>();
    for (Account s : Trigger.new)
    {
        for (Account existing : existingAccounts)
        {
            if (s.GE_LGT_EM_SAP_Customer_Number__c == existing.GE_LGT_EM_SAP_Customer_Number__c )
            {
                dupestodelete.add(s);
                continue;
            }
        }
    }

    delete dupestodelete;

}

How to get pages, classes,Trigers,users,recordtypes Dynamically in VF page as Tab panels and also with moseover links?????????

Hello everyone,

I am seeking some help and advice regarding email templates.

Our ORG currently is configured with Accounts >> Opportunities >> Opportunity Line Items (multiple "items" per opp is possible).

What I'm trying to accomplish is:

Pull Account Information, Pull Opportunity Information, BUT ALSO pull Opportunity Line Items for an email template.

Currently, if I send an email template from the opportunity object, it only pulls account and opportunity information.

Anyone have the same problem?  I've tried using VF/APEX templates but I'm pretty new to that.

Please help.

Thanks