Tuesday, March 29, 2011

Latest earthquakes in the World

Very usefull online information tool to get info for latest earthquakes and volcanos in the world

Monday, March 28, 2011

How long does it take to drive through Riga city ?

I must say that this is not a story about THIS. My approach was more realistic and much safer :)I took my car to drive through city Riga from one city border to another simply to check how much time do i need to get through this city within legal limits.

Thursday, March 24, 2011

Get current SharePoint User with JavaScript

During the SharePoint form customization in many cases it is important to know the current user. So with JavaScript and SharePoint Designer this is how it's done:

var loginElement = document.getElementById("zz7_Menu").innerHTML;
var end = loginElement.indexOf("<");
var nameOnly = loginElement.substring(8, end);

note: I use this script in MOSS2007, but if you use this in WSS3 change "zz7_Menu" to "zz6_Menu".

My whole point using this script was to get the current username (in my case organization username format is: username14, username57 etc.) And based on that I need to get only numbers from this username. So there is my complete solution:

var loginElement = document.getElementById("zz7_Menu").innerHTML;
var end = loginElement.indexOf("<");
var nameOnly = loginElement.substring(8, end);
var number = nameOnly.replace (/[^\d]/g, "");
var k;

if (number != "") {
var elements = document.getElementsByTagName('select');
for (var i = 0; i < elements.length; i++) {
if (elements[i].title == 'YOUR DROPDOWN TITLE'){
var sel = elements[i].options.selectedIndex = number;
for (k=elements[i].options.length-1;k>=0;k--) {
if (k != sel) {
elements[i].remove(k);
        }
      }
    }
  }

}

Tuesday, March 22, 2011

How to get CRM grid View Id

If we add this piece of code to ISV.config we get the current View Id currently displayed in the CRM grid:

if (top.stage.crmGrid != null)
{
    var ViewID = top.stage.crmGrid.GetParameter('viewid');    

    alert(ViewID);
}

Train Tracking with GPS

Last Saturday I took a trip on a train from Riga to Saulkrasti (45km). Weather was pretty cloudy but I thought maybe I could get interesting info from this trip with my gps. This is my gps data report

Train model: ER2T

Friday, March 18, 2011

CRM Save Events - you can do more

    When user saves the form we can check which save event was executed and regarding to that event make some actions. Two most popular save events are Save and SaveAndClose.


Javascript functions to call from  your script:
crmForm.Save(); 
crmForm.SaveAndClose();


To check which event was executed  we use "event.Mode"
Output for Save event = 1;
Output for SaveAndClose event = 2;


example:   
if  (event.Mode == 1) {
alert("You click Save button");
} else if (event.Mode == 2) {
alert("You click SaveAndClose button");

Thursday, March 17, 2011

JavaScript in CRM ISV.config

Writing JavaScript code in ISV.config can be painful. There is one important thing you need to know when you write JS code in ISV - Some JavaScript characters here are not supported and that's why you need to encode them:

Symbol                 Encoded value
   <                       &lt;    
   >                       &gt;
   "                       &quot;
   &                       &amp;

Wednesday, March 16, 2011

Great site for CRM developers

If you are familiar with Russian language this is great site about CRM customization. If not.. there still are lot of scripts to pick up.
Мелкомягкий CRM