proxy.resetClientIds
Reset the Business Unit context previously set by setClientId — subsequent operations target the script's own BU again.
proxy.resetClientIds() clears any Business Unit context set by a previous proxy.setClientId() call. After resetting, all WSProxy operations target the BU the script is running in.
Syntax
proxy.resetClientIds();
Parameters
None.
Return Value
undefined.
Examples
Switch BU, then reset
var proxy = new Script.Util.WSProxy();
// Target child BU
proxy.setClientId({ ID: 123456 });
var childResult = proxy.retrieve("DataExtension", ["Name", "CustomerKey"]);
// Restore own BU context before continuing
proxy.resetClientIds();
var ownResult = proxy.retrieve("DataExtension", ["Name", "CustomerKey"]);
Iterate over multiple BUs, then restore context
var proxy = new Script.Util.WSProxy();
var businessUnits = [
{ name: "US", mid: 111111 },
{ name: "EU", mid: 222222 }
];
for (var i = 0; i < businessUnits.length; i++) {
proxy.setClientId({ ID: businessUnits[i].mid });
var result = proxy.retrieve("DataExtension", ["Name"]);
Write(businessUnits[i].name + ": " + result.Results.length + " DEs<br>");
}
// Always reset after iterating to avoid unintended cross-BU side effects
proxy.resetClientIds();
Notes
Call resetClientIds() after finishing any cross-BU operations. Leaving the client ID set for the remainder of a script’s execution can cause later WSProxy calls to target the wrong BU.