Does anyone knows how to get the report of users along with their roles and business unit assigned in SFMC ?
2 Answers
I have half of the answer here using SSJS
<script runat="server">
Platform.Load("core","1");
var filters = { Property:'ActiveFlag',
SimpleOperator: 'equals',
Value: 'true'
};
var cols = ["ID", "Name", "Email", "ActiveFlag", "DefaultBusinessUnit", "Roles"];
var prox = new Script.Util.WSProxy();
var accUsers = prox.retrieve("AccountUser", cols, filter);
var len = accUsers.Results.length;
for ( var i = 0; i < len; i++ ) {
Write(accUsers.Results[i].Name + ', ');
Write(accUsers.Results[i].DefaultBusinessUnit + ', ');
for ( var j=0; j < accUsers.Results[i].Roles.length; j++ ) {
Write(accUsers.Results[i].Roles[j].Name + "; ")
}
Write('<br>');
}
</script>
This should give you a list of all active users and their roles if the roles are SFMC default roles. You can also extract the custom role names (Name) by retrieving the Role object similar to the code above (matching Role.CustomerKey to AccountUser.Roles[i].Name.
Unfortunately, from my understanding, AssociatedBusinessUnit[] is non-retrievable according this post and this SF document.
-
-
1When I retrieve a custom role, the Name isn't what's listed Setup -- it's "Individual role for ####" -- where #### is the AccountUserId. Is there another way to correlate it? Commented Dec 30, 2021 at 20:41
I would also suggest to take a look at Audit Trail. Not sure what is your exact use case but it might help you. We enabled it recently and through it we are tracking our user activity https://help.salesforce.com/articleView?id=mc_overview_audit_trail.htm&type=5
You can enable it through request to SF support.