Google Groups API wrong output - javascript

In Google Script Project I have 2 Google-API functions that should give out the same output.
can somebody please explain to me what I am wrong with, or maybe is it a bug in the API?
I have a group with 904 members.
Function "listMembersOfGroup1" is using the "GroupsManager" API, and is working correctly. the Logger displais "904.0".
And here is the code:
function listMembersOfGroup1() {
var group = GroupsManager.getGroup("group#domain.com");
var members = group.getAllMembers();
Logger.log(members.length);
}
But function "listMembersOfGroup2", which is using the "GroupsApp" API, is not working correctly (as far I understand). the Logger displais "753.0".
And here is the code:
function listMembersOfGroup2() {
var group = GroupsApp.getGroupByEmail("group#domain.com");
var users = group.getUsers();
Logger.log(users.length);
}
Is there any good reason why the "GroupApp" API gives out a different number?
Thanks in advance for your help.
.
(This is my first question on my first day on this site, I hope my question follows the rules.)

Welcome to StackOverflow. Your post was well explained.
The first API GroupsManager is used by domain administrators to manage their domain groups Check Here.
The secong one GroupsApp is used to manage google groups Google Groups API.
Your second call is retrieving users that belongs to the google groups mail passed as URL. Check full documentation here
So you're working with different google products.

Related

Google places API automatically get place from a string

