This is a new code sample for calling a web service using Javascript/Jscript, but specially to call my web services on the same server that MSCRMServices is located.
The difference on this sample code is that I'm enabling the web service call using the RemoteCommand functions available under the following folder Inetpub\wwwroot\_controls\RemoteCommands\RemoteCommand.js, also Ronald Lemmen have a good blog on how to call internal CRM SDK services, but in this case I will be calling My special web service that will give me a True/False value for a specific Case, the process will validate if the Case have any Open Activities (Any Type of Activity)
The code is simple to implement, there is 3 sections for the sample
- The Case OnLoad event change
- The General definition for calling my Web Service, Global.js modifications
- The web service that will process the Case Activities
So lets see the Case OnLoad Code
if(crmForm.FormType == CRM_FORM_TYPE_UPDATE)
{
// crmFormSubmit.crmFormSubmitId.value is the Case ID sent as part of the querystring
var caseid= crmFormSubmit.crmFormSubmitId.value;
var iscaseValidforclose = IncidentValidForClose(caseid);
if (iscaseValidforclose == false)
{
alert("\r\n Please Close all Open Activities,\r\n\r\nBefore Resolving the Case!\r\n");
}
}
This is the Global.js code that will make the web service call
// IncidentValidForClose
// Web Service Call
//
// Abe Saldana
// This all is undocumented and unsupported.
// Therefore you should only try these kind of modifications
// if you feel comfortable with this.
function IncidentValidForClose(caseid)
{
var isIncidentValidForClose;
isIncidentValidForClose = true;
try
{
// Calling the Local Web service located on the following
// folder \Inetpub\wwwroot\MSCRMServices\CRMcustom\CRMCustom.asmx
var oCommand = new RemoteCommand("CRMCustom","IncidentValidForClose","/MSCRMServices/CRMcustom/");
// Passing the parameters
oCommand.SetParameter("CaseID",caseid);
// Making the call
var oResult = oCommand.Execute();
if (oResult.Success)
{
// Success Return Value
isIncidentValidForClose = oResult.ReturnValue;
alert("caseid: " + caseid + "Response: " + oResult.ReturnValue.toString());
}else
{
// Failed response or Default response
alert("caseid: " + caseid + "Response: " + oResult.ReturnValue.toString());
}
}catch (e)
{
alert(e.description);
isIncidentValidForClose = true;
}
return isIncidentValidForClose;
}
The web service code is located on a zip file plase follow the installation instructions to have a successful installation also make the correct Web.config changes for your environment, code is available here

Download the CRMCustomWS.zip file with the sample code.
You can copy and past the functions as the code for the Case OnLoad event. if you copy and past the last function on the Global.js make sure to change the reference to the web services to "/MSCRMServices/" and change to any SDK method call you want to make.
So I will use this blog to say: "Thanks to Ronald Lemmen for his code and detail information on how to acomodate these JScript calls"...
Abe Saldana.
This all is undocumented and unsupported. Therefore you should only try these kind of modifications if you feel comfortable with this.
Everything here, though, is my personal opinion and is not read nor approved before being posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.