Sunday, January 17, 2010

Get the Object Type Code using AJAX

function getObjectTypeCode(entityName,organizationName)
{
//FUNCTION CREATED BY GEOFFREY JOE ON 18-01-2010
//TO GET THE OBJECT TYPE CODE OF AN ENTITY DYNAMICALLY
// EXAMPLE : getObjectTypeCode('account','za2'); WILL RETURN 1



var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

xmlHttpRequest.Open("POST", "/mscrmservices/2007/MetaDataService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
//debugger;
var xDoc = new ActiveXObject("MSXML2.DOMDocument");
xDoc.loadXML(resultXml.xml);
var objectTypeCode=xDoc.childNodes(1).childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(3).getAttribute('formattedvalue');
//alert(objectTypeCode);
return objectTypeCode;
}

Remove/Replace special characters in a string

var temp = new String('This is a te!!!!st st>ring... So??? What...');
document.write(temp + '
');
temp = temp.replace(/[^a-zA-Z 0-9]+/g,'');
document.write(temp + '
');

Thursday, January 14, 2010

Record count per page For Microsoft Dynamics CRM 4.0

Idea of plugin - is to catch Execute message and change quantity of records per page.

Here the code of plugin:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Win32;
using System.Xml;
using Microsoft.Crm.SdkTypeProxy.Metadata;
using Microsoft.Crm.Sdk.Metadata;

namespace TestPlugin
{
public class RecordCounterExtender : IPlugin
{
public RecordCounterExtender(string config, string secureConfig)
{
}

#region IPlugin Members

public void Execute(IPluginExecutionContext context)
{
if (context.MessageName == "Execute" && context.InputParameters.Contains("FetchXml"))
{
XmlDocument indoc = new XmlDocument();
indoc.LoadXml((string)context.InputParameters["FetchXml"]);

indoc.DocumentElement.Attributes["count"].Value = "1000";
context.InputParameters["FetchXml"] = indoc.OuterXml;
}
}

#endregion

}
}



Source :

Thursday, January 7, 2010

Threading - Sample

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;


namespace ThreadClassLibrary
{
public class Class1
{
//My thread
public double MyThread_Multiply(int a, int b)
{
double retVal = 1;
retVal = a * b;
return retVal;

}

//Call this method in the web application
public double ThreadMultiply(int a, int b)
{
double dd=0;
Thread MyThread = new Thread(delegate()
{
dd = MyThread_Multiply(a, b);

});
MyThread.Start();
return dd;

}


}
}

Monday, January 4, 2010

Setup instructions on how to send SMS from Microsoft Dynamics CRM 4.0

Setup instructions on how to send SMS from Microsoft Dynamics CRM 4.0

Sunday, January 3, 2010