NewPath-Consulting/warm

Return a proper list of admin roles for contacts object

Opened this issue · 2 comments

Reference to enhancement request

The administrator role end point needs to have a comma delimited list, in alphabetical order of all admin roles granted.

Currently the admin role is assigned a hard coded value for administrator (full access) no matter what the admin roles are.

Here's an example structure that should be flattened into an alphabetical sorted string delimited with commas.

{ "FieldName": "Administrator role", "Value": [ { "Id": 2, "Label": "Membership manager" }, { "Id": 4, "Label": "Event manager" }, { "Id": 16, "Label": "Restricted website editor" }, { "Id": 32, "Label": "Newsletter manager" }, { "Id": 64, "Label": "Online store manager" } ], "SystemCode": "AdminRole" }

Could use this array Walker

case "Groupparticipation":
                var result = "";
                member.FieldValues.forEach(function(e) {
                  if (e.SystemCode === "Groups") {
                    var values = e.Value;
                    for (var j = 0; j < values.length; j++) {
                      var value = values[j].Label;
                      result += (value || null) + ", ";
                    }
                  }
                });
                row.push(result.substring(0, result.length - 2));
                break;

Use this code snippet to create comma separated string

var arrayObjects = [
  {
    property1: "A",
    property2: "1"
  },
  {
    property1: "B",
    property2: "2"
  },
  {
    property1: "C",
    property2: "3"
  }
];

Array.prototype.map.call(arrayObjects, function(item) { return item.property1; }).join(",");