Pages

Friday, 11 April 2008

Join CRM Field Values Into A Single Field

It's time for some JavaScript fun today. :)

Something I get asked for occasionally is to join a few CRM form field values into a single field. A possible example for this would be the joining of the first name and last name fields into the full name field on a contact form. This can, of course, be done by using a callout or plug-in (and to a limited extent, by using a workflow rule) but the easiest way to get this done is by using a form script.

I took the time and created a generic script that (I hope) covers all possible cases and irregularities in the data. Explanations are built into the script itself as remarks.


//Declare your world.
var strings = new Array();
var target = crmForm.all.some_nvarchar_field;

//A function that check whether there is a legitimate value further on.
function checkNext(a,i) {
if (i >= a.length) {
return false;
} else if (a[i] != null && a[i] != "") {
return true;
}
else {
return checkNext(a,i+1);
}
}

//A function that add a line to an array
function addLine(l,t) {
//If lookup field.
if (t == 1) {
if (l.DataValue) {
return l.DataValue[0].name;
} else {
return null;
}
//If text field.
} else if (t == 2) {
return l.DataValue;
//If picklist field.
} else if (t == 3) {
return l.SelectedText;
} else {
return null;
}
}

//Add each of the values in order to the array.
//As the second parameter, enter 1 for lookup fields, 2 for any text field and 3 for picklist fields.
strings[0] = addLine(crmForm.all.some_lookup_field,1);
strings[1] = addLine(crmForm.all.some_nvarchar_field,2);
strings[2] = addLine(crmForm.all.some_picklist_field,3);

//Loop through the array and chain its
values.
for (i=0;i<strings.length;i++) {
if (strings[i] != null && strings[i] != "" && checkNext(strings,i+1)) {
if (i==0){
target.DataValue = strings[i] + " - ";
} else {
target.DataValue += strings[i] + " - ";
}
} else if (strings[i] != null && strings[i]
!= "") {
if (i==0) {
target.DataValue = strings[i];
} else
{
target.DataValue += strings[i];
}
}
}


It seems there isn't much I can do about how badly the script comes out on the blog...
My apologies. I'll take it up with Google.

Tuesday, 1 April 2008

Hiding Users From The CRM (3.0 / 4.0) Service Calendar

I was fiddling with the CRM Filtered Views today for a report I'm writing for a customer. One of the views I was dealing with was the FilteredSystemUser view. This view is the one which displays attributes for the User entity in CRM.

I suddenly came across an interesting attribute I had not noticed before named displayinserviceviews. This caught my attention as it had the potential of solving a problem which has plagued me for a long time - How do I hide certain users from the Service Calendar so they are not displayed as resources?



Turns out there was a really simple solution for this. I was very pleased! :)

All you need to do is add this attribute to the User form in the CRM customization section and then you'll have a new bit (yes/no) field in the User form which will allow you to choose whether or not the user will be available as a resource in the Service Calendar.

Couldn't be simpler! :)

Monday, 31 March 2008

MOSS 2007 / WSS 3.0 Search Indexer Gets Stuck

Now I know this is not a new subject and the solutions are out there. So I'm writing this (short this time) article as a basic summary of what I've come across.

So what's the problem?
Some of you must have come across this before. The Shared Service Provider's crawler get stuck and you can't stop it. It also does not add any new items to the index.

I've found two great articles that deal with this issue.
The first one by Mike Hanley explains how to resolve this issue with clear instructions and good screenshots. It can be found here.
The second is a support KB by Microsoft which expands what is explained in Mike's article by adding more tables which need fixing. It can be found here under KB930887.