Use
addEvent(crmForm.all.tab7Tab, "mousedown", iframeHOMEPAGEExplorer);
Tuesday, August 10, 2010
Monday, June 7, 2010
Adding Many to many Data
//Links (relates) an account record to a lead record in a manyToMany relationship
Moniker moniker1 = new Moniker();
moniker1.Name = "opportunity";
moniker1.Id = new Guid("0D50E716-2757-DF11-AF09-000C29A10E7B");
Moniker moniker2 = new Moniker();
moniker2.Name = "contact";
moniker2.Id = new Guid("0D6BF93F-9D94-4EC1-970B-5E1B1BFBADA2");
AssociateEntitiesRequest request = new AssociateEntitiesRequest();
request.Moniker1 = moniker1;
request.Moniker2 = moniker2;
request.RelationshipName = "ppp_opportunity_contact";
service.Execute(request);
Source : http://blogs.msdn.com/b/crm/archive/2008/02/14/crm-4-0-relationships-explained.aspx
Moniker moniker1 = new Moniker();
moniker1.Name = "opportunity";
moniker1.Id = new Guid("0D50E716-2757-DF11-AF09-000C29A10E7B");
Moniker moniker2 = new Moniker();
moniker2.Name = "contact";
moniker2.Id = new Guid("0D6BF93F-9D94-4EC1-970B-5E1B1BFBADA2");
AssociateEntitiesRequest request = new AssociateEntitiesRequest();
request.Moniker1 = moniker1;
request.Moniker2 = moniker2;
request.RelationshipName = "ppp_opportunity_contact";
service.Execute(request);
Source : http://blogs.msdn.com/b/crm/archive/2008/02/14/crm-4-0-relationships-explained.aspx
Sunday, June 6, 2010
Call a function when a CTRL + key is pressed
Trigger a function when a key is pressed.
function filterKeys()
{
if (window.event)
{
// captures the key combination of Ctrl and Shift keys
if(window.event.ctrlKey && window.event.shiftKey)
{
var key = window.event.keyCode;
// captures the key for upper and lower case F
if (key == 70 || key == 102)
//window.event.keyCode = 0; - do nothing
write a custom function here
}
}
}
function filterKeys()
{
if (window.event)
{
// captures the key combination of Ctrl and Shift keys
if(window.event.ctrlKey && window.event.shiftKey)
{
var key = window.event.keyCode;
// captures the key for upper and lower case F
if (key == 70 || key == 102)
//window.event.keyCode = 0; - do nothing
write a custom function here
}
}
}
Thursday, April 22, 2010
Refresh the GRID in an IFRAME
var iframeWin = crmForm.all.IFRAME_signalcodesummary.contentWindow;
iframeWin.document.all.crmGrid.Refresh();
iframeWin.document.all.crmGrid.Refresh();
Sunday, April 18, 2010
Friday, April 16, 2010
Change mouse cursor
To change the mouse cursor you can use the below code
document.body.style.cursor='wait'
the following options can also be used
auto -- the default
crosshair - cross
pointer -- the hand similar to the one that appears over a link
help -- question mark
move -- the hand that signifies a movable element
text - cursor
wait -- hourglass
document.body.style.cursor='wait'
the following options can also be used
auto -- the default
crosshair - cross
pointer -- the hand similar to the one that appears over a link
help -- question mark
move -- the hand that signifies a movable element
text - cursor
wait -- hourglass
Thursday, April 15, 2010
Thursday, April 8, 2010
XML Escape Tool
In XML text and attribute values, we need to escape ASCII characters like the angle brackets/semicolon/single quote/double quotes. XML Escape Tool can escape/unescape XML characters easily and quickly. it is FREEWARE
Refer : http://www.myxmltools.com/xml-escape-tool.shtml
Refer : http://www.myxmltools.com/xml-escape-tool.shtml
Friday, March 26, 2010
Add custom stylesheets to SSRS reports
To add custom stylesheets to a SSRS report
http://msdn.microsoft.com/en-us/library/ms345247.aspx
http://msdn.microsoft.com/en-us/library/ms345247.aspx
Wednesday, March 24, 2010
Move a section from one tab to another tab
//get the section you want to move
var sectionToReplace = crmForm.all.ppp_keywords.parentElement.parentElement.parentElement;
//this code will place the above section below the specified section
crmForm.all.ppp_dealeractions.parentElement.parentElement.parentElement.appendChild(aa);
var sectionToReplace = crmForm.all.ppp_keywords.parentElement.parentElement.parentElement;
//this code will place the above section below the specified section
crmForm.all.ppp_dealeractions.parentElement.parentElement.parentElement.appendChild(aa);
Hide a section on the CRM Form
crmForm.all.ppp_keywords.parentElement.parentElement.parentElement.style.display = 'none';
Sunday, March 21, 2010
IFRAME content in different domain
In one of my requirement I had to include an IFRAME on the CRMForm. The IFRAME url points to a website in a different domain. The website had a JavaScript code which would populate value on two fields in the CRM Form.
Since the website and CRM Form were on different domains the JavaScript within the website could not access the fields on the CRM Form. So I had to write the below code on the website and CRMForm which made the domains same.
document.domain = "domain.com";
Since the website and CRM Form were on different domains the JavaScript within the website could not access the fields on the CRM Form. So I had to write the below code on the website and CRMForm which made the domains same.
document.domain = "domain.com";
Post to a page
var HPtoken = null;
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest)
{
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', 'http://somewebsite.com', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function()
{
if (self.xmlHttpReq.readyState == 4)
{
alert(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(null);
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest)
{
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', 'http://somewebsite.com', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function()
{
if (self.xmlHttpReq.readyState == 4)
{
alert(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(null);
Thursday, March 11, 2010
SQL Connection
// This example needs the
// System.Data.SqlClient library
#region Building the connection string
string Server = "localhost";
string Username = "my_username";
string Password = "my_password";
string Database = "my_database";
string ConnectionString = "Data Source=" + Server + ";";
ConnectionString += "User ID=" + Username + ";";
ConnectionString += "Password=" + Password + ";";
ConnectionString += "Initial Catalog=" + Database;
#endregion
#region Try to establish a connection to the database
SqlConnection SQLConnection = new SqlConnection();
try
{
SQLConnection.ConnectionString = ConnectionString;
SQLConnection.Open();
// You can get the server version
// SQLConnection.ServerVersion
}
catch (Exception Ex)
{
// Try to close the connection
if (SQLConnection != null)
SQLConnection.Dispose();
// Create a (useful) error message
string ErrorMessage = "A error occurred while trying to connect to the server.";
ErrorMessage += Environment.NewLine;
ErrorMessage += Environment.NewLine;
ErrorMessage += Ex.Message;
// Show error message (this = the parent Form object)
MessageBox.Show(this, ErrorMessage, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Stop here
return;
}
#endregion
#region Execute a SQL query
string SQLStatement = "SELECT * FROM ExampleTable";
// Create a SqlDataAdapter to get the results as DataTable
SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(SQLStatement, SQLConnection);
// Create a new DataTable
DataTable dtResult = new DataTable();
// Fill the DataTable with the result of the SQL statement
SQLDataAdapter.Fill(dtResult);
// Loop through all entries
foreach (DataRow drRow in dtResult.Rows)
{
// Show a message box with the content of
// the "Name" column
MessageBox.Show(drRow["Name"].ToString());
}
// We don't need the data adapter any more
SQLDataAdapter.Dispose();
#endregion
#region Close the database link
SQLConnection.Close();
SQLConnection.Dispose();
#endregion
// System.Data.SqlClient library
#region Building the connection string
string Server = "localhost";
string Username = "my_username";
string Password = "my_password";
string Database = "my_database";
string ConnectionString = "Data Source=" + Server + ";";
ConnectionString += "User ID=" + Username + ";";
ConnectionString += "Password=" + Password + ";";
ConnectionString += "Initial Catalog=" + Database;
#endregion
#region Try to establish a connection to the database
SqlConnection SQLConnection = new SqlConnection();
try
{
SQLConnection.ConnectionString = ConnectionString;
SQLConnection.Open();
// You can get the server version
// SQLConnection.ServerVersion
}
catch (Exception Ex)
{
// Try to close the connection
if (SQLConnection != null)
SQLConnection.Dispose();
// Create a (useful) error message
string ErrorMessage = "A error occurred while trying to connect to the server.";
ErrorMessage += Environment.NewLine;
ErrorMessage += Environment.NewLine;
ErrorMessage += Ex.Message;
// Show error message (this = the parent Form object)
MessageBox.Show(this, ErrorMessage, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Stop here
return;
}
#endregion
#region Execute a SQL query
string SQLStatement = "SELECT * FROM ExampleTable";
// Create a SqlDataAdapter to get the results as DataTable
SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(SQLStatement, SQLConnection);
// Create a new DataTable
DataTable dtResult = new DataTable();
// Fill the DataTable with the result of the SQL statement
SQLDataAdapter.Fill(dtResult);
// Loop through all entries
foreach (DataRow drRow in dtResult.Rows)
{
// Show a message box with the content of
// the "Name" column
MessageBox.Show(drRow["Name"].ToString());
}
// We don't need the data adapter any more
SQLDataAdapter.Dispose();
#endregion
#region Close the database link
SQLConnection.Close();
SQLConnection.Dispose();
#endregion
Sunday, February 28, 2010
Get Object Type Code + C#
To get the Object type code dynamically using C#
public int GetObjectTypeCode(string entityName)
{
CrmMetaDataService.CrmAuthenticationToken token = new CrmMetaDataService.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "NZ";
// Create the metadata Web service.
MetadataService metadataService = new MetadataService();
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
metadataService.PreAuthenticate = true;
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest();
entityRequest.RetrieveAsIfPublished = false;
entityRequest.LogicalName = entityName;
entityRequest.EntityItems = EntityItems.EntityOnly;
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)metadataService.Execute(entityRequest);
// Access the retrieved entity
EntityMetadata retrievedEntityMetadata = entityResponse.EntityMetadata;
return retrievedEntityMetadata.ObjectTypeCode.Value;
}
public int GetObjectTypeCode(string entityName)
{
CrmMetaDataService.CrmAuthenticationToken token = new CrmMetaDataService.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "NZ";
// Create the metadata Web service.
MetadataService metadataService = new MetadataService();
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
metadataService.PreAuthenticate = true;
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest();
entityRequest.RetrieveAsIfPublished = false;
entityRequest.LogicalName = entityName;
entityRequest.EntityItems = EntityItems.EntityOnly;
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)metadataService.Execute(entityRequest);
// Access the retrieved entity
EntityMetadata retrievedEntityMetadata = entityResponse.EntityMetadata;
return retrievedEntityMetadata.ObjectTypeCode.Value;
}
Thursday, February 25, 2010
The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey
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;
}
{
//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 + '
');
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 :
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;
}
}
}
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
Subscribe to:
Comments (Atom)


