Posts Tagged ‘javascript’
Chrome 37 breaks CRM 2011 and 2013 functionality
Google has removed a number of APIs from Chrome 37 which is causing a lot of issues with CRM 2011 and CRM 2013. So far I’ve noticed: –
- You can no longer add options to Option Set fields via customisation
- Changes made to an email in a workflow are not saved when the save button is clicked
- The ‘Upload’ button on the SharePoint list component no longer works
- Anything using the ‘window.showModalDialog’ function no longer works as the API has been deprecated
- Can no longer save field properties such as ‘Visible by default’
- Export to Excel no longer works
In order to fix the problem until Microsoft issue a real fix, you can re-enable the deprecated features by following the below: – Read the rest of this entry »
Login Prompt When Opening Web Resource From Outlook
I’ve been experiencing an issue since the launch of CRM 2011 (online and IFD). Opening a Silverlight web resource in a new window from the Outlook client causes the user to see a login prompt rather than the web resource.
Other people have been reporting the same problem in the CRM forums both here and here, but none of the proposed solutions seemed to work for me. I had to advise users to log into CRM from Internet Explorer and leave it minimised to get around the problem.
When Microsoft introduced CRM 2011 Update Rollup 8, they also introduced a number of new Xrm.Utility JavaScript functions. Xrm.Utility.openWebResource jumped out at me as a possible fix to the login prompt issue. You can read more about the new functions on the Microsoft Dynamics CRM blog.
The JavaScript I had been using to launch my web resource from the ribbon button was: –
window.open("/WebResources/cnova_XRM_CV_SearchPage.html#/VacancyID/" + idString);
Note: idString is the guid of the record I am clicking the button from. Read the rest of this entry »
Add a CRM Calendar to a dashboard
Dashboards in Dynamics CRM 2011 are a great way to visualize data. Did you know that they can also be used to view pretty much any other web content?
I’ve recently had a requirement to add the CRM Calendar to a dashboard. I could have simply added a list of appointment activities to the dashboard, but the actual calendar control looks a lot nicer.
To do this, first we need to get the URL of the Calendar page. Load up the IE developer tools (F12 in IE9) and start a profiler. Now navigate to the calendar in CRM and click on ‘Month’, ‘Week’ and ‘Day’ (we want the URL for each page).
Stop the profiler and take a look at the results
As you can see, we’ve got the URLs of the 3 calendar views needed for the dashboard. The URL seems to contain a parameter for the current date in ISO8601 format (YYYY-MM-DDThh:mm:ss). We’ll have to deal with that inside of our web resource.
Set age based on date of birth
I had a requirement to set an ‘Age’ attribute based on the contents of the Date of Birth field on Contacts. The below script in the On Save, On Load or On Change will do this.
Note: You will need to change the “birthdate” and “new_age” field names to the relavant fields on your form.
CRM 2011
function calcBirthday() { if(Xrm.Page.getAttribute("birthdate").getValue() != null) { var now = new Date(); //get today's date var birthday = Xrm.Page.getAttribute("birthdate").getValue(); //get the dob value var diff = now.getMonth() - birthday.getMonth(); //have they had their birthday already this year? var age; //use to store age if (diff == 0) //if birthday is this month, compare the days instead { diff = now.getDate() - birthday.getDate(); } if(diff > -1) //if they've had a birthday this year { age = now.getFullYear() - birthday.getFullYear(); } else //if they have not had a birthday yet this year { age = now.getFullYear() - birthday.getFullYear() - 1; } Xrm.Page.getAttribute("new_age").setValue(age.toString()); //set the new_age attribute } }
CRM 4
function calcBirthday(){ if(crmForm.all.birthdate.DataValue != null) { var now = new Date(); //get today's date var birthday = crmForm.all.birthdate.DataValue; //get the dob value var diff = now.getMonth() - birthday.getMonth(); //have they had their birthday already this year? if (diff == 0) //if birthday is this month, compare the days instead { diff = now.getDate() - birthday.getDate(); } if(diff > -1) //if they've had a birthday this year { var bd1 = now.getFullYear() - birthday.getFullYear(); crmForm.all.new_age.DataValue =bd1.toString(); //set the new_age attribute } else //if they have not had a birthday yet this year { var bd2 = now.getFullYear() - birthday.getFullYear() - 1; crmForm.all.new_age.DataValue =bd2.toString(); } } }
IE8 crashing when using picklists in Advanced Finds
I’ve been having an issue where IE8 would crash when trying to use picklists in advanced finds (see below example).
It may not be a common issue, but I posted it on the MS partner forums and got the below response which has fixed it for me, so hopefully it will help someone else out too!
Edit AdvFind.aspx and add the following code. AdvFind.aspx can be found in the CRM web directoryAdvancedFind
NOTE: The code needs to be added right below function window.onload(){
<% if (Request.Params["AutoRun"] != "False") { %> if (location.href.indexOf("?") > 0) location.href = location.href + "&AutoRun=False"; else location.href = location.href + "?AutoRun=False"; <% } %>
View originating lead notes on a contact
Our sales guys wanted a way to view originating lead notes against the Contacts created from Leads. I added a new tab to the contact containing an Iframe and used the below javascript to display the notes from the originating lead.
var lookupItem = new Array; //set the lookup to the originating lead lookupItem = crmForm.originatingleadid.DataValue; if (lookupItem != null) { //display the originating lead notes in the iframe 'IFRAME_LeadNotes' crmForm.all.IFRAME_LeadNotes.src="/_controls/notes/notesdata.aspx?id="+ lookupItem[0].id + "&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false"; } else { //if there is no originating lead, hide the tab crmForm.all.IFRAME_LeadNotes.src="about:blank"; tab7Tab.style.display = "none"; }
Hide tabs and disable fields based on user roles
The below is a way to hide a tab to everyone not in the Account Manager and System Administrator roles. There’s also a slightly less polished method to disable fields to everyone not in the System Administrator role.
You should be able to copy and paste the below script into your OnLoad event and change the bottom 2 lines of code to specify the tab you want to hide. It wil then hide it from everyone not in the roles specified. You’ll also have to change the attribute names which you want to disable in the HideField function.
Google Maps in CRM
I wanted a quick way of viewing an Account’s location so I created a link to Google maps based on the postcode of the Account.
First of all, create an nvarchar/URL attribute called new_googlemaps, stick it somewhere on your Account form and then put the below javascript into the Account OnLoad event
crmForm.all.new_googlemaps.DataValue = “http://maps.google.com/maps?q=”+crmForm.all.address1_postalcode.DataValue;
It’s pretty basic but does exactly what I want. I’m going to look at embedding the actual map in an iframe when I get the chance
Edit: it turns out that Richard Knudson has covered embedding maps already on his site!