In my Page I'm querying my backend to get an address and placing that address in my input.
Now using Jquery I get that input value and want to get the place from google places api.
//placing value from parameter my input
var pickup = $state.params.bookingInfo.address;
$("#address").val(pickup);
//Calling for places
autocomplete = new.google.maps.places.Autocomplete(document.getElementById("address"));
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var place = autocomplete.getPlace();
console.log(place);
});
Here I'm getting places as undefined as there is no event in the map.
All I need is how do I get the place with the address i get from my query?
Thanks in advance.
See the official Google dev docs and source sample found here:
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
In your case, you can embed this code in as is; tweak the CSS in the head (for example hide the map if it isn't needed); copy the sample code and plugin your key and do some live editing until you figure out how to make it work best with your existing page; first try it as-is just to ensure it's working properly; after you can begin modding it to fit your needs. I was in your situation before actually, I found the source above to be the most helpful in getting the place details callback. Hope it helps you as well.

google spreedsheets & URI.js

I'm traying to use http://medialize.github.io/URI.js/ to get a url form a cell in my google spreedsheet without the query part.
original url http://test.com/file.php?this=1&that=2 --> from this url i like to get http://test.com/file.php
following this site http://googleappscripting.com/working-with-urls/ i added the example code in my spreedsheet and i can get to functions to work like:
function urlPath(url){
return URI(url).path()
}
to get the url as i need, i created another function following :the documents here http://medialize.github.io/URI.js/
eval(UrlFetchApp.fetch('https://rawgit.com/medialize/URI.js/gh-pages/src/URI.js').getContentText());
function url_whitout(url){
return URI(url).search("")
}
but i get an error : TypeError: undefined is not a valid argument for URI
Any ideas how i can get this to work?
thanks
This is not a URI.js issue, it is a Google Apps Script issue. You need to get the url into the function first.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getActiveSheet().getRange(1,1).getValue();
The getRange() function has several different versions so choose wisely Range Docs
You have to get the value into the function for it to read it.
As a side note I recommend using the function
Logger.log(url);
to clarify what you are doing after you run the function.

Custom Tab in the Field Service Schedule Board

I found this blog: http://www.powerobjects.com/2016/08/01/advanced-customizations-for-the-custom-tab-in-the-field-service-schedule-board/#collapse2
In it the author describes using configuration to create a new tab in the Field Services Schedule Board by pointing it to a CRM web resource.
The blog includes the following javascript:
function updateBooking()
{
var entityRecordGuid = "10B8A40B-D499-E611-80E6-A45D36FC5A4C";
// GUID is hardcoded to make the sample code easier to understand.
// We can extend this customization to be able to extract the selected booking IDs
// from the SChedule Board's DOM, but that is out of scope for now
var bookableResourceBooking = new XrmServiceToolkit.Soap.BusinessEntity("bookableresourcebooking", entityRecordGuid);
bookableResourceBooking.attributes["cus_urgency"] = document.getElementById('UrgencyInput').value;
bookableResourceBooking.attributes["cus_notes"] = document.getElementById('NoteInput').value;
var updateResponse = XrmServiceToolkit.Soap.Update(bookableResourceBooking);
if (updateResponse == "") { // clear fields if synced to crm
document.getElementById('UrgencyInput').value = "";
document.getElementById('NoteInput').value = "";
} else {
alert('Data didn't sync to CRM');
}
}
The problem that I've got is that I'm not sure how to get the entityRecordGuid value dynamically.
There doesn't seem to be a way of configuring the web resource to
have the selected Item as part of the querystring
There seem to be undocumented JavaScript libraries for Field
Services; however, I can't access them from the web resource IFrame
and of course, they're undocumented.
Has anyone else tried to do this? I'm using CRM Online
I ended up doing this by scraping the HTML directly rather than trying to use any of the API methods from Field One.
This wasn't really a satisfactory answer for me. It depends on the Unscheduled Orders board being in a certain order and since this is changeable by the end-user my solution is very fragile.
For anyone else looking, I did manage to find these API methods; however, I couldn't find any documentation for them so assume that they are unsupported. I also couldn't tie them together to achieve what I wanted
// get the id of the sub grid
F1SDK.SchedulerPage.UnscheduledOrdersGrid.id
// -> "UnscheduledGrid"
F1SDK.SchedulerPage.UnscheduledOrdersGrid.getItemId()
// -> "UnscheduledGrid"
F1SDK.SchedulerPage.UnscheduledOrdersGrid.getStore().storeId
// -> "UnscheduledWorkOrders"
F1SDK.SchedulerPage.UnscheduledOrdersGrid.getStore().data.items[0].internalId
F1SDK.SchedulerPage.UnscheduledOrdersGrid.selModel.selected.items[0].internalId
// Get a subgrid
FieldOneSkyUtils.Subgrid.GetSubgrid('id')
F1SDK.data.models.WorkOrder.getFields()
F1SDK.data.models.WorkOrder.getIdByWONumber('00106')
// -> {55caa97d-429a-e611-80e6-c4346bc4bef0}

Facebook Graph API - Tagged Places in version 2.0

I used the Graph API with javascript to fetch all of my data contained locations in v1.0.
( I used FB.api("/v1.0/me/locations", function (response) { ... }); )
I know that the updated version is 2.2 and the "locations" node is replaced by "tagged_places" node in v2.0 and above.
I also use the Graph API Explorer to test my results.
I try this, GET: /v2.2/me?fields=tagged_places
and the results are exactly what I want.
However, in my js code, I try: FB.api("/v2.2/me?fields=tagged_places", function (response) { ... });
and there is NO any results!
Besides,
I set version: 'v2.2' in Parse.FacebookUtils.init();
I also ask the permissions :user_tagged_places,user_photos,user_status,user_friends,user_about_me,user_birthday,read_stream in Parse.FacebookUtils.logIn();
I need almost all of the data of my checkins(a.k.a locations in v1.0/tagged_places in v2.0) to add into my database.
I try to fetch /me/photos, but the results are not satisfied. So I still need to use maybe this: FB.api("/v2.2/me?fields=tagged_places", function (response) { ... });
So... can anyone help me? please....
I went through permissions in groups testing them out and I figured out what the problem was.
You need to have the permission of the item you were tagged in.
So in my case I was tagged in photos, so I needed user_photos permission to gain access to user_tagged_places. It actually creates quite an issue because you need to know how a user was tagged to retrieve their tagged_places.
If a user was tagged at a place in a post you need a different permission than if they were tagged in a photo.

How to programmatically subscribe a user to a google calendar using javascript?

Hey i'm able to authenticate and authorize a user with the javascript API for google calendar. what i want to do next is subscribe that user to a public calendar. I was thinking i could just call the google.gdata.calendar.CalendarEntry constructor with the id of the calendar but that didn't work
var entry = google.gdata.calendar.CalendarEntry("idOfCalendar");
i also tried creating an instance of a entry id with google.gdata.atom.Id("idOfCalendar"); and adding that to the CalendarEntry constructor. Using the set methods didn't work either.
I use the InsertEntry method to add the entry but i get the following error
Error: Valid calendar id must be supplied for adding calendar to favorites list in allcalendars projection.
I can access the events of this calendar using google.gdata.calendar.CalendarEventQuery()
The google api for javascript doesn't give a lot of examples anyone know the answer to my problem or a good resource for working with the google calendar api? do you think i should be using php or jason instead?
** Edit
I found an example of what I want in the Java Api link so i tried
function addSubscriptionToCalendar() {
var feedUri = "http://www.google.com/calendar/feeds/default/allcalendars/full";
var calendarEntry = new google.gdata.calendar.CalendarEntry();
calendarEntry.setId("nhl_21_%54oronto+%4daple+%4ceafs#sports#group.v.calendar.google.com");
calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError);
}
but i got the same error
You should be using owncalendars feed to modify/add calendar entry for the authenticated user not allcalendars.
Sounds like your calendar id is invalid. The id from your second example appears to be URL encoded. Try using the decoded value:
nhl_21_Toronto Maple Leafs#sports#group.v.calendar.google.com
The gdata API for calendars has been switched off; the new way to do this is via: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert

Categories

Resources