• Leon Thanikal
  • NEWBIE
  • 25 Points
  • Member since 2019

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 13
    Replies
Hi Team,
scenario :
I have Case object and status picklist filed .
Status field have New, In-progress,completed, Rejected and Closed.
My requirement is :
When Creating case , only user can select status value is NEW not other values , But in details page user can select any status values.

THanks
sekhar
  • November 04, 2019
  • Like
  • 0
I have case object firstname and lastname and city multiselect picklist i need to auto populate combination of above 3 fields.
I'm new to developing in general and I am trying to create a trigger that updates the custom lookup field Test1__c and account__c on the custom object test2  object. I have a created a custom object called test2  o  which has a related one-to-one relationship with the Account and test 1. I'm getting an error when attempting to save the Opportunity record, although it mentions the correct reference below but doesnt populate the field. My code is pasted below the error message."Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Populatetest2caused an unexpected exception, contact your administrator: Populatetest2 : data changed by trigger for field Repcode: data value too large: (value has been hidden)"
 
trigger PopulateTest2 on Test1(before insert,before update) {
    set<ID> setofTest2 = new set<id>();
    set<ID> setofContactUser     = new set<id>();
    for (Test1 CA : trigger.new){
        if(CA.Test2_Name__c != null){
            setofTest2.add(CA.Test2_Name__c);}
        if(CA.ContactUser__c!=null){
            setofContactUser.add(CA.ContactUser__c); }   }       
        List<Test2__c> Test2List  = [Select ContactUser__c from Test2__c where id in: setofTest2];
        List<Account>  AccList = [Select Name from Account where id in: setofContactUser];    
     for(Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].Test2__c != null) {
           Trigger.new[i].Test2__c = Test2List[i].ID;            
        }
        if (Trigger.new[i].ContactUser__c != null) {
           Trigger.new[i].ContactUser__c  = AccList[i].ID;            
        }
    }
    }


 
Hello All,

I have Picklist Field A with 16 values and picklist field B with 2 values(Mail/Email). Few values in Picklist A should have both email and mail so that user can select one. Few should have only one either mail/Email.  This is in lightning.

Please let me know the ways to do it.

Thank you for your help.
 
Hi Team,
pls find below my requirement :
i have Case object and custom object . Both have same Record Types.
In custom object contains ' Manager reviwer ' value.
When case status is ' pending for manager review ' then its send notificaiotn to custom object ' Manager reviwer ' ... based on Record Types..
can you anyone provide code for this requirement ...


 
  • November 04, 2019
  • Like
  • 0
Hi Team,
scenario :
I have Case object and status picklist filed .
Status field have New, In-progress,completed, Rejected and Closed.
My requirement is :
When Creating case , only user can select status value is NEW not other values , But in details page user can select any status values.

THanks
sekhar
  • November 04, 2019
  • Like
  • 0
So we have these two look-up(user) fields on the Account object:
  • Account_Manager__c
  • Enterprise_Solutions_Manager__c
On Account Teams, we have 2 team role picklist values that correspond to these fields (api names):
  • Account Manager
  • Enterprise Solution Manager
I need a before trigger that will update the account fields automatically based on the Account Team roles setup based on the owner of the account (so each owner has a pre-set account team).

I am not a developer and I don't really write code. Can someone help me out with this?

Thanks!
Erin
Here is my code. It perfectly run on insert, it also update contact name and it also delete the contact if i remove tha name but it updates by duplicate name. there is field on contact i.e. No_of_Occurences. If I update t
public class CommaSeparatedContact 
{
    String strFirstName;
    String strLastName;
    String strName;
    List<Contact> lstContact;
    Map<String,Contact> mapUniqueContact = new Map<String,Contact>();
    List<Contact> lstContactToDelete = new List<Contact>();
    Map<String,List<Contact>> mapContactComparison = new Map<String,List<Contact>>();
    Set<Id> setAccId= new Set<Id>();   
    
    public void onInsert(List<Account> lstAccountTrigger)
    {   
        List<String> lstString = new List<String>();
        for(Account objAccountCon : lstAccountTrigger)
        {
            lstContact = new List<Contact>();
            if(objAccountCon.Comma_Separated_Values__c != null)
                lstString =  objAccountCon.Comma_Separated_Values__c.split(',');
            for(Integer i=0; i<lstString.size(); i++)
            {
                Contact objContact = new Contact();
                if(lstString[i].contains(' '))
                {
                    strFirstName = lstString[i].substringBefore(' ');
                    strLastName = lstString[i].substringAfter(' ');
                }
                else
                {
                    strFirstName = '';
                    strLastName = lstString[i];
                }
                objContact.No_of_Occurrence__c = 1;
                objContact.LastName = strLastName;
                objContact.FirstName = strFirstName;
                strname = objContact.FirstName+' '+ objContact.LastName;
                objContact.AccountId = objAccountCon.Id;
                
                if(mapUniqueContact.containsKey(strname))
                {
                    Contact objc = mapUniqueContact.get(strname);
                    objc.No_of_Occurrence__c +=1;  
                }
                else
                {
                    mapUniqueContact.put(strname,objContact);
                }
            }
        }
        
        for(String objCont : mapUniqueContact.keySet())
        {
            lstContact.add(mapUniqueContact.get(objCont));
        }
        if(lstContact.size()>0)
        {
            insert lstContact;
        }
    }
    
