CRM 2011 | Trigger Silverlight function from Javascript Form - javascript

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.

Related

doc.pageWindowRect and doc.media are undefined in Adobe Acrobat Javascript

I'm using the Javascript API built-in to the Adobe Acrobat products, and trying to access the doc.pageWindowRect attribute.
I originally found that doc.pageWindowRect was undefined whenever I tried to access it, and through various posts on the AdobeUsers forum, found that I needed to activate the media extension first, by running something like console.println(this.media);
Normally this prints a result like: [object DocMedia]
However, on some computers used by our client, this just prints undefined instead. It seems that having this.media remain undefined means that doc.pageWindowRect will stay undefined too.
Does anyone know how to make sure this.media is defined, and thus enable doc.pageWindowRect? Or any other way of getting hold of the doc.pageWindowRect information?
I wondered if there might be a delay in activating the media extension (a suggestion I found online), and have tried repeatedly running code to display this.media and doc.pageWindowRect using app.setInterval, but even after waiting for a couple of minutes, they are still not defined.
Any suggestions would be greatly appreciated.
It seems that having this.media remain undefined means that
doc.pageWindowRect will stay undefined too.
Does anyone know how to [...] enable doc.pageWindowRect?
pageWindowRect belongs to the multimedia.api plugin. In Acrobat 9 and possibly other versions, this plugin is not by default loaded.
From what I can find in that scenario, one method for loading the multimedia.api plugin is to actually have media in the PDF file.
Default location for this plugin is: %Program Files%\Adobe\Reader 11.0\Reader\plug_ins\Multimedia.api
This might not be the fixing answer, but I hope the suggestion gives some insight. Good luck!

what does utag.DB mean?

I am stumped on figuring out what this means..
utag.DB
I am seeing it in a web page via the console. And I'm trying to figure out what it means. Any pointers are useful.
utag.db is a Tealium function for debugging. It is similar to console.log(which is non standard). It is enabled via a cookie that's set.
Caught you!!
You are curious about utag means you have implemented or trying to implement Tealium data layer in your portal.
Basically utag.db is used to debug tealium functionalities related to utag files. As rightly mentioned by #webanalyticsdood, it should be used instead of non standard console.log
That's fine but how do I and why should I use it?
Simple, set utag cookie to true in your developer console using following command
document.cookie="utagdb=true";
Let's try with following command,
utag.data
Whatever data you are passing on to tealium will be found inside utag.data. If you can't read your data based on conditional events, it won't be sent to Teamium, better go back and correct your code. Let's try another one.
utag.id
it will return id you've set for synching with tealium,
You can explore more similar stuff inside utag.js
PS: would suggest you to add tealium tag in your question.

SharePoint 2013 Calendar getSelector is undefined in IE

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

sitefinity 6 - events module error javascript

I've upgraded a website from 4.4 to 6.0 and found some issues. Some I already solved but I keep getting one error (javascript I suppose) on events module. When I try to preview/create new/publish/save draft I get the following js error:
TypeError: startDate is null
Unable to get property 'getFullYear' of undefined or null reference
Telerik.Web.UI.WebResource.axd, line 329 character 1
var range=this.get_rangeView().getRange();
var time=this.get_timeView().getRange();
var startDateTime=new Date(time.get_start());
var endDateTime=new Date(time.get_start());
var startDate=range.get_start();
var endDate=range.get_recursUntil();
startDateTime.setFullYear(startDate.getFullYear(),startDate.getMonth(),startDate.getDate());
I reckon that this is dynamically created by Telerik sitefinity and I'm not sure how to fix it. I went to the administration area and checked the relevant configurations and it seems to be everything ok (similar configs as sitefinity 4.4).
Does anyone have an idea how to solve this? I've tried to post a sitefinity forum thread on their website but they took way to much time to answer.
Cheers
by any chance were you using external templates or a custom widget to show the events?
Sitefinity 6.0 apparently rebuilt the events module and it is no longer a simple, flat type. Instead it is a nested (hierarchical) type, with a parent calendar to which events are added (or multiple calendars if you need them).
So if you did any custom code or external template to display the content (in other words anything not out of the box that auto-upgraded itself when you updated to 6.0) you may need to rebuild this custom component to use the latest changes.
Consult the upgrade guide to 6.0 for latest breaking changes that one had the most differences, then compare your custom templates (if any) to the widget templates in the SDK: http://selarom.net/blog/2012/11/06/mapping-sitefinity-templates-from-the-sdk
I hope this is helpful!

How to access controls from a console

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();

Categories

Resources