Uncaught ScriptError: Invalid argument: EVENT_HANGOUT - javascript

This error is received when I try to update a calendar event's title and description. The strange thing is it works on one calendar and not on the other.
Here is a code example
function makeAppointment(eventID, person, calendarID){
Logger.log("eventID:", eventID);
Logger.log("userFolder: " + person);
Logger.log("calendarID: " + calendarID);
var userFolder = findFolder(person);
var calendar = CalendarApp.getCalendarById(calendarID);
var event = calendar.getEventSeriesById(eventID);
var appointments = getAppointments(true, calendarID);
try {
event.setTitle("Interviewee: " + person);
event.setDescription(userFolder.getUrl());
return appointments;
}
catch(e){
Logger.log("There was an issue with setting interview");
}
return appointments;
}
The makeAppointment function is called from the java script side where the relevant information is passed in. But it throws an error on the client side browser console image attached. There are 59 events present on the calendar that creates this issue and 2 on the one that doesn't, I find that to be the only difference between the two.
Thanks for any help provided in solving this issue

The issue was with the type of event. When creating an event, if there is a video call option present for that event, it will throw an error when updating. Removing the video call option will resolve the issue.

Related

response.getselectedbutton() is not a function?

I am in school and trying to code a google apps script where I have a function bound to a doc with a custom menu that can create a new doc with the date, subject, and email it to the teacher of said subject. All was going according to plan until I decided to make it so that if I hit cancel instead of OK in one of the parameters I would get the default value of that parameter if I had not hit edit parameters so I could easily only change 1 or 2 things. The function works spotlessly, but now what's happening is I can't get the selected button for the alert that asks me if I want to edit parameters.
It just says
"TypeError: response.getSelectedButton is not a function"
and won't let me run my function. Here's my code for the function. This has worked fine for me in the past and I'm really not sure why it doesn't work now.
function Mathdoc() { var ui = DocumentApp.getUi();
var d = new Date();
var s = (d.getDate()) + '/' + (d.getMonth()+1) + '/' + d.getFullYear();
console.log(s);
var response = ui.alert( 'Change parameters?', ui.ButtonSet.YES_NO);
if (response.getSelectedButton() == ui.Button.YES) { insert all my other code here}
Is there a glitch or something I'm missing? I'm new to JS and fairly new to web design altogether.
There is no method named getSelectedButton(). The ui.alert() just returns the button and nothing else
function Mathdoc() {
var ui=DocumentApp.getUi();
var d = new Date();
var s = (d.getDate()) + '/' + (d.getMonth()+1) + '/' + d.getFullYear();
console.log(s);
var response=ui.alert( 'Change parameters?', ui.ButtonSet.YES_NO);
if (response==ui.Button.YES) { insert all my other code here}
Look at example here
Nope, this function doesn't exist. Basically if you type a function on google and don't find anything, it means the function doesn't exist
EDIT : If you have an error message that says it doesn't exist, it means that the function really doesn't exist or that the library containing the function is missing. But in your case the function doesn't exist

updating date via C# or JavaScript causes following error

I have recently discovered that when I update any date in Lightswitch HTML, whether it be in C# or JavaScript, that it causes the application to display this message:
if i comment out anything that changes the date then this does not appear.. so my question is has anyone else come across this problem and if so, what is the fix?
some examples of code that causes the error:
JS - Executed on a custom Save button
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 0);
if (screen.OrderRequest.changedate == null) {
screen.OrderRequest.changedate = tomorrow;
}
C# executed on either the inserting or updating method
partial void OrderRequests_Updating(OrderRequest entity) {
entity.changedate = DateTime.Now;
}
JS - executed in the beforeApplyChanges also causes same error:
myapp.OrderScreenView.beforeApplyChanges = function (screen) {
screen.OrderRequest.changedate = Date.now();
};
It is possible that your custom save button is causing the problem. Any chance you could implement the beforeApplyChanges event and handle any updates there?

Creating SharePoint Site with JavaScript

I am attempting to use JSOM to create a sub-site (web) on button-click. The function is working - in so far as a site is created with the given configuration. However, despite the fact that a site is indeed being create, the ExecuteQueryAsync call always routes to the failure function. The relevant code is below:
var ctx = SP.ClientContext.get_current();
var web = ctx.get_web();
var webCreationInfo = new SP.WebCreationInformation();
webCreationInfo.set_title(portalName); //note: this variable is defined elsewhere
webCreationInfo.set_description('');
webCreationInfo.set_language(1033);
webCreationInfo.set_url(webUrl); //note: this variable is defined elsewhere
webCreationInfo.set_useSamePermissionsAsParentSite(false);
webCreationInfo.set_webTemplate(templateGuid); //note: this variable is defined elsewhere
web.get_webs().add(webCreationInfo);
web.update();
ctx.load(web);
ctx.executeQueryAsync(
function() {
alert("Created Site");
},
function(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
);
This includes a couple variables that are defined elsewhere in my code, but this should not be a part of my problem. The site is properly created, using the correct template, name, and URL.
The 'Request failed' alert is always what pops up for me, despite the site being created correctly. The value of args.get_message() is "Unexpected response from server" and the value of args.get_stackTrace() is 'null'.
The issue here was actually due to the button and not the above code. I needed to add 'event.preventDefault();' to the start of my onClick function. Otherwise, the page attempts to refresh - which happens much faster than the site can be provisioned.

Error handling "Out of Memory Exception" in browser?

I am debugging a javascript/html5 web app that uses a lot of memory. Occasionally I get an error message in the console window saying
"uncaught exception: out of memory".
Is there a way for me to gracefully handle this error inside the app?
Ultimately I need to re-write parts of this to prevent this from happening in the first place.
You should calclulate size of your localStorage,
window.localStorage is full
as a solution is to try to add something
var localStorageSpace = function(){
var allStrings = '';
for(var key in window.localStorage){
if(window.localStorage.hasOwnProperty(key)){
allStrings += window.localStorage[key];
}
}
return allStrings ? 3 + ((allStrings.length*16)/(8*1024)) + ' KB' : 'Empty (0 KB)';
};
var storageIsFull = function () {
var size = localStorageSpace(); // old size
// try to add data
var er;
try {
window.localStorage.setItem("test-size", "1");
} catch(er) {}
// check if data added
var isFull = (size === localStorageSpace());
window.localStorage.removeItem("test-size");
return isFull;
}
I also got the same error message recently when working on a project having lots of JS and sending Json, but the solution which I found was to update input type="submit" attribute to input type="button". I know there are limitations of using input type="button"..> and the solution looks weird, but if your application has ajax with JS,Json data, you can give it a try. Thanks.
Faced the same problem in Firefox then later I came to know I was trying to reload a HTML page even before setting up some data into local-storage inside if loop. So you need to take care of that one and also check somewhere ID is repeating or not.
But same thing was working great in Chrome. Maybe Chrome is more Intelligent.

Windows 8 Javascript apps multiple Message alerts

In my application, I need to display multiple message popups. However it doesn't work. It can be illustrated by the simple code below:
function alert(title, content) {
try {
var msg = new Windows.UI.Popups.MessageDialog(content, title);
msg.showAsync();
}
catch (err) {
}
}
I have a server side method which invokes this alert, at times I may have multiple alerts. There I get the following error:
WinRTError: Access is denied.
Hence only 1 alert is shown and the second one goes in the catch.
How to achieve multiple alerts from a windows 8 app?
I think you have to use Toast Notification Here is the code sample.
other wise you should chaining the message from server side. means first store particular messages in array then display one by one. and delete which message is displayed.
You can use promises to display popups..
like
var msg = new Windows.UI.Popups.MessageDialog(content, title);
var msg1 = new Windows.UI.Popups.MessageDialog(content, title);
var msg2 = new Windows.UI.Popups.MessageDialog(content, title);
msg.showAsync().then(function(){
return msg1.showAsync();
}).then(function(){
return msg2.showAsync();
});

Categories

Resources