我正在编写一个函数来更新用户的信息。我做了它并且它工作正常但是当我想使用自定义模式时它不起作用。我检查了reference,但显示错误“无效输入:[employmentData]”
function directoryUpdate(userId, userDept, userLocation, userPhone,userTitle) {
var userId = 'devtest@pruebatest.com',userDept='D003', userLocation='L003';
var userTitle='T003';
var update = {
ims:
[{
type: "work",
protocol: "gtalk",
im: "liz_im@talk.example.com",
primary: true
}],
emails: [
{
address: "liz@example.com",
type: "home",
customType: "",
primary: true
}
],
addresses:
[{
type: "home",
customType: "",
streetAddress: "1600 Amphitheatre Parkway",
locality: "Mountain View",
region: "CA",
postalCode: "94043"
}
],
organizations:
[{
name: "Next Step",
title: userTitle,
primary: true,
type: "work",
department: userDept,
location: userLocation
}],
customSchemas: {
employmentData: {
employeeNumber: "123456789",
jobFamily: "Engineering",
location: "Atlanta",
jobLevel: 8,
projects: [
{ value: "GeneGnome", customType: "development" },
{ value: "Panopticon", customType: "support" }
]
}
}
};
update = AdminDirectory.Users.patch(update, userId);
Logger.log('User %s updated with result %s.', userId, update)
return true;
}
错误是什么?
问候,提前致谢。
答案 0 :(得分:1)
employmentData字段位于" customSchemas"领域。在使用之前必须定义自定义模式。 要创建自定义架构,您必须使用资源Schemas.insert。
使用对应的字段和值类型(STRING,INT,ETC)创建模式后,您的代码应该运行没有问题。我尝试过并为我工作。
此外,在更新用户后,在调用Users.get时,您必须设置参数" projection = full"为了在响应中看到这些值。