0

Could some please help as where I am going wrong ,i am basically trying to create new users in marketing cloud using SSJS

<script runat=server> 

    Platform.Load("Core","1"); 
    {
        var status = Account.Init("Xxxxxxxxxx");
        var targetUserKey = 'Xxxxxxxxxxb';
        var myClientID = 1234567;
        var acctUser = AccountUser.Init(targetUserKey, myClientID);

        var newUser = {
            "Name"      : "sachin",
            "UserID"    : "Sachin_POC",
            "Password"  : "Welcome@123",
            "Email"     : "sachin.m@gmail.com",
            "ClientID"  : 1234567,
            "DefaultBusinessUnitKey": "xxxxxxxxxxxx",
            "AssociatedBusinessUnits" : "xxxxxxx"
    };

    var status = acctUser.Add(newUser);
};
</script>
  • I'm not familiar with Marketing Cloud authentication, but if those GUIDs are secret values you should remove and revoke them immediately. – David Reed Jan 12 at 14:55
  • 1
    Can you be more specific on what issues you are experiencing? – Lukas Lunow Jan 14 at 10:17
  • You can delete your own question. Why have you requested we delete it for you? – Adrian Larson 7 hours ago
  • Not able to do from my side – sachin 5 hours ago
1

Ok there's a few of things that are incorrect here.

  1. The Account.Init is usually used when you're interacting with an existing object. So you'll need to remove/comment out the following line
var status = Account.Init("29C492ED-9330-4515-865E-6F5E05F4FBB5");
var targetUserKey = '4819a67f-613f-40ae-8e0b-3bcd45ede56b';
var myClientID = 1234567;
var acctUser = AccountUser.Init(targetUserKey, myClientID);
  1. AssociatedBusinessUnits is an array of Business Units, you'll need to add the Business Unit GUID within square brackets.

  2. The correct API Reference to add an AccountUser is AccountUser.Add

Try this code out, I haven't tested it myself.

var newUser = {
            "Name"      : "sachin",
            "UserID"    : "Sachin_POC",
            "Password"  : "Welcome@123",
            "Email"     : "sachin.m@gmail.com",
            "ClientID"  : 1234567,
            "DefaultBusinessUnitKey": "29C492ED-9330-4515-865E-6F5E05F4FBB5",
            "AssociatedBusinessUnits" : ["29C492ED-9330-4515-865E-6F5E05F4FBB5"]
    };

    var status = AccountUser.Add(newUser);
  • Could you please have it peer reviewed – sachin 12 hours ago
  • ametera could please have comments modified or deleted and add Xxxxxxx which I have added – sachin 11 hours ago
  • Sandeep could you please modify and. Edit your post – sachin 11 hours ago

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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