I've been able to successfully add a contact via the API but I can't delete contacts that I've created.
https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/shared-contacts
function deletecontact()
{
SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken ());
var contacts = SharedContactsApp.getContactById('5c8b05ab8c9f68c6');
SharedContactsApp.deleteContact('5c8b05ab8c9f68c6');
}
I get the following error message:
TypeError: Cannot call method "getElements" of undefined. (line 200, file "Code", project "SharedContactsApp")
How to remove this error?
Additionally...
I've tried to set a Job Title using the code below but get the following error:
ReferenceError:"profile" is not defined. (line 142, file "Code")
function changeJobTitle2()
{
SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken ());
var contact = SharedContactsApp.getContactById('82f05968956d66f');
profile.setJobTitle('Google Apps Expert');
}
I figured it out.
function hailmary()
{
SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken());
var contact = SharedContactsApp.getContactById('82f05968956d66f');
SharedContactsApp.deleteContact(contact)
}
Related
When I am trying to update my modal in my slack app it is giving this error message: Error returned when the given view_id or external_id doesn't exist.
This is my code of updating the modal, help me what is going wrong here or if something is missing:
if (userAction.getType().equalsIgnoreCase("view_submission")) {
log.info("inside view_submission..");
List<LayoutBlock> message = new ArrayList();
ButtonElement buttonElement = ButtonElement.builder()
.actionId("submit")
.value("submit")
.text(PlainTextObject.builder().text("submit").build()).build();
message.add(SectionBlock.builder()
.accessory(buttonElement)
.text(MarkdownTextObject.builder().text("hey this is my updated modal").build()).build());
ViewTitle viewTitle = ViewTitle.builder()
.text("Header for 2nd modal")
.type("plain_text")
.emoji(true).build();
ViewSubmit viewSubmit = ViewSubmit.builder()
.text("Submit")
.type("plain_text").build();
View view = View.builder()
.type("modal")
.callbackId("second_view")
.title(viewTitle)
.submit(viewSubmit)
.blocks(message).build();
ViewsUpdateRequest viewsUpdateRequest = ViewsUpdateRequest.builder()
.viewId(userAction.getViewModel().getId())
.hash(userAction.getViewModel().getHash())
.view(view)
.token(botToken).build();
slackhelperService.sendViews(viewsUpdateRequest, botToken);
return;
}
I have viewed all the articles on here, and haven't done any javascript coding in the past. Hoping someone can help me.
I have a class called rank and of course the parse _User class. I have added a pointer to the _User class to the rank class (the column name is called user_rank, which allows me to give a user a rank - seems simple enough.
What I am trying to achieve, is to use Cloud Code to change a user's rank as the administrator of the app (so it's something I do in my admin app, not the user does in their app).
This is what I have, but all I get is an error 101 'Object not found'. I have no doubt I am doing this all wrong, but I have tried to piece together responses from other posts with no success.
Any help is greatly appreciated.
Updated code with Davi's change below - now throwing error schema mismatch for _User.user_rank; expected Pointer but got String
Parse.Cloud.define("setUserRank", async (request, response) => {
let { userObjectId, rankObjectId } = request.params;
const userQuery = new Parse.Query(Parse.User);
const rankQuery = new Parse.Query('rank');
// Get the user object to change the rank of
try{
let user = await userQuery.get(userObjectId, { useMasterKey: true});
let rank = await rankQuery.get(rankObjectId, { useMasterKey: true});
console.log(user);
console.log("Running");
const rankRelation = user.relation('user_rank');
rankRelation.add(user_rank);
user.save(null, { useMasterKey: true});
return ("User Rank Changed"));
} catch (err) {
throw new Error(err.message)
}
});
I think the problem happens because of this line:
const rankQuery = new Parse.Query(Parse.rank);
In the case of you custom classes, you need to pass the class name as a string:
const rankQuery = new Parse.Query('rank');
I have a basic installable trigger I am trying to use to send an email invite based on when a Sheet is edited (a specific checkbox is selected in my case) however when I try and access the range or source object from my event object I get [object Object] and undefined respectively. However I know the event object is working thanks to being able get the oldValue, value, triggerUid, and user.
function onEditCheck(e) {
var cells = e.range.getA1Notation();
var name = e.source.getActiveSheet().getName()
console.log('cells: ' + cells);
console.log('sheet name: ' + name);
console.log('id: ' + e.triggerUid);
console.log('edit: ' + e.value);
if(e.oldValue === 'false' && e.value === 'TRUE') {
sendEmail(e.user.getEmail(), e.range);
}
}
The only other reference to this issue I could find was this question here however I have had no luck with the permissions "solution" they found.
Any help or insight would be appreciated.
This is because necessary authorization wasn't granted to your script.
Add this somewhere in your code:
//SpreadsheetApp.getActive()
This will trigger the oAuth flow and request the permission to access Spreadsheets, which was missing.
Related:
IssueTracker
User response missing on Form submit
This worked for me:
function createTrigger(){
var tr=ScriptApp.newTrigger('onEditCheck').forSpreadsheet('My SSID').onEdit().create();
}
function onEditCheck(e) {
var cell = e.range.getA1Notation();
var name = e.range.getSheet().getName();
var data=Utilities.formatString('<br />Cell Edited: %s<br />Name of Sheet: %s<br />TriggerId: %s<br />Value: %s<br />Old Value: %s<br />',cell,name,e.triggerUid,e.value,e.oldValue);
var userInterface=HtmlService.createHtmlOutput(data);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'Testing')
}
By the way it's really handy to go to the trigger editor after creating the trigger and set notifications to immediate. That way you'll get notifications to failures pretty fast from Google Server.
Using the JavaScript SDK, what kind of object would be returned on the following query:
var groupQuery = new Parse.Query('some_valid_class');
var group = groupQuery.get('some_valid_object_id');
console.log(group);
I only see [object Object] in the log.
thanks!
On Cloud Code - You can't print objects directly as we usually does in console of browser.
You have to use console.log(JSON.stringify(yourObject))
Although the documentation doesn't say so, I believe the get method returns a Promise. Here is an example for getting the actual object taken from the documentation:
var query = new Parse.Query(MyClass);
query.get(myId, {
success: function(object) {
// object is an instance of Parse.Object.
},
error: function(object, error) {
// error is an instance of Parse.Error.
}
});
In the success-function a Parse.Object is provided.
You can find all the info at the Parse JavaScript SDK & Cloud Code Reference
Specific Parse.Query.get() documentation here: https://parse.com/docs/js/symbols/Parse.Query.html#get
As facebook just released it's new sdk for Unity. I m trying to use FB.API method and getting a lot of troubles with it. Like this is code I have written in UnityScript in my Unity project.
function LoginCallback() {
Debug.Log("User id is"+ FB.UserId);
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, LogCallback, null);
FBUtil.Log(FB.UserId); // Use this to sync progress, etc.
}
function LogCallback(response:String) {
// Debug.Log(response);
var profile = FBUtil.DeserializeJSONProfile(response);
var friends = FBUtil.DeserializeJSONFriends(response);
}
I am getting this error in Unity Log
BCE0005: Unknown identifier: 'FBUtil'.
And if I comment out the FBUtil part and just try to print the json string by writing this
function LoginCallback() {
Debug.Log("User id is"+ FB.UserId);
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, LogCallback, null);
}
function LogCallback(response:String) {
Debug.Log(response);
}
I am able to get Fb.UserId but I am not getting the response with the following details like first_name, friends. The error in DDMS Log is this
"09-04 21:35:04.534: E/Unity(23893): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)
"
Someone help me out.