by Gustaf Westerlund | Sep 1, 2007
Javascript is a strange language, it is often confused to be Java, which is very far from right, and the syntax can often be thought to be as consistent as C# or Java. Not the case. Javascript is a strange and weird beast, that when tamed can be a very strong ally. Taming it can however really get on your nerves!
There is one method working on the object window, called close(). Hence it is called using window.close(). It does the simple thing of closing the current browser window. No more, no less.
Well, actually, it does it in a strange way. Have a look at the following code that is executed in body onload. What is going to happen?
Alert(“Start”);
Windows.close();
Alert(“End”);
I will give you two options:
Option 1:
- A dialog window showing “Start” will show.
- The current browser window will close.
Option 2:
- A dialog window showing “Start” will show.
- A dialog window showing “End” will show.
- The current browser window will close.
Well?
You would think that option 1 is correct, well, it isn’t, the script is executed according to option 2. For some reason, window.close() doesn’t actually close the window, it signals it to close and when the onload has reached its end, it is closed. I havn’t checked to see if this behavior only happens when executed in onload or if it is the same all over. Be aware though, it might not work as you’d expect!
Gustaf
by Gustaf Westerlund | Sep 1, 2007
Sometimes you would like to create a virtual directory bellow for instance the SharePoint main site. Lets say you MOSS is installed at http://intranet and you would like to create your own virtual directory with your custom made aspx-pages at for instance http://intranet/custom. Well, if you use the IIS Management Console, add a virtual directory to the website, and add an aspx-page to that virtual directory, you will get errors saying that the application cannot find certain assemblies. This is due to the fact that these assemblies have been referenced in web.config using <add assembly=”name-of-assembly” / > tags. Due to the way IIS works, these references are automatically inherited to all sub-directories, in this case, you virtual directory.
So, what to do? The simplest way to handle this is to add <remove assembly=”name-of-assembly” / > tags to the web.config that resides in your virtual directory. This will explicitly remove the reference created by the parent website. Remove them one by one and soon you will be able to run your code just as you would like.
One good advantage of using adding your code to a virtual directory bellow the main site instead of using a new website at for instance another host header or TCP port, is that you can address your code using server relative urls. In essence, if you created an aspx-page at http://intranet/custom/mycustompage.aspx. If you address this page from the SharePoint, you can use the url: /custom/mycustompage.aspx without http:// or the servername. This also gives you the benefit that the page is on the same server, hence no security problems with IE.
In SharePoint, make sure that the address of your virtual directory is NOT bellow any wildcard included och explicitly included sites (in the setup of the webapplication in central admin).
Please note that adding virtual directories bellow the CRM root is an unsupported customization. This is due to the fact that Microsoft might release an update that adds a directory with the exact name of you virtual directory. This would give rise to either the fact that your code stops working or more likely that the content of the directory added by Microsoft cannot be accessed.
Gustaf Westerlund
Humandata AB
by Gustaf Westerlund | Aug 31, 2007
Today I was working with a customer who wanted to show their SSRS 2005 reports in SharePoint. As many of you might be aware, from SP 2 of SQL 2005 there is an option of storing you reports on the SharePoint Server. Very nice, but I havn’t really tried getting that to work with MS CRM 3, so the SSRS I was using ran in normal mode, i.e. not SharePoint integration. However, I did want to show the reports and the reports explorer in SharePoint. For SharePoint v2 there has long existed RSWebparts.cab, which is a web part package consisting of two web parts; report viewer and report explorer.
After a bit of looking I couldn’t find it for SharePoint v3, and found some information saying that the old webparts actually still worked well. So, after the always so tedious work of trying to locate the file, RSWebparts.cab (it cannot be downloaded from the Internet as far as I know) I installed it using stsadm –o installwp -o addwppack -force –filename “C:tempRSWebParts.cab” –globalinstall (use stsadm –help addwppack to see possible syntax), and adding the RSWebparts.dll as a safecontroll (with the correct strong name). I got it to work, just as nicely as it did in SharePoint v2. So, my suggestion to you, if you have the same need, use the old one.
And where can you find the file? It is installed in some impossible path bellow c:program filesSQL Server of a SQL 2000 SP2 (or greater) server. So, get your hands on it, and don’t let go. I don’t think I can publish it here though, due to copyright reasons.
Gustaf
by Gustaf Westerlund | Aug 30, 2007
I was reading a bit on the CRM Teams blog and read a posting on the fact that there is an aspx-page that lists all entities that can also show all attributes of the entity. Read the post here or just brows to: http://<yourservername>/sdk/list.aspx.
You learn something new, every day J.
Gustaf Westerlund
Humandata AB
by Gustaf Westerlund | Aug 30, 2007
As many of you who work with development in Microsoft CRM know, callouts is a great tool. Lots of different tasks can be left to be handled by callouts and they are even run when offline data is resynced to the main system. However, a common problem when working with PostUpdate callouts is that the code wants to update the object that created the callout, hence executing the calloutcode again, which might result in an endless recursion.
I recently ran into this problem working at a customer of mine, and found a nice generic way of solving it using the thought behind the design pattern object factory or single instance.
I guess you want some code! Well, the basis of this solution is to have a static instance of a collection that keeps track of if a certain key just has been run. I use the collection StringCollection. It is simple, and just what I needed in this case:
private
static System.Collections.Specialized.StringCollection justtreated;
Then I created a method that is supposed to return false the first, third, fifth… time it is called and true every second, fourth, sixth… time it is called with a certain key.
private
bool JustDone(string key)
{
if (justtreated == null)
{
justtreated = new System.Collections.Specialized.StringCollection();
}
if (justtreated.Contains(key))
{
justtreated.Remove(key);
return
true;
}
justtreated.Add(key);
return
false;
}
}
The method is not very complicated. First off, it makes sure that the static variable has been created. Then it checks if it can find the key string in the string collection. If it can it will remove it and then return true. If it cannot find the key, it will add it to the collection and return false.
Since, this method is working with a static variable that will remain in memory between instantiations of the class, hence the data will remain between PostUpdate calls.
Then in the beginning of the PostUpdate method just call JustDone() with the object key (or some other unique key) and if it is true, just “return”.
Gustaf Westerlund
Humandata AB
by Gustaf Westerlund | Aug 23, 2007
I’ve been bad at reading all blogs recently. Full of work and my private time is now mostly filled with my daughter Nora, hence less time to read up on blogs.
We have all (?!) been waiting for the new MS CRM VPC and it has now been released. It can be downloaded from here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=57394bc8-5ecc-422e-a066-34189f48f8c8&displaylang=en
I havn’t downloaded it myself yet, but I will soon.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Recent Comments