Setting G Suite user properties with App Script and the Admin SDK
I'm trying to set a user's OU from an App Script inside App Maker.
(user
is a variable with an email address)
function getUser(user)
var x = AdminDirectory.Users.update(
orgUnitPath: "/",
userKey: user,
);
console.log("function ran");
This code errors with:
Exception: Invalid number of arguments provided. Expected 2-3 only at getUser (ServerScripts:107)
Invalid number of arguments provided. Expected 2-3 only
at getUser (ServerScripts:107)
at getUser (ClientHandoff:21:21)
at TestMoveOU.Panel1.Button1.onClick:1:1
What am I doing wrong here? Looking at the docs, you only need to provide the properties you're changing.
google-apps-script google-admin-sdk google-app-maker
add a comment |
I'm trying to set a user's OU from an App Script inside App Maker.
(user
is a variable with an email address)
function getUser(user)
var x = AdminDirectory.Users.update(
orgUnitPath: "/",
userKey: user,
);
console.log("function ran");
This code errors with:
Exception: Invalid number of arguments provided. Expected 2-3 only at getUser (ServerScripts:107)
Invalid number of arguments provided. Expected 2-3 only
at getUser (ServerScripts:107)
at getUser (ClientHandoff:21:21)
at TestMoveOU.Panel1.Button1.onClick:1:1
What am I doing wrong here? Looking at the docs, you only need to provide the properties you're changing.
google-apps-script google-admin-sdk google-app-maker
add a comment |
I'm trying to set a user's OU from an App Script inside App Maker.
(user
is a variable with an email address)
function getUser(user)
var x = AdminDirectory.Users.update(
orgUnitPath: "/",
userKey: user,
);
console.log("function ran");
This code errors with:
Exception: Invalid number of arguments provided. Expected 2-3 only at getUser (ServerScripts:107)
Invalid number of arguments provided. Expected 2-3 only
at getUser (ServerScripts:107)
at getUser (ClientHandoff:21:21)
at TestMoveOU.Panel1.Button1.onClick:1:1
What am I doing wrong here? Looking at the docs, you only need to provide the properties you're changing.
google-apps-script google-admin-sdk google-app-maker
I'm trying to set a user's OU from an App Script inside App Maker.
(user
is a variable with an email address)
function getUser(user)
var x = AdminDirectory.Users.update(
orgUnitPath: "/",
userKey: user,
);
console.log("function ran");
This code errors with:
Exception: Invalid number of arguments provided. Expected 2-3 only at getUser (ServerScripts:107)
Invalid number of arguments provided. Expected 2-3 only
at getUser (ServerScripts:107)
at getUser (ClientHandoff:21:21)
at TestMoveOU.Panel1.Button1.onClick:1:1
What am I doing wrong here? Looking at the docs, you only need to provide the properties you're changing.
google-apps-script google-admin-sdk google-app-maker
google-apps-script google-admin-sdk google-app-maker
asked Nov 13 '18 at 22:41
Ian HyzyIan Hyzy
147113
147113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The Apps Script documentation says the following:
For detailed information on this service, see the reference documentation for the Admin SDK Directory API. Like all advanced services in Apps Script, the Admin SDK Directory service uses the same objects, methods, and parameters as the public API.
Therefore, we need to consult the documentation to get clarification on how to achieve this.
The method requires at least two parameters: that means that the the first parameter is a user object resource and the second parameter is the email address of the user: AdminDirectory.Users.update(resource, userKey)
. So you need to do this:
function getUser(user)
var userResource =
orgUnitPath: "/"
;
var updated = AdminDirectory.Users.update(userResource, user);
console.log(updated.primaryEmail);
So why do you need to specify the user email in the method when it is already being specified in the userResource
object? Well, the email address in the userResource
object would be the new value, in case you want to change the email address.
P.S. Perhaps you might wanna change the name of the function to something that is more of a match; updateUser()
perhaps? I hope this helps!
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to changeorgUnitPath = "/"
toorgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290593%2fsetting-g-suite-user-properties-with-app-script-and-the-admin-sdk%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Apps Script documentation says the following:
For detailed information on this service, see the reference documentation for the Admin SDK Directory API. Like all advanced services in Apps Script, the Admin SDK Directory service uses the same objects, methods, and parameters as the public API.
Therefore, we need to consult the documentation to get clarification on how to achieve this.
The method requires at least two parameters: that means that the the first parameter is a user object resource and the second parameter is the email address of the user: AdminDirectory.Users.update(resource, userKey)
. So you need to do this:
function getUser(user)
var userResource =
orgUnitPath: "/"
;
var updated = AdminDirectory.Users.update(userResource, user);
console.log(updated.primaryEmail);
So why do you need to specify the user email in the method when it is already being specified in the userResource
object? Well, the email address in the userResource
object would be the new value, in case you want to change the email address.
P.S. Perhaps you might wanna change the name of the function to something that is more of a match; updateUser()
perhaps? I hope this helps!
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to changeorgUnitPath = "/"
toorgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
add a comment |
The Apps Script documentation says the following:
For detailed information on this service, see the reference documentation for the Admin SDK Directory API. Like all advanced services in Apps Script, the Admin SDK Directory service uses the same objects, methods, and parameters as the public API.
Therefore, we need to consult the documentation to get clarification on how to achieve this.
The method requires at least two parameters: that means that the the first parameter is a user object resource and the second parameter is the email address of the user: AdminDirectory.Users.update(resource, userKey)
. So you need to do this:
function getUser(user)
var userResource =
orgUnitPath: "/"
;
var updated = AdminDirectory.Users.update(userResource, user);
console.log(updated.primaryEmail);
So why do you need to specify the user email in the method when it is already being specified in the userResource
object? Well, the email address in the userResource
object would be the new value, in case you want to change the email address.
P.S. Perhaps you might wanna change the name of the function to something that is more of a match; updateUser()
perhaps? I hope this helps!
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to changeorgUnitPath = "/"
toorgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
add a comment |
The Apps Script documentation says the following:
For detailed information on this service, see the reference documentation for the Admin SDK Directory API. Like all advanced services in Apps Script, the Admin SDK Directory service uses the same objects, methods, and parameters as the public API.
Therefore, we need to consult the documentation to get clarification on how to achieve this.
The method requires at least two parameters: that means that the the first parameter is a user object resource and the second parameter is the email address of the user: AdminDirectory.Users.update(resource, userKey)
. So you need to do this:
function getUser(user)
var userResource =
orgUnitPath: "/"
;
var updated = AdminDirectory.Users.update(userResource, user);
console.log(updated.primaryEmail);
So why do you need to specify the user email in the method when it is already being specified in the userResource
object? Well, the email address in the userResource
object would be the new value, in case you want to change the email address.
P.S. Perhaps you might wanna change the name of the function to something that is more of a match; updateUser()
perhaps? I hope this helps!
The Apps Script documentation says the following:
For detailed information on this service, see the reference documentation for the Admin SDK Directory API. Like all advanced services in Apps Script, the Admin SDK Directory service uses the same objects, methods, and parameters as the public API.
Therefore, we need to consult the documentation to get clarification on how to achieve this.
The method requires at least two parameters: that means that the the first parameter is a user object resource and the second parameter is the email address of the user: AdminDirectory.Users.update(resource, userKey)
. So you need to do this:
function getUser(user)
var userResource =
orgUnitPath: "/"
;
var updated = AdminDirectory.Users.update(userResource, user);
console.log(updated.primaryEmail);
So why do you need to specify the user email in the method when it is already being specified in the userResource
object? Well, the email address in the userResource
object would be the new value, in case you want to change the email address.
P.S. Perhaps you might wanna change the name of the function to something that is more of a match; updateUser()
perhaps? I hope this helps!
edited Nov 14 '18 at 21:52
answered Nov 13 '18 at 23:27
MorfinismoMorfinismo
2,3681719
2,3681719
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to changeorgUnitPath = "/"
toorgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
add a comment |
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to changeorgUnitPath = "/"
toorgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
This worked, and your explanation helped a lot - thanks!
– Ian Hyzy
Nov 14 '18 at 21:50
For future readers: You'll need to change
orgUnitPath = "/"
to orgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
For future readers: You'll need to change
orgUnitPath = "/"
to orgUnitPath: "/"
– Ian Hyzy
Nov 14 '18 at 21:51
1
1
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
@IanHyzy I saw that... sorry. I just edited the answer to match the above comment.
– Morfinismo
Nov 14 '18 at 21:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290593%2fsetting-g-suite-user-properties-with-app-script-and-the-admin-sdk%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown