Expression for a field in report
It would check whether a field is null or not. If null that it would add six months to current date or else keep the same value. It would also remove the time part from it.
= iif(
IsNothing(new_mydate.Value),
Format(DateAdd(DateInterval.Month,6,Now()),”M\/d\/yyyy”),
Format(Fields!new_mydate.Value,”M\/d\/yyyy”)
)
Dynamically showing progress bar in the left navigation pane of the entity form.
document.getElementById(‘navAsyncOperations’).innerHTML = “<table align=’center’><tr><td><div id=’showbar’ style=’font-size:8pt;padding:2px;border:solid black 2px;’><span id=’p1′> </span> <span id=’p2′> </span> <span id=’p3′> </span></div><span id=’info’></span></td></tr></table>”;
var percentComplete;
GetPercentComplete=function()
{
// hard code the the value for total number of field
var totalField=3;
// set total no of blank field as 0
var totalBlankField=0;
// check for all the required fields and increment the value
if(crmForm.all.new_name.DataValue==null)
{
totalBlankField++;
}
if(crmForm.all.new_firstname.DataValue==null)
{
totalBlankField++;
}
if(crmForm.all.new_lastname.DataValue==null)
{
totalBlankField++;
}
// total no. of fields would be total field minus total blank field
var totalFilledField=totalField-totalBlankField;
// if total filled field is zero that 0 % complete
if(totalFilledField==0)
{
percentComplete=0;
}
else
{
// calculate the percentage
percentComplete=(totalFilledField/totalField)*100;
}
Code for refreshing parent Crm Form from an asp.net page code
private void ReloadWindow()
{
StringBuilder builder = new StringBuilder();
builder.Append(“<script language=JavaScript>”);
builder.Append(“\r\n”);
builder.Append(“if (“);
builder.Append(“(window.opener != null) &&”);
builder.Append(“(window.opener.parent != null) &&”);
builder.Append(“(window.opener.parent.document != null) &&”);
builder.Append(“(window.opener.parent.document.crmForm != null)) {“);
builder.Append(“\r\n”);
builder.Append(“var parentForm = window.opener.parent.document.crmForm;”);
builder.Append(“\r\n”);
builder.Append(“parentForm.Save();”);
builder.Append(“\r\n”);
builder.Append(“window.opener.document.location.replace(window.opener.location);”);
builder.Append(“\r\n”);
builder.Append(“}”);
builder.Append(“\r\n”);
builder.Append(“self.focus();”);
builder.Append(“</script>”);
this.Response.Write(builder.ToString());
}
Just a simple JavaScript to change the status of the form
var statusContent=”’test content’
document.getElementById(‘EntityStatusText’).innerHTML=statusContent;
Preventing user from changing url in browser javascript
<body onBlur=”self.focus();”>
For getting value from crm’s form to iframe page
var AccountName = parent.document.forms[0].all.name.DataValue;
alert(‘Order Name=’+AccountName);
For getting values from Iframe’s page
// test is the name of the iframe
// textbox1,image1 are the control inside the page within iframe
var to=window.frames['test'].document.getElementById(‘TextBox1′).value;
var to1=window.frames['test'].document.getElementById(‘Image1′).src;
For changing Button value using javascript
script type=”text/javascript”>
function SetReadOnly()
{
var x=document.getElementsByTagName(“input”);
for (var i=0;i<x.length;i++)
{
if (x.item(i).type==”button”&&x.item(i).value==”OK”)
{
x.item(i).value=”Save”
};
}
}
_spBodyOnLoadFunctionNames.push(“SetReadOnly()”);
</script>
For writing log in a text file
TextWriter log = TextWriter.Synchronized(File.AppendText(@”C:\g.txt”));
log.WriteLine(“MyMessage”);
log.Close();
For converting mm/dd/yyyy format to dd/mm/yyyy
public string ConvertTOSqlServerFormat(string DateToConvert)
{
int day, month, year;
String[] myDelim = DateToConvert.Split(new Char[] { ‘/’ });
day = Convert.ToInt32(myDelim[0]);
month = Convert.ToInt32(myDelim[1]);
year = Convert.ToInt32(myDelim[2]);
string myConvertedDate = new DateTime(year, month, day).ToShortDateString();
return myConvertedDate;
}
For giving double quotes
string myInfo=”Hello”;
string myMsg = @”This is my message”"”+myInfo+ @”"”to you”;
MessageBox.Show(myMsg);
–> This is my message “Hello” to you
For finding the days difference in javascript and setting a particular date 28 days before
<!–[if gte mso 9]> Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <![endif]–><!–[if gte mso 9]> <![endif]–> <!–[endif]–>
function GetDiff(form1)
{
date1 = new Date(form1.firstdate.value);
date2 = new Date(form1.seconddate.value);
diff = new Date();
//date.getTime() –>Returns the number of milliseconds since midnight Jan 1, 1970
//Math.abs() –>Returns the absolute value of a number
//Math.floor –>Returns the value of a number rounded downwards to the nearest integer
diff=diff.setTime(Math.abs(date1.getTime() – date2.getTime()));
days = Math.floor(diff / (1000 * 60 * 60 * 24));
// if days greater than 28
// than set the first date 28 days less than the second date
if(days>28)
{
alert(‘Greater than 28 ‘);
// setting the second date 28 days less
date2.setDate(date2.getDate()-28);
// converting to string to find the length and if 1 than adding a 0
// i.e 1 to 01
var month=((date2.getMonth())+1).toString();
if(month.length==1)
{
month=“0″+month;
}
var date=date2.getDate().toString();
if(date.length==1)
{
date=“0″+date;
}
form1.firstdate.value=month+“/”+date+“/”+date2.getYear();
}
}
RSS - Posts

Is there any code snippet available for the image saving and retrieving from Database using SQL
By: aftan on June 9, 2008
at 10:18 am
Hi,
Nishant I am facing some problem while calling webservice from client machine. Below code is working fine on local machine(window 2003 server). When i call application from user machine (window XP) than permission denied error raise. Please help. Thanx in advance.
function XmlhttpCall(objXML,serviceName)
{
try
{
var xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
var xmlHttpGo = xmlHttp;
var str = “http://192.168.0.1/MyWebService/HelloWebService.asmx” + serviceName;
//Service name is webmethod define in Webservice
//192.168.0.1 is ip address of my server (Window 2003 Server)
xmlHttpGo.open(“POST”, str, false);
xmlHttpGo.SetRequestHeader(“Content-type”,”application/x-www-form-urlencoded”);
xmlHttpGo.send(‘xmlLogin=’ + objXML.xml);
var xmlString1 = xmlHttpGo.responseXML.text;
return xmlString1;
}
catch(e)
{
return (e.Message + “–> XmlhttpCall”);
}
}
By: prabhat on November 13, 2009
at 1:02 pm
Hi Prabhat,
It could be cross domain issue. The page you are calling through web service should be in the same domain.
Regards,
Nishant Rana
By: Nishant Rana on November 13, 2009
at 1:06 pm
Hi Nishant,
I am trying to update attributes of entities programmatically for CRM 4.0 using metadatawebservice. can you please help me with snippet on how to do it.
By: kashyap on May 22, 2009
at 5:48 am
Hi Nishat,
I need to call a custom webservice and pass a value on some event through javasript in CRM entity page.
Can you please help me in this regard, giving some sample code?
By: alihamzaraza on May 27, 2009
at 1:55 pm
Hey Nishat, are you up for a SharePoint development project? reply a follow up comment here to let me know. This is for a company in California. Thanks.
By: SlamDunker on July 20, 2009
at 1:22 am
hi nishanth im trying to invoke a Siebel web service from .net(im using c#).im querying contacts.but im getting null response..can you please tell me how to do it properly..thanks in advance
By: shaji on August 4, 2009
at 10:55 am
Hi,
It was long back i worked with siebel web service and i don’t even have access to the server right now !!
This is what i had done that time for fetching the data !!
http://nishantrana.wordpress.com/2009/03/21/using-oracle-crm-on-demand-web-service-to-query-opportunity-data-in-net/
May be that could be of help !!
By: Nishant Rana on August 5, 2009
at 10:11 am
Hi Nishanth ,
I am working on the MS CRM webservice on java . i couldn’t find much examples in the Java .can you please help on this . I am trying to store the value into the Salesorder entity . but i am getting exception. And Same thing is hpning while retrieving the data with query condition.
. Please help me .
org.apache.axis2.AxisFault:
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ‘S’
(code 83) in prolog; expected ‘<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:118)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
By: Chandra on August 10, 2009
at 4:26 pm
Hi Chandra ,
Check this url
http://rabout.com/?q=ms_dynamics_crm_3_api_axis2
Hope it helps you.
By: Nishant Rana on August 19, 2009
at 4:53 am
Hi,
Am new to CRM,I would like to know details about the domain concept in CRM.
Is CRM Domain Based?? Plz help
By: Tejashree.S on August 20, 2009
at 5:00 am
http://nishantrana.files.wordpress.com/2008/10/8912-en_customization_and_configuration_student_manual.pdf
The path you sent for materials on crm 4.0 certifications is not working. plz help me for the materials
By: Tejashree.S on August 20, 2009
at 5:06 am
simple and good collection of crm code snippets.
thanks.
By: jitendra parekh on October 6, 2009
at 11:57 am
I have created a webservice to Add a contact, account etc.. So my client application will be to create a contact thro webservice.
Right now, my client application database has tables for contact and account, but the primary key is of int data type. If i import all the contacts from the existing database to crm, all the contactid will be in GUID type.
how will I identify which contact id(int) is for which guid?..
how will I retrieve a imported contact from crm if I pass the contactid (int) to the webservice? ..
should I create a custom attribute in crm as an identifier?
Your help is greatly appreciated!
By: Karthik on November 5, 2009
at 1:34 am
I have created a webservice to Add a contact, account etc.. So my client application will be to create a contact thro webservice.
Right now, my client application database has tables for contact and account, but the primary key is of int data type. If i import all the contacts from the existing database to crm, all the contactid will be in GUID type.
how will I identify which contact id(int) is for which guid?..
how will I retrieve a imported contact from crm if I pass the contactid (int) to the webservice? ..
should I create a custom attribute in crm as an identifier?
Your help is greatly appreciated!
Thanks
karthik
By: Karthik on November 5, 2009
at 1:35 am