Neil McDonald's Dynamics 365 Blog

Archive for the ‘CRM 4’ Category

Get past the 250 records per page limit

with one comment

Screen_shot_2010-07-18_at_17

Dynamics CRM 4 only allows users to view a maximum of 250 records per page within a view. This can be quite limiting when you need to run an on demand workflow against thousands of records.

There are 2 ways to get around this limit. The Microsoft supported solution is to use a plugin as described here. The unsupported and more risky workaround (and what I did…) is to update the organisation database directly as below.

UPDATE UserSettingsBase SET PagingLimit=1000 WHERE SystemUserId IN(Select SystemUserId from SystemUserBase WHERE FullName = 'neil mcdonald')
Screen_shot_2010-07-18_at_17.57.36.png.scaled1000

If using the SQL method, I recommend that you change it back to 250 rows or less once you’ve accomplished your tasks, as this is not supported by Microsoft and could cause errors with future updates.

Written by neilmcd

Jul 18, 2010 at 4:43 pm

Posted in CRM 4

Tagged with , ,

Set age based on date of birth

with one comment

Dob_js

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

Written by neilmcd

Jul 16, 2010 at 11:07 am

Posted in CRM 2011, CRM 4

Tagged with ,

IE8 crashing when using picklists in Advanced Finds

leave a comment »

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";
<%
}
%>

Written by neilmcd

Jul 14, 2010 at 10:05 am

CRM pop-ups in new tabs

with one comment

2crms

With Internet Explorer, you have the option to open all pop ups in a new tab rather than a new window. I find this works great for CRM, particularly when working inside different organisations. I can keep my development organisation and all pop ups in one IE instance and my live instance in another. You can find the option to do this under IEToolsInternet Options and click the Settings button under the Tabs section on the General tab.

Tabbed

Written by neilmcd

Jul 12, 2010 at 1:15 pm

Posted in CRM 4, Misc

Tagged with ,

CRM iPhone homescreen icon

leave a comment »

I sometimes like to check up on cases and activities from my iPhone and have a homescreen shortcut to our CRM mobile express site. By default, Dynamics CRM does not have an iPhone icon, so I created one for myself here. If you’d like to use it, download it, save it as apple-touch-icon.png and drop it into your CRM web root folder (mine is c:inetpubwwwroot). When you next navigate to your CRM mobile express site, add it to your homecreen and it will display a much prettier icon.

photo.PNG.scaled500/

Written by neilmcd

Jul 9, 2010 at 12:00 pm

Posted in CRM 4, Misc

Tagged with ,

View originating lead notes on a contact

leave a comment »

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";
}

Written by neilmcd

Jul 9, 2010 at 10:38 am

Posted in CRM 4

Tagged with , , ,

Hide tabs and disable fields based on user roles

leave a comment »

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.

Read the rest of this entry »

Written by neilmcd

Jul 8, 2010 at 6:58 pm

Posted in CRM 4

Tagged with , ,

Changing an Active Directory username in CRM

leave a comment »

Add_user_error

One of our users had complained that their name was spelled incorrectly. I made the changes in AD, Exchange and in her CRM user account, but when I tried to change her domain login name in CRM, I received the error ‘You are attempting to create a user with a domain logon that is already used by another user…’

To get around it, I made the change directly in the organisation database. The domain login name is stored in the ‘DomainName’ column of the ‘SystemUserBase’ table, so I just edited the data within SQL management studio.

FYI – Although I do this, I don’t recommend making any changes to the CRM databases directly. A safer workaround is posted here

Written by neilmcd

Jul 7, 2010 at 6:06 pm

Posted in CRM 4

Tagged with ,

Google Maps in CRM

leave a comment »

Tumblr_l56ytphlmo1qccrkio1_1280

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!

Written by neilmcd

Jul 5, 2010 at 10:27 pm

Posted in CRM 4

Tagged with ,