How to get "Object Type Code"in CRM for roll-up 12, How to disable view picker in crm 2011,how to disable New button in lookup dialog, how to call workflow with java script, how to attach event in rollup 12,All java scripts for rollup 12.
1.Java Script for getting "object type code" of a crm entity :-
For
Rollup 11,
var
EntityTypeCode = crmForm.ObjectTypeCode;
For
Rollup 12,13 for cross browser support.
var
EntityTypeCode = Xrm.Page.context.getQueryStringParameters().etc;
2.Java Script for disabling filter lookup view selector :-
For
Rollup 11,
document.getElementById(“Lookup Id").disableViewPicker = 1;
For
Rollup 12,13 for cross browser support.
document.getElementById("Lookup Id")._behaviors[0].AddParam("DisableViewPicker", "1");
document.getElementById("Lookup Id ")._behaviors[0].set_showProperty(1);
3.Java Script for hiding New Button in filter lookup dialog :-
For
Rollup 11,
crmForm.all.Lookup Id.AddParam("ShowNewButton", "0");
For
Rollup 12,13 for cross browser support.
document.getElementById("Lookup Id")._behaviors[0].AddParam("ShowNewButton", "0");
document.getElementById("Lookup Id")._behaviors[0].set_showProperty(0);
4.Java Script for executing a workflow with java script :-
For
Rollup 11,
var WorkflowId = "9533D5BB-A8FB-4D4C-A6E5-272F7C90EDC0";//Work
flow guid to execute
var soapBody = "<soap:Body>"
+
"<Execute
xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
"<Request
xsi:type=\'ExecuteWorkflowRequest\'>" +
"<EntityId>" + Entity Id + "</EntityId>" +
"<WorkflowId>" + WorkflowId +
"</WorkflowId>" +
"</Request>" +
"</Execute>" +
"</soap:Body>";
var soapXml = "<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'>"
+
GenerateAuthenticationHeader() +
soapBody +
"</soap:Envelope>";
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", "/MSCRMservices/2007/crmservice.asmx",
false);
xmlhttp.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlhttp.send(soapXml);
For
Rollup 12,13 and for cross browser support.
var WorkflowId = "9533D5BB-A8FB-4D4C-A6E5-272F7C90EDC0";//Work
flow guid to execute
var soapBody = "<soap:Body>"
+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"
+
"<Request
xsi:type=\'ExecuteWorkflowRequest\'>" +
"<EntityId>" + Entity Id + "</EntityId>" +
"<WorkflowId>" + WorkflowId +
"</WorkflowId>" +
"</Request>" +
"</Execute>" +
"</soap:Body>";
var soapXml = "<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'>"
+
GenerateAuthenticationHeader() +
soapBody +
"</soap:Envelope>";
var xmlHttpRequest;
var doc;
var result;
if (window.XMLHttpRequest) {//
code for IE7+, Firefox, Chrome
xmlHttpRequest
= new XMLHttpRequest();
xmlHttpRequest.open("POST", "/mscrmservices/2007/CrmService.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", soapXml.length);
xmlHttpRequest.send(soapXml);
5.Java Script for attach click event :-
For
Rollup 11,
//Function
Definition
FunctionName(Function
parameters)
{
//
write your code
}
var elment = document.getElementById(“grid id”);
var func = "var
efunction=function() { " +
"FunctionName(Function parameters);"
+
" };";
eval(func);
//Attach
to click event
elment.attachEvent("onclick", ef, false);
For
Rollup 12,13 and for cross browser support.
FunctionName(Function
parameters)
{
//
write your code
}
var elment = document.getElementById(“grid id”);
var func = "var
efunction=function() { " +
"FunctionName(Function parameters);"
+
" };";
eval(func);
if (elment!=null)
{
if(elment.attachEvent!=null)
{
elment.attachEvent("onclick",
efunction, false);
}
else {
var grid = Xrm.Page.getControl(grid
id)._control.get_innerControl();
grid._events.addHandler('OnClick',
ef);
grid.onclick = efunction;
}
}
and it
will work in IE7+, Mozila and in Crome properly
Enjoy the great technology Dynamics CRM. Good luck.....!!!!!
2 comments:
Thanks for ur post. Really helpfull.
It will help u to get Object type code of an entity with java script for roll up 12,13
Post a Comment