0

I just created an Apex Trigger on the Apex object. The trigger works great in salesforce classic but does not work in the new lightning experience. Any guidance would be fantastic please ??? Here is my code :

Trigger taskbeforeInsert on Task (before insert) {
set<id> ctcids= new set<id> ();

    for(task t:   trigger.new){
        ctcids.add(t.WhoId );
    }
    Map<ID, contact> m = new Map<ID, contact>([ select accountID ,id from contact where id in :ctcids ]);
    for(task t:   trigger.new){
        if( t.WhoId!= null){

            if (m.containsKey(t.WhoId)) {
               t.whatID = m.get(t.WhoId).accountID  ;
            }
        }

    }
}
2
  • 1
    Trigger has nothing to do with lightning experience. Check if DML is happening or not when the UI is lightning.
    – Ashwani
    Commented Feb 2, 2017 at 9:45
  • Triggers are supported both in Classic and Lightning Exp , more over its a back end process. Please validate it using step by step approach. Commented Feb 2, 2017 at 10:00

1 Answer 1

1

Wouldn't expect to see any difference in Lightning Experience.

Perhaps more importantly, this trigger is dangerous in that it affects all Tasks created in an org. That is OK if the org is only every used by one set of users for one purpose. But most orgs over time get used for more things and by different types of users and have 3rd party apps added. Forcing the Task.WhatId as this trigger is doing is likely to break those.

This sort of logic is best applied to a narrowed case e.g for specific profile Users or for Tasks attached to a specific WhatId SObjectType.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .