1

Has anyone have success of using SSJS filters to exclude data that contains a particular string?

I am trying to get a list of Marketing Cloud users that the AccountUser.Name doesn't contain the word 'user'.

Sadly,notExistsInString and notContains only for the DataFilter. I got the following error when I used it

StatusError: "notExistsInString" is not a valid SimpleOperator for a retrieve Filter.

var filterNotAppUser = {
    Property: "Name",
    SimpleOperator: "notExistsInString",
    Value: "user"
};

var prox = new Script.Util.WSProxy();
var cols = ["ID", "Name", "Email","ActiveFlag"];
var myUsers = prox.retrieve("AccountUser", cols, filterNotAppUser);
Write("Status" + myUsers.Status);
1

It looks like you are trying to exclude installed packages (when you create an installed package, it creates a user). I would use the following code, as app users don't have an email address, but an email is required for other users (and isNotNull is not a valid operator for filtering objects, so we can't use that).

var filterNotAppUser = {
    Property: "Email",
    SimpleOperator: "like",
    Value: "%@%"
};

var prox = new Script.Util.WSProxy();
var cols = ["ID", "Name", "Email","ActiveFlag",];
var myUsers = prox.retrieve("AccountUser", cols, filterNotAppUser);
Write(Stringify(myUsers));
1
  • 1
    Hi Eliot. Thanks for your reply. Yes, my goal was to exclude the app users. I tried the filter you mentioned (Email LIKE '%@%' together with ActiveFlag as complex filter), it still returned a handful of "app users", which I think they were created by some sort of legacy process. I guessed I can add another filter to exclude these "app users" by user names and emails.
    – Eliott
    Mar 15 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.