You need to sign in to do that
Don't have an account?

Help with update trigger
Dear All,
Here is my trigger. I want to update "Deactivated on" text field everytime Opportunty "Active" field changes to False. Trigger works fine but the issue is that it runs everytime Inactive user record is updated. I only want this trigger to run when user changes from True to False. Can someone please help?
Here is my trigger. I want to update "Deactivated on" text field everytime Opportunty "Active" field changes to False. Trigger works fine but the issue is that it runs everytime Inactive user record is updated. I only want this trigger to run when user changes from True to False. Can someone please help?
trigger DeactivateDate on User (before update) { String deastat = 'User license is deactivated on '; User us = [select Name from user where id=:userinfo.getuserid()]; string username = us.Name; for (User u : Trigger.new) { DateTime dt = u.LastModifieddate; String formattedDt = dt.format('MM-dd-yyyy @ hh:mm:ss'); if (u.IsActive == False){ u.Deactivated_On__c = deastat + formattedDt + ' by ' + username; } } }
Try with below code
Let me know if it helps !!
Thanks
Manoj
All Answers
Try with below code
Let me know if it helps !!
Thanks
Manoj