Error loading external JavaScript file on Win2k8, IIS7.0

May 16, 2011 by Geron Profet · Leave a Comment 

I’m using the following code in the entity’s OnLoad event to load an external JavaScript file in MS CRM.
===================================
function LoadFile(url, cache)
{
var httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
httpRequest.open('GET', url, false);
if (!cache) {
httpRequest.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
}
httpRequest.send(null);
return httpRequest.responseText;
}
LoadFile('/ISV/scripts/accounts.js', false)
We recently migrated our CRM Server to Windows 2008, with IIS 7.0.
This worked fine on Windows [...]

Change the form title in MS CRM via JavaScript

February 15, 2011 by Geron Profet · Leave a Comment 

In MS CRM the document title and form title defaults to the primary name attribute of an entity. Sometimes you want to display a different name e.g. to display both the account name and account number. The originale idea came from: http://mscrm4ever.blogspot.com/2008/10/finding-crmform-elements-by-css-class.html
I made this function a bit more generic and changed it so you can [...]

Dynamically filter a picklist in MS CRM – Part 2

February 14, 2011 by Geron Profet · 2 Comments 

Last year I wrote an article explaining how to filter a picklist based on another picklist in MS CRM. In this article I’ll explain how to filter a picklist based on an array of values. The original idea for this approach came from Greg Owens on: The CRM Grid – A Microsoft CRM Blog.
I made [...]

How to get the Entity Type Code via the Metadata Webservice in JavaScript

January 25, 2011 by Geron Profet · 3 Comments 

Sometimes you want to fill in a default value in a lookup field. In order to do so you need to specify the Id, Value and Object Type Code, also known as Entity Type Code, of the entity (for an example see gLookupSetField() on our site).
The ObjectTypeCode of custom entities might be different when you [...]

Execute workflow in JavaScript and wait for it to complete

December 17, 2010 by Geron Profet · Leave a Comment 

Sometimes you want to launch a workflow in JavaScript and wait for it to complete. Andriy Butenko wrote a script that would wait for a workflow to complete in JavaScript.
Scenario
Our customer requested that an email would be created via a workflow and that the user is notified immediately when the email is saved so that [...]

Retrieve one or more fields using FetchXML

December 17, 2010 by Geron Profet · Leave a Comment 

This function is used to retrieve multiple fields in MS CRM via fetchXml and return an array containing the requested values.
The function requires the following parameters:

xml            = fetchXml
arrFields   = array of attributes to return

When multiple records are found you can request the value of the attribute (example 1), recordcount (example 2) or the entire recordset [...]

Calculate working days between to two dates

December 17, 2010 by Geron Profet · 1 Comment 

This function can be used to calculate the number of working days between two dates in JavaScript. If needed, holidays can be excluded by passing an array of dates. For a list op all holidays see: http://www.calendardate.com/year2010_holidays.php  or retrieve them from the database using gGetValue() or gFetchValues().
Copy the function in the Onload event and call it using  [...]

Change the display text in a lookup

December 17, 2010 by Geron Profet · 2 Comments 

The following function enables you to change display value of a lookup in MS CRM. In the example below we have a custom entity to register multiple roles/relationships between accounts and contacts. Obviously, one contact can work for multiple accounts at any time or become a member of a society or association.
We have modified the [...]

How to change label width beyond 250 px. in MS CRM

December 17, 2010 by Geron Profet · Leave a Comment 

Sometimes you want to create a questionnaire in MS CRM. See example:

However, in MS CRM the max label width within a section is 250 pixels. Fortunately, Mitch Milam  found an interesting (unsupported) way how to increase the label width beyond 250 pixels.
2
Follow the procedure below to change your column label width:
Step-by-Step

Create a new section
Click on [...]

Get data from fields of "Close Opportunity” dialogue

November 19, 2010 by Geron Profet · Leave a Comment 

When closing an opportunity you sometimes you want to validate if e.g. the competitor field is filled when the user selected “Lost”. By default there is no way to get this information but Andriy Butenko found a way in JavaScript. See the original post: http://a33ik.blogspot.com/2010/06/extended-handling-of-save-event-in.html. 
This gave me the idea to make this a bit more [...]