Refresh Parent Form from child entity in CRM.


Check out this wonderful article by Andriy (the master in CRM) on it.

http://a33ik.blogspot.com/2009/05/page-refresh.html

And the same code translated for CRM 3.0.

function timerHandler()
{
var xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
"  <soap:Body>" +
"    <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
"      <q1:EntityName>salesorder</q1:EntityName>" +
"      <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
"        <q1:Attributes>" +
"          <q1:Attribute>modifiedon</q1:Attribute>" +
"        </q1:Attributes>" +
"      </q1:ColumnSet>" +
"      <q1:Distinct>false</q1:Distinct>" +
"      <q1:Criteria>" +
"        <q1:FilterOperator>And</q1:FilterOperator>" +
"        <q1:Conditions>" +
"          <q1:Condition>" +
"            <q1:AttributeName>salesorderid</q1:AttributeName>" +
"            <q1:Operator>Equal</q1:Operator>" +
"            <q1:Values>" +
"              <q1:Value xmlns:q2=\"http://microsoft.com/wsdl/types/\" xsi:type=\"q2:guid\">"+crmForm.ObjectId+"</q1:Value>" +
"            </q1:Values>" +
"          </q1:Condition>" +
"        </q1:Conditions>" +
"      </q1:Criteria>" +
"    </query>" +
"  </soap:Body>" +
"</soap:Envelope>" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple&quot;);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
var source = resultXml.selectSingleNode("//modifiedon").nodeTypedValue;
alert(source);
var firstpart = source.split(‘T’)[0];
var secondpart = source.split(‘T’)[1].split(‘+’)[0];
var parts =  firstpart .split(‘-‘);
var parts2 = secondpart.split(‘:’)
var modifiedon = new Date();
modifiedon.setYear(parts[0]);
modifiedon.setMonth(parts[1] – 1);
modifiedon.setDate(parts[2]);
modifiedon.setHours(parts2[0]);
modifiedon.setMinutes(parts2[1]);
modifiedon.setSeconds(parts2[2]);
if (modifiedon > openDate)
location.reload();
}
var openDate = new Date();
if (crmForm.FormType == 2)
setInterval(timerHandler, 1000);

 

Bye…

Understanding pipeline in CRM 4.0


Different stages in the event execution pipeline introduced in CRM 4.0.

Stage #1

•Pre-Operation – This is where custom logic can be registered to execute before the platform operation occurs. Logic that runs in this stage can stop further execution of the pipeline as we will discuss more in the plug-in chapters. Custom logic that runs in this stage is not part of the platform transaction.

Stage #2
•Pre-Operation – System – This stage is reserved as a pre-operation stage for system internal processing. Operations that occur as part of this stage are part of the Platform Transaction.You can’t register your own custom logic to run during this stage.

Stage #3
•Platform Operation – This is where the real work happens. The request/event that caused us to be in the pipeline is processed here and reflected on the state of the system. This stage is also part of the Platform Transaction. You can’t register your own custom logic to run during this stage.

Stage #4
•Post-Operation-System -This stage is also reserved as a post-operation stage for system internal processing. Operations that occur as part of this stage are part of the Platform Transaction. You can’t register your own custom logic to run during this stage.

Stage #5

•Post-Operation -This is where custom logic can be registered to execute. Custom logic in this stage can be either synchronous or asynchronous. Asynchronous logic will be handed off for processing by the Asynchronous Service queue. Custom logic that runs in this stage is not part of the platform transaction.

For better understanding of pipeline check out this wonderful article

http://crmscape.blogspot.com/2009/02/ms-crm-40-plug-in-stages-pipelines-and.html

Bye..

0x80044150 Generic SQL error. Platform : Server was unable to process the request in CRM


Hi,

I got this error while using CrmService from an web application.

Later i found that Crm Asynchronous Service(client)  was not running, so starting it solved the issue.

Just thought of sharing that !

Bye..

Hiding form assistant in CRM


Hi,

We could use the following script to hide the form assistant in Crm , we would use it in the form load event

document.getElementById(‘RelatedInformationPane’).style.display=’none’;

// ToggleInformationPane() to toggle the form assistant pane

document.all.RelatedInformationPane.ToggleInformationPane();

For CRM 4.0, go to customization ->customize entities-> select your entity–> select form properties->select Display tab and uncheck enable form assistant check box !!

Bye..

Cancel delete using PreDelete callout.


Just an example of using PreDelete callout !!!

public override PreCalloutReturnValue PreDelete(CalloutUserContext userContext,
   CalloutEntityContext entityContext,
   ref string errorMessage)
  {
   
   // Use retrive to get the status value
   CrmService service=new CrmService();
   service.CallerIdValue=new CallerId();
   service.CallerIdValue.CallerGuid=userContext.UserId;
   service.Credentials=System.Net.CredentialCache.DefaultCredentials;

   // Get status value
   ColumnSet cols=new ColumnSet();
   cols.Attributes=new String[]{“statuscode”};

   BusinessEntity busEntity= service.Retrieve(EntityName.salesorder.ToString(),entityContext.InstanceId,cols);

   salesorder poOrder=(salesorder)busEntity;
   // check for PO status value
   string poStatusValue=poOrder.statuscode.Value.ToString();

   // if status is found cancel the event and show error message
   if(poStatusValue==1)
   {
    errorMessage = “Aborting delete : Record cannot be deleted !”;
    return PreCalloutReturnValue.Abort;
   }
   
   return PreCalloutReturnValue.Continue;
  }

 Bye…

Body OnLoad function in content page in ASP.NET


Hi,

I wanted to certain script to run in the onload of the body for my content page.

To do this we need to do the following

Add an id and runat attribute to the body tag in the MASTER page

<body id=”body” runat=”server”>

And in the Content page’s  page load handler

protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl body = this.Master.FindControl(“body”) as HtmlGenericControl;
body.Attributes.Add(“onLoad”, “alert(‘Hello World’);”);
}

Bye…

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