Skip to main content
Hi All,

I have one text field. I wnat to insert that field with owner name using Apex or Trigger. Can any one suggest me.

Thanks,

Sarma
2 answers
  1. Feb 4, 2019, 8:37 AM
    Hi Sarma,

     

    trigger on case(before Insert) {

    if(Trigger.isBefore && Trigger.isInsert) {

    TriggerHandler.handleBeforeInsert(Trigger.new);

    }

    }

    public class TriggerHandler {

    public static void handleBeforeInsert(List<Case> newCaseList) {

    Set<String> caseIdSet = new Set<String>();

    for(Case newCase : newCaseList) {

    caseIdSet.add(newCase.OwnerId);

    }

    // Create a map of String with Owner

    // Loop over the newCaseList

    and assign newCase.TextField = map.get(key).Name;

    }

    }

    But let me tell you it can be done via config using formula field of text type.

    Hope it helps. If it does, close it by marking it as solved.

    Thanks