I am trying to update user's reach profile attributes with below apps script. It is updating all fields except only addresses. Kindly suggest if I am missing anything. Below is the part of code:
var resource = {
organizations:
[{title: designation,
department: department,
}],
addresses: [
{
locality: "Pune",
streetAddress:"Kothrud",
postalCode:"411038",
primary:true,
region:"Maharashtra",
type: "work",
}
],
phones: [{
type: "work",
value: phone,
},
{
type: "mobile",
value: mobile,
},
{
customType: "Extension",
value: land_line,
},
{
customType:"Middle Name",
value: middle,
}],
}
var result = AdminDirectory.Users.update(resource, email_address)
Instead of update you could try result = AdminDirectory.Users.patch(resource, userId);
API link for your reference here.
Hope that helps!
Related
How to add or set value for "Department" field in google contacts?
No problems with "Company" and "Job title"
var contact = ContactsApp.createContact('John', 'Doe', 'john.doe#example.com');
var company_set = contact.addCompany('Google', 'Product Manager');
// ?????
var department_set = contact.add______________('IT');
UPD: Thanks to #TheMaster I've managed to solve this task.
Nice API example you can find here https://www.any-api.com/googleapis_com/people/docs/people/people_people_createContact
Using the examle on this site you can build required body for API.
var reqBody = {
names: [
{
givenName: givenName,
familyName: familyName
}
],
phoneNumbers: phoneNumbers,
organizations: [
{
title: orgTitle,
department: orgDepartment
}
],
emailAddresses: [
{
value: emailAddres,
type: 'work'
}
],
addresses: [
{
city: city,
streetAddress: streetAddress,
type: 'work'
}
],
memberships: [
{
contactGroupMembership: {
contactGroupId: contactGroupsID,
contactGroupResourceName: "contactGroups/" + contactGroupsID
}
}
]
}
createContact(reqBody);
It is possible to set department through People API with Advanced Google services. When a contact is created through the api, the people object can include organizations[].department
I have been using the ng2-smart-table template. I could not able to found the location where the data save after click the add new button.some one can help me now.
In this table create data and show in the list the data what we are created. but the case is if we are refresh the browser , the above mentioned data not saved. then what should i do for add those data for firestore.
The DataSource of the mentioned module is simply an array or LocalDataSource object according to Documentation.
Let's take an example.
On typescript file define an array like this.
data = [
{
id: 1,
name: "Leanne Graham",
username: "Bret",
email: "Sincere#april.biz"
},
{
id: 2,
name: "Ervin Howell",
username: "Antonette",
email: "Shanna#melissa.tv"
},
// ... list of items
{
id: 11,
name: "Nicholas DuBuque",
username: "Nicholas.Stanton",
email: "Rey.Padberg#rosamond.biz"
}
];
settings = {
columns: {
id: {
title: 'ID'
},
name: {
title: 'Full Name'
},
username: {
title: 'User Name'
},
email: {
title: 'Email'
}
},
add:{
confirmCreate:true
},
mode:'inline'
};
On template(html).
<ng2-smart-table (createConfirm)="addData($event)" [settings]="settings"
[source]="data"></ng2-smart-table>
Again on template.
addData(event){
//event.data is the newely created data
// Handle newly created data
// Shape of object is {
// id,
// name,
// username,
// email,
// }
// You must call event.confirm.resolve() to show data on table
}
Above addData(event) function is called when click ctrate confim.
I have this JSON FILE
{
"_id": "GgCRguT8Ky8e4zxqF",
"services": {
"emails": [
{
"address": "Abunae#naa.com",
"verified": false,
"verifiedMail": "Toto#hotmail.com"
}
],
"profile": {
"name": "Janis"
},
"pushIds": []
}
I want to update my verifiedMail field but couldn't figure out how to do it in Meteor, it's always returning me an error
let VerifiedEmail = "Exemple1"
await Meteor.users.update({ _id: user._id }, { $set: { 'emails.verifiedEmail': emailRefactor} }, { upsert: true })
Couldn't figure out how to access the emails.verifiedEmail field
Tried this exemlpe worked like a charm
let VerifiedEmail = "Exemple1"
await Meteor.users.update({ _id: user._id }, { $set: { 'profile.name': emailRefactor} }, { upsert: true })
but couldn't figure out how to access emails.verifiedEmail .
Could you please help me ?
Emails is an array, while profile is an object. You have to access the first object of the email array instead
This updates the exact email address from emails
Meteor.users.update({
"emails.address": emailRefactor
}, {
$set: {
"emails.$.verified": true
}
});
Or update the first element
Meteor.users.update({
_id: user._id,
"emails.address": emailRefactor
}, {
$set: {
"emails.0.verified": true
}
});
You're trying to set verifiedEmail while the actual field is verifiedMail.
I want to remove proxies fields like __initializer__: null,__cloner__: null, __isInitialized__: true, from my returned json but I have no idea.
I dont want to use * #Serializer\Exclude() because there are some more fields next to those fields.
here is a sample json:
emails: [
{
id: 1,
subject: "Mrs. Astrid Wuckert",
body: "Excepturi.",
sendCopy: false,
roles: [
{
__initializer__: null,
__cloner__: null,
__isInitialized__: true,
name: "ROLE_ADMIN"
},
{
name: "ROLE_RESELLER"
},
{
name: "ROLE_RETAILER"
},
{
name: "ROLE_CLUB_SHOP"
}
]
},
]
Thanks in advance.
Try call ignoring fields while creating normalizer:
$normalilzer->setIgnoredAttributes(["__initializer__", "__cloner__","__isInitialized__"]);
I'm programming a function in order to update users' info. I did it and it works fine however it doesn't work when I want to use custom schemas. I checked the reference but it showed an error "Invalid Input: [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;
}
What's the error?
Greetings, Thanks in advance.
The employmentData field is inside the "customSchemas" field. Custom schemas have to be defined before using them.
To create a Custom Schema you have to use the resource Schemas.insert.
After creating the schema with the correspondent fields and type of value (STRING, INT, ETC) your code should run without issues. I tried it and worked for me.
Also, after updating the user, when making the call to Users.get, you have to set the parameter "projection=full" in order to see these values in the response.