Newer Version Available

This content describes an older version of this product. View Latest

Get Change Information by Querying the SourceMember Object

Source tracking gives you a list of changes, but what if you want to know more about a specific change? To answer questions like “Who made this change?” and “What are all the changes Sarah made?”, query the SourceMember object.

For example, see a list of changed components and who last changed them by running a query like this from the CLI (where DevSandbox is the username or alias of your sandbox).

1sfdx force:data:soql:query -q "SELECT MemberName, MemberType, ChangedBy, RevisionCounter FROM SourceMember" -t -u DevSandbox

The query returns a list of components. The CHANGEDBY column returns the user ID of the person who last changed the component.

1MEMBERNAME                   MEMBERTYPE    CHANGEDBY        REVISIONCOUNTER
2───────────────────────────  ────────────  ───────────────  ───────────────
3Account.MyTextField__c       CustomField   0056g000000FDuZ  1
4Contact.MyField__c           CustomField   0056g000000FDuZ  11
5Admin                        Profile       0051k000002KW4R  54
6MyObj1__c-MyObj1 Layout      Layout        0051k000002KW4R  55
7Account-Account Layout       Layout        0056g000000FDuZ  33
8Contact-Contact Layout       Layout        0056g000000FDuZ  45
9MyObj1__c                    CustomObject  0051k000002KW4R  57
10TVRemoteControl              ApexClass     0056g000000FDuZ  53

A second query maps the IDs from CHANGEDBY to usernames

1sfdx force:data:soql:query -q "SELECT Id,Username,Name FROM User" -u MyDevSandbox

And the result is similar to:

1ID                  USERNAME                   NAME
2──────────────────  ────────────────────────   ────────────
30051k000002KW4RAAW  dev2@example.com.devsb1    Dev2
40056g000000FDuZAAW  admin@example.com.devsb1   Admin User