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…

Server Application Unavailable in ASP.NET 2.0


Hi,

I was getting this error when trying to open a asp.net 2.0 page.

However other applications developed in asp.net 1.1 were running fine.

Then realized that both of them were using the same Application Pool, so created a new application pool and assigned this new application pool to my asp.net 2.0 application.

That solved the issue.

“An application pool is a process that responds to web requests under IIS. An application pool does not have a setting for what type of ASP.Net applications will be run in it. Instead, it loads the appropriate libraries when an ASP.Net application is loaded in the process. Because the libraries for ASP.Net 1.1 and ASP.Net 2.0 are similar, but not the same, the application pool cannot respond to requests for both types of applications at the same time. This can cause sporadic behavior if you are using the server at the same time as another developer and you have applications using different versions of the framework in the same application pool”

Bye..

Recalculate and SubmitCrmForm JavaScript function in CRM


Hi,

I was trying to figure out what the recalcuate button does in case of Order and Quote form. Got to know that it calculates the total based on the Products added to that record. Behind the scene this is the html code for the recalculate button

<li tabIndex=”-1″ title=”Recalculate” id=”_MBcrmFormSubmitCrmForm1truetruefalse”
onclick=”window.execScript(action)”
action=”crmForm.SubmitCrmForm(1, true, true, false);”>

So basically it calls SubmitCrmForm function.

SubmitCrmForm triggers the save event even if there are no modifications made on the form.

SubmitCRMForm( Mode, Validate, ForceSubmit, closeWindow)        // we could use this function but it is unsupported

Different Mode could be -1,2,7,58,59

or alternatively we could use the below function

Save
Code: 1
Function: crmForm.Save();

SaveAndClose
Code: 2
Function: crmForm.SaveAndClose();

Send
Code: 7
Function: send();

SaveAsCompleted
Code: 58
Function: SaveAsCompleted();

SaveAndNew
Code: 59
Function: crmForm.SubmitCrmForm(59, true, true, false);

Bye…

Finding the id of the element using IE Developer tool.


With IE Developer Tool, to find the id, we need to do the following

Select developer tools and

clip_image001

then “select element by click” in find menu of dev tool.

clip_image002

And then select the element whose id we want

clip_image003

The id would be within the Li element within the attributes tab, select it

clip_image004

 

That’s  it ..

Consuming CurrencyConverter web service through JavaScript


Hi,

For getting the currency conversion rate we could use the following web service provided by Generic Objects Technologies Ltd.

Check out the web services provided by them

http://www.webservicex.net/WCF/webServices.aspx

To consume their currency converter web service

http://www.webservicex.net/CurrencyConvertor.asmx we could use the following JavaScript code

var xmlHttp;
function SoapCall() {
// creatng the xmlHttp object
xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
// Calling the web service using post and true means asynchronous call
xmlHttp.open(“post”, “http://www.webservicex.net/CurrencyConvertor.asmx&#8221;, false);
// Setting the request header to let the web service identify the soap request we would be sending

xmlHttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);

xmlHttp.setRequestHeader(“SOAPAction”, “http://www.webserviceX.NET/ConversionRate&#8221;);

var soapRequest = “<?xml version=’1.0′ encoding=’utf-8′?> ” +
“<soap12:Envelope xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance&#8217; xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:soap12=’http://www.w3.org/2003/05/soap-envelope’>&#8221; +
” <soap12:Body>” +
”   <ConversionRate xmlns=’http://www.webserviceX.NET/’>&#8221; +
”     <FromCurrency>USD</FromCurrency>” +
”    <ToCurrency>INR</ToCurrency>” +
”  </ConversionRate>” +
“</soap12:Body>” +
“</soap12:Envelope>”;

xmlHttp.send(soapRequest);
alert(xmlHttp.responseText);

}


Bye..