    public void onUpdate(List<Account> lstAccountTrigger, Map<Id,Account> mapOldAccount)
    {  
        List<Contact> lstContactToUpdate = new List<Contact>();
        for(Account objConAcc : lstAccountTrigger)
        {
            if(objConAcc.Comma_Separated_Values__c != mapOldAccount.get(objConAcc.id).Comma_Separated_Values__c)
            {
                setAccId.add(objConAcc.id);
            }
        }
        
        for(Contact objCon : [Select Id, Name, AccountId, FirstName, LastName, Phone, Email, Description From Contact Where AccountId in : setAccId])
        {
            if(mapContactComparison!=null && mapContactComparison.containsKey(objCon.AccountId))
            {
                List<Contact> conList = mapContactComparison.get(objCon.AccountId);
                conList.add(objCon);
                mapContactComparison.put(objCon.AccountId, conList);
            }
            else
                mapContactComparison.put(objCon.AccountId, new List<Contact>{objCon});
        System.debug('>>>>>>>>81'+mapContactComparison.get(objCon.AccountId));
        }
        System.debug('>>>>>>>>83'+mapContactComparison.keySet());
        List<String> lstString = new List<String>();
        
        for(Account objAccountCon : lstAccountTrigger)
        {  
            Integer i =0;
            lstContact = new List<Contact>();
            if(objAccountCon.Comma_Separated_Values__c != null)
                lstString =  objAccountCon.Comma_Separated_Values__c.split(',');
            if(mapContactComparison != null && mapContactComparison.containsKey(objAccountCon.Id))
            {
                for(Contact objCon : mapContactComparison.get(objAccountCon.id))
                { 
                    if(lstString.size() == 0)
                    {
                       if(mapContactComparison.containsKey(objCon.AccountId))
                            mapUniqueContact.put(objCon.Name,objCon); 
                    }
                    if(lstString.size()>i)
                    {
                        System.debug('>>>103'+lstString[i]);
                        System.debug('Name Contains : '+lstString[i].contains(' ')); 
                        if(lstString[i].contains(' '))
                        {
                            strFirstName = lstString[i].substringBefore(' ');
                            strLastName = lstString[i].substringAfter(' ');
                        }
                        else
                        {
                            strFirstName = '';
                            strLastName = lstString[i];
                        }
                        
                        objCon.LastName = strLastName;
                        objCon.FirstName = strFirstName;
                        strName = objCon.FirstName+' '+ objCon.LastName;
                        lstContact.add(objCon);
                        System.debug('>>>>>>>119'+lstContact);
                        System.debug('>>>>>>>120'+mapContactComparison.get(objCon.AccountId));
                        if(mapContactComparison.containsKey(objCon.AccountId))
                            mapUniqueContact.put(strname,objCon);
                        System.debug('>>>>>>>>122'+mapUniqueContact.get(strname));
                        System.debug('>>>>>>>>123'+mapUniqueContact.keySet());
                    }
                    i+=1;
                }
            }
        }
        System.debug('>>>>>>>>1325'+lstContact);
        for(String objCont : mapUniqueContact.keySet())
        {
            System.debug('>>>>>>>>>>>>>131'+objCont);
            System.debug('>>>>>>>>>132'+lstContact.contains(mapUniqueContact.get(objCont)));
            if(!lstContact.contains(mapUniqueContact.get(objCont)))
                lstContact.add(mapUniqueContact.get(objCont));
        }
        System.debug('List of Contact Under An Account'+lstContact);
        if(lstContact.size()>0)
        {
            update lstContact;
        }
        for(Contact objConToDelete : lstContact)
        {
            System.debug('>>>>>>>>>143'+objConToDelete.Name);
            if(!lstString.contains(objConToDelete.Name))
            {  
                if(!lstContactToDelete.contains(objConToDelete))
                { 
                    System.debug('>>>>>>>>>>>>>148'+objConToDelete.Name);
                    lstContactToDelete.add(objConToDelete);
                }    
            }
        }
        if(lstContactToDelete.size()==0 && lstContact.size()==0)
        {
            System.debug('>>>>>>>>>>55');
            for(Contact str : mapUniqueContact.values())
            {
                System.debug('>>>>>>>>>>158');
                lstContactToDelete.add(str);
            }
        }
        if(lstContactToDelete.size()>0)
        {
            System.debug('delete List'+lstContactToDelete);
            delete lstContactToDelete;
        }
    }
}

he account  comma separated field with same values then the total number of time the values are come is update on Contact field i.e. Number of Occurences. Please Help

On update please Insert following values on account comma separated field: Amit,Dharmesh,Amit,Ankit,Amit. and test.

So the no of occurrence contains on Amit Contact is 3 and if I update the value with Amit,Dharmesh,Amit,Amit,Amit then the Ankit name of contact will be deleted and under Amit account there is no of occurences field value updated by 3 to 4 and only 2 accounts will remains i.e. Amit and Dharmesh.
Hi  All, I want group record by the  field named Shipment_Status__c  as attached.  I get the error "only aggregate expressions use field aliasing"
Here the controller
public class ContainerGlobalShipmentController{
public Map<String, List<Container__c>> Records { get; set; }
public ContainerGlobalShipmentController() {
 Records = new Map<String, List<Container__c>>();
 Container__c [] results =
[SELECT  Shipment_Status__c status, Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,
Brocker__c,Comments__c,     ID_Container__c,  Consignee__c, Provenance__c
 FROM Container__c WHERE (Departed_to_Wharf_Date__c = NULL OR 
 (Departed_to_Wharf_Date__c =LAST_N_DAYS:5))   
 AND Provenance__c ='FFP FLORIDA'];
 
  for(Container__c result: results) {
     status = (String)result.get('status');
    if(!Records.containsKey(status)) {
      Records.put(status, new Container__c[0]);
    }
    Records.get(status).add(result);
  }
}
}

User-added image