Activity Forums Salesforce® Discussions Is There Any Way To Control The Sequence Of Execution Of These Triggers? Reply To: Is There Any Way To Control The Sequence Of Execution Of These Triggers?

  • shariq

    Member
    September 20, 2018 at 10:36 pm

    Hi,
    Trigger example -

    trigger Duplicate Name on Contact (before insert, before update)
    {
    set<String> lastName = new set<String>();
    set<String> setname = new set<String>();
    for(Contact con : Trigger.new)
    {
    lastName.add(con.email);
    }
    for(Contact con : [select lastName from contact where email in : lastName])
    {
    setname.add(con.lastName);
    }
    if(Trigger.isInsert||Trigger.isUpdate)
    for(contact a:trigger.new)
    {
    if(setname.contains(a.lastName))
    {
    a.lastName.adderror('This email already exists');
    }
    }
    }

    Hope this helps.