function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vanitha ManiVanitha Mani 

urgent help on apex triggers in case object

Hi,

I have a case trigger.when creating a case based on the value given in these fields I need to autopopulate two other fields.

Account--user entered
Product--user entered
system-user entered
Environment --user entered

We need to autopopulate 
ticket.productbuild =
Ticket.system version=

these vales comes from
svc-product-build is another object with lookup account .
User-added image
this is the account where installed product name value should diplay in product build and installed system should get display in system version ..
where this table comes from svc product build object with account as a lookup.
for example if environment given as production in case and product as ABS in case it should lookup this table for tat account entered while creating a case..it should match and autopopulate value in those fields
Need to fetch values of product build and system version from svc product build object with account as a lookup.

It's very challenging. Can anyone help with this autopopulation of fields

can anyone help me with this trigger
AbhishekAbhishek (Salesforce Developers) 
/* Note that this is just a working code. However, you might need to modify this code in order to make it appropriate for your use or make it bulkified.

trigger copyAccountMemberinContact1 on Case(before insert, before update) {

    List < Id > newOrUpdatedCases = new List < Id > ();
    List < account > acclist = new List < account > ();
    list <case> casesToBeUpdated = new List <case>();

    for (case c: trigger.new) {
         newOrUpdatedCases.add(c.AccountId);
        casesToBeUpdated.add(c);
    }

    acclist = [Select AccountMember__c from Account where Id in : newOrUpdatedCases];

    System.Debug('newOrUpdatedCases' + newOrUpdatedCases);  
    System.debug('acclist ' + acclist);

    for (integer i = 0; i < casesToBeUpdated.size(); i++) {
        casesToBeUpdated[i].Contact1__c = acclist[i].AccountMember__c;
    }
}


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.