Skip to content

Instantly share code, notes, and snippets.

@jdeblank
Created April 18, 2019 14:04
Show Gist options
  • Save jdeblank/bfa99f697723d07d31f28fc812c755f4 to your computer and use it in GitHub Desktop.
Save jdeblank/bfa99f697723d07d31f28fc812c755f4 to your computer and use it in GitHub Desktop.
<script runat="server">
var skey = "abc123";
var prox = new Script.Util.WSProxy();
// query all BUs
var queryAllAccounts = true;
// set the attributes to be retrieved
// note Client.ID and not ClientID
var cols = ["Status","Client.ID"];
var filter = {
Property: "SubscriberKey",
SimpleOperator: "equals",
Value: skey
};
// WSProxy retrieve
var desc = prox.retrieve("Subscriber", cols, filter, queryAllAccounts);
if (desc.Status == "OK") {
// create array
var unsubBusinessUnits = [];
for (var i=0; i<desc.Results.length; i++) {
if (desc.Results[i].Status == "Unsubscribed") {
// add any BU MIDs to an array for no particular reason
unsubBusinessUnits.push(desc.Results[i].Client.ID);
}
}
} else {
// handle the error
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment