2

I have a custom checkbox field.

I need to know how to identify the last user that changed the custom checkbox field by using an apex code.

Is it possible? If so, how?

0

You can also create a new custom field, type = lookup to User, and set value to that lookup field only when somebody will be editing Your custom checkbox. That can be easily done in trigger, let me know if You need support with that.

It is not as straightforward solution like Adrian Larson gave to You, but Yu can save SOQL with that approach. Everyting depends what You need.

  • You can't add custom fields to the CustomField object... – Adrian Larson Mar 29 '18 at 12:58
  • @AdrianLarson sorry if I was not clear enough, I had on mind creating new custom field next to the custom checkbox mentioned by lemdev, on the same SObject. Not creating a custom field on CustomField object. Eg having fields: Custom_Checkbox__c and User_Who_Last_Time_Edited_Custom_Checkbox__c, and check in trigger if value from Trigger.new != Trigger.old for that field, and then just assign current user Id to User_Who_Last_Time_Edited_Custom_Checkbox__c. Hope I am clear now. – patryk Mar 30 '18 at 16:49
3

Just query for it.

List<CustomField> fields = [
    SELECT DeveloperName, LastModifiedBy.Name, LastModifiedDate
    FROM CustomField WHERE ...
];
  • This code snippet gaves me error: Compile failure on line 1, column 1: Invalid type: CustomField. – patryk Mar 30 '18 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.