I have a SharePoint 2013 publishing website with a calendar web part. I want the calendar to be a group calendar, but SharePoint doesn't retain default users for the calendar. So I've been using a method to populate the calendar when the page loads. It's described in detail here: http://blogs.technet.com/b/meamcs/archive/2013/04/10/sharepoint-group-calendar-adding-default-users.aspx.
This works in Chrome, Opera, Safari, and FireFox, but not IE (I've tested 5 through 11 using IE's emulator)
The method described in the link gets a context id from the calendar html tags and uses SharePoint's JavaScript library to load the extra users from predefined XML.
I loaded the XML from a file on the server. The HTML for the web part looks like:
<div id="ctl00_ctl43_g_cc24db55_d224_4ea9_b770_4c2edd2c083e_ctl01_ctl00_ctl00" class="ms-acal-rootdiv" ctxid="WPQ3">...</div>
The ctxid is used to reference the calendar. However, in IE, the ctxid property isn't there! So, I use the previous element to get the ctxid instead:
<div class="ms-acal-error" id="WPQ3_err" style="display:none"></div>
Here's my code for loading the users into the calendar:
ExecuteOrDelayUntilScriptLoaded(function(){
var ctxid;
if ( $(".ms-acal-rootdiv").attr("ctxid") ){
ctxid = $(".ms-acal-rootdiv").attr("ctxid");
}
else if ( $(".ms-acal-error").attr("id") ){
ctxid = $(".ms-acal-error").attr("id").replace("_err","");
}
SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1,ctxid).selectEntities(xml,true);
},"sp.ribbon.js");
IE throws an error: "Unable to get property 'selectEntities' of undefined or null reference", and IE does return undefined for getSelector(1,ctxid). I've also tried hard-coding the value for ctxid with no success.
I've been looking on Google for a couple of hours now and haven't found any solutions. Most blogs that describe this process, have comments from other users asking about this issue but no one has answered those questions.
What could be the problem?
Not sure if this constitutes an "answer" and I am unsure if this will help others but it seems that the problem is fixed!
So the problem seems to have resolved itself after I fixed another issue: IE was also throwing the error:
Sys.ArgumentException: Value does not fall within the expected range. Parameter name: serverRelativeUrl sp.runtime.js
Everything else continued to work on the page, so I initially continued focusing on the problem at hand. Today I decided to focus on the Sys.ArgumentException error instead: In my code, some subsites required information from a list in its parent site. To get the site collection URL, I used SharePoint's L_MenuBase_Url variable. However, I found that the Sys.ArgumentException error was thrown because the L_MenuBase_Url variable (set by SharePoint) was empty ("").
This, somehow, was caused by SharePoint executing this code:
angular.element("#home_content").scope()._init()
before the scope finished loading (I think). As I was working to fix the error above I didn't see this error:
Object doesn't support property or method '_init'
So I logged the out put of
angular.element("#home_content").scope()
and, sure enough, it returned undefined. This error was not occurring in any other browser...Anyway, once I ensured that scope() was defined, by using a timer and waiting for scope() to not be undefined, before executing _init() everything worked (including the calendar and the L_Menu_BaseUrl variable.
I probably should have fixed the other two errors before asking the question. Sorry about that!
Thanks for the help though
Related
Safari isn't rendering my single page application built in VueJS.
I have spent 2 weeks developing it. It contains components that show or not depending on user clicks. And data objects that are rendered via the "v-for" element.
In chrome all works perfectly!! In mozilla also...in safari the list doesn't show up. Why isn't safari rendering anything?? I can't even debug it..
I looked up work arounds, like polyfills...but these seem to not be supported by safari..so there's no point in implementing them.
Would love some support or insights guys..if there's no work around does that mean i have to go back a build it in JS + Jquery?
Thanks in advance
So, I had this same issue. Meaning, a series of components listed with a v-for but not rendered on the screen (or the DOM) only in Safari (on Mac) even though it worked just fine on Firefox and Chrome (even on Mac). And after long and hard attempts, I was able to resolve the issue. I will give the answer in two parts.
THE QUICK ANSWER
In my case, the render error was the end result of a date conversion gone wrong somewhere deep in my code in a helper file. Indeed, in this file, I was receiving an ISO date in string format and transforming it into a JS date object through new Date(myISODateString). While Firefox and Chrome handle this conversion just fine, Safari was producing 'Invalid Date' errors and the chain-reaction was only effecting a single component. Once I corrected this date parsing, everything was being rendered correctly in Safari. In this instance, I used Luxon to do the conversion, I will give that as the solution
DateTime.fromISO(myISODateString, { setZone: true }).toJSDate();
THE LONG ANSWER
I think what is even more valuable in this experience is how I found out that this was the problem since in your case, it will probably be some other particularity of Safari that is causing the error.
It was actually Frank Provost's comment on this question that guided me in the right direction.
It goes without saying that smaller components are most of the time constructed from their props. It is like their life source. If props are erroneous, internal operations and render will also be problematic.
So I decided to console, within the lifecycle hooks, the props that my non-rendering component was receiving. Of course, nothing was printed out to the console. So I went up one level above and did the same thing for the props of the parent component. This time, I was getting information in the console but there were variations in what is being printed to the console between Firefox and Safari.
By the way, the props were not filled in at created or mounted in my case since they depended on an asynchronous network operation. So, my console debugging looked like this;
created(){
setInterval(() => {
console.log(this.myProp);
}, 5000, this);
}
Long story short, by going up this way, component to component, variable to variable, I found out that I was relying on this date provided by my helper function in a helper file outside of my components and this was why no error was logged to the console at runtime even though multiple components were not being rendered correctly.
I am working on CRM 2011 online.
I have a form and added a Silverlight web-resource to it.
And when a lookup value changes, I need to trigger/invoke a Silverlight function.
I followed this guide exactly and a few other guides with same concept but still not able to run it properly due to this statement:
silverlightPlugin.Content.interactionObject.FormAttributeChanged(attName, attValue);
I used the IE debugger and found the the Content property is always undefined.
Why it's undefined ?
Has anyone came across this before?
I will answer my own question:
The problem was that I was referencing the HTML page instead of the .XAP.
After debugging the Content property was set.
I tried to execute the following command from the console.
var subject = Xrm.Page.ui.controls.get("subject");
That's the exact syntax I'm using in the web resource that I'm plugging in to CRM. However, I only got an error message saying that "unable to get property 'controls' of undefined or null reference".
I do understand the message. What I want to know is two-fold.
What syntax will work from the console (F12) to refer to the stuff on the screen?
Why doesn't it work the way I did? Where doesn ui come from?
I've checked that I can refer to both Xrm and Crm.Page but apparently ui is null (it's listed when I print out the contents of Page but sett to null).
I know this is a kinda old thread, but if you still getting that 'object doesn't support property..' error when executing the command from console, IE F12; try calling it from the frame i.e
frames[0].Xrm.Page.getAttribute("controlId").getValue();
In CRM 2013 it is a little different
frames[1].Xrm.Page
It's kind of tough to detect the frames across different browsers, so this little javascript can help you out:
for(var i=0;i<5;i++) //loop through 0 to 4
if(frames[i].Xrm.Page.ui != undefined) //check if undefined
{
Xrm = frames[i].Xrm; //assign Xrm
console.info("~: Xrm updated with frame " + i + " :~"); //show info
break; //breakout the loop
}
What it does ?
What it's basically doing is to loop through 0-5 to find frame where
Xrm.Page.ui is not undefined, once it gets it it assigns it to the Xrm and breaks the loop.
How to use ?
To use it just copy/paste and run in the browser console once per
session then after you can run/test all your Xrm codes form the browser console.
This works for me Xrm.Page.getControl("controlId"). It's just a shortcut for what you have already though...cant-disable-set-to-read-only-protect-gray-out-etc-a-field
In addition to what #Daryl said, I can add that I use different syntax. For some reason, I don't get his to work either. Might have to do with different browser version or something. Instead try to execute this, if you still can't get it to work (although I must admit that his is shorter = better).
Xrm.Page.getAttribute("lastname").getValue();
The lastname parts is tested a minute ago on creation of an instance of entity Contact. I just put in a breakpoint inside a script that is executed onchange and while broken-pointed, I entered the command above to the console.
If neither approach works for you, you've got some weird problem with your CRM or browser.
A reason some people need this information is to access their own code. If you need to access your own methods from the console, in 2011, any global methods (or namespaces) in your javascript were also in forms[0]. Obviously, this is a bad idea, just from a naming standpoint. In forms v6+ any global objects or functions are in an object called customScriptsFrame inside frames[0] (or presumably whichever frame the Xrm is found).
frames[0].customScriptsFrame.myFunctionName();
I'm working with Dynamics CRM 2011 Online and trying to refactor some code that works on the Quote > Add Product page to also work on Order > Add Product. The problem is that when the page loads I get the error "Unable to get property 'getValue' of undefined or null reference."
I went into the IE console (tried both IE 9 and 10) and typed in what I believed to be the offending line:
Xrm.Page.getAttribute('ati_clin').getValue()
It complains with "Object doesn't support property or method 'getAttribute'". I also tried
document.getElementById('ati_clin')
but that too fails.
This doesn't make sense to me because I can use the HTML view of the developer console to find the object on the page and it's clearly there (no typo too). It also doesn't make sense that this statement fails in the console on both pages even though one of the pages runs properly at runtime and the other doesn't. Shouldn't it at least work on the page that does work at runtime?
After doing some research I think the following posting is the most relevant but I'm afraid it doesn't lead me to an answer seeing as how new I am to this: Xrm.Page.data is null
My question is why does the console return this error if the element clearly exists?
A handy trick when debugging a problem like this:
The Xrm.Page object lives in the context of a frame. If you want to use console in IE Developer tools without having to break in debug mode, you first have to point to the frame on the page.
Example:
frames[0].Xrm.Page.getAttribute('ati_clin').getValue()
I'm getting the following error in IE 6:
Line: 454
Char: 13
Error: Invalid Argument
Code: 0
URL: xxxxx/Iframe1.aspx
and I can't for the life of me find what's causing this.
This only happens in a situation where I have a main page that has several IFrames, and it only happens when I have one particular IFrame (the one pointed to by the URL in the error message), and that IFrame is invisible at the time of loading.
I've narrowed it up to there, but I still can't find anything more specific...
The IFrame in question doesn't have 454 lines in its HTML, nor do any of the JS files referred by it.
I tried attaching VS to iexplore.exe as a debugger, and it breaks when the error occurs, but then tells me "There is no source code available for the current location"...
Any suggestions on how I can go about chasing this one?
UPDATE: I found this problem through brute-force, basically, commenting everything out and uncommenting randomly...
But the question still stands: what is the rational way to find where the error is, when IE reports the wrong line number / file?
IE's Javascript engine is disgusting when it comes to debugging. You can try enabling script debugging in the Advanced Options, and then if you have Visual Studio installed it will jump to the place of error... if you're lucky. Other times you don't get anything, especially if the code was eval()'ed.
Another thing about these line numbers is that it doesn't reflect which file the error is happening in. I've had cases where the line number was actually correct, but it was in a linked .js file, not the main file.
Try using the Microsoft Script Debugger or DebugBar (http://www.debugbar.com) which may give you some better IE6 debugging tools. They always help me with IE6.
Also, does this happen in any newer versions of IE or just in IE6?
It's virtually impossible to debug this without a live example, but one thing that often causes an "Invalid Argument" error in Internet Explorer is trying to set an incorrect value for a style property.
So something like:
document.getElementById("foo").style.borderWidth = bar + "px";
when "bar" has the value null, or undefined, or is the string "grandma", will cause it, as "grandmapx" isn't a valid value for the borderWidth style property.
IE9 has a browser mode.
Open up Developer Tools, then select the version you want to emulate in the console, reload the page with errors, and the console will show you line numbers and the correct file where the error is.
I run into this problem a lot too, and I've also resorted to commenting everything out until I find the problem. One thing that I find to be useful is to add a try/catch block to every javascript method. Sometimes I add an alert to tell what method the error came from. Still tedious, but easier than trial and error commenting. And if you add them every time you write a new method it saves a lot of time in the event errors like those occur.
function TestMethod()
{
try
{
//whatever
}
catch (ex)
{
ShowError(ex.description);
//alert("TestMethod");
}
}
A note to other readers: I recently had this "Invalid argument." error reported in IE7-9 and eventually found that it was down to the way I was using setTimeout/setInterval.
This is wrong, in IE:
var Thing = {};
Thing.myFunc = function() { ... };
setTimeout(Thing.myFunc, 1000);
Instead, wrap the callback in an anonymous function like so:
var Thing = {};
Thing.myFunc = function() { ... };
setTimeout(function() { Thing.myFunc(); }, 1000);
and no more "invalid argument" errors.
Another possibility:
I do a lot of dev between two computers, at home and at work, so I often email myself or download pages from the server to work on. Recently I realised that Vista has a habit of unilaterally applying blocks to certain files when they are downloaded in certain ways, without notifying me that it is doing this.
The result is that, for example, an HTML page wants to access the .js file in its header, but it doesn't have permission to access local files. In this case, it doesn't matter what you write in the .js file, the browser will never even read it, and an irksome Line: 0 error will result.
So before you comb your code for an error, check your HTML page's properties, and see if it hasn't been blocked by the OS....
Like NickFitz pointed out, styling was an issue with my code.
document.getElementById('sums<%= event.id %>').style.border='1px solid #3b3b3b;'
I removed the border style and my IE issues were gone.