var totalNotes = getTotalNotes(crmForm.ObjectId);
setNoteTabName(totalNotes);
function setNoteTabName(count) {
/* update note tab */
if (crmForm.FormType != 1) {
var cells = document.getElementsByTagName("A");
for (var i = 0; i < cells.length; i++) {
if (cells[i].innerText == "Notes") {
if (count > 0) {
cells[i].innerText = "Notes (" + count + ")";
document.all.crmTabBar.style.width = "auto";
}
break;
}
}
}
}
// Helper method to return the total notes associated with an object
function getTotalNotes(objectId) {
// Define SOAP message
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\">",
GenerateAuthenticationHeader(),
"<soap:Body>",
"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>",
"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' ",
"xsi:type='q1:QueryExpression'>",
"<q1:EntityName>annotation</q1:EntityName>",
"<q1:ColumnSet xsi:type=\"q1:ColumnSet\"><q1:Attributes><q1:Attribute>createdon</q1:Attribute></q1:Attributes></q1:ColumnSet>",
"<q1:Distinct>false</q1:Distinct><q1:Criteria><q1:FilterOperator>And</q1:FilterOperator>",
"<q1:Conditions><q1:Condition><q1:AttributeName>objectid</q1:AttributeName><q1:Operator>Equal</q1:Operator>",
"<q1:Values><q1:Value xsi:type=\"xsd:string\">",
objectId,
"</q1:Value></q1:Values></q1:Condition></q1:Conditions></q1:Criteria>",
"</query>",
"</RetrieveMultiple>",
"</soap:Body>",
"</soap:Envelope>"
].join("");
var resultXml = executeSoapRequest("RetrieveMultiple", xml);
return getMultipleNodeCount(resultXml, "q1:createdon");
}
// Helper method to execute a SOAP request
function executeSoapRequest(action, xml) {
var actionUrl = "http://schemas.microsoft.com/crm/2007/WebServices/";
actionUrl += action;
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", actionUrl);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
return resultXml;
}
// Helper method to return total # of nodes from XML
function getMultipleNodeCount(tree, el) {
var e = null;
e = tree.getElementsByTagName(el);
return e.length;
}
Search
Wednesday, January 19, 2011
Showing Number of Notes on Notes Tab
Thursday, October 7, 2010
Write Event Log error -> Exception: Unhandled Exception: System.Security.SecurityException: Requested registry access is not allowed.
When trying to write an event log, sometime we hit the error "Requested registry access is not allowed."
It's due to permission on registry entry for event log.
Solution:
1. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
2. Right-click Eventlog, and then click Permissions.
3. Add Everyone and give Full Control permission.
It's due to permission on registry entry for event log.
Solution:
1. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
2. Right-click Eventlog, and then click Permissions.
3. Add Everyone and give Full Control permission.
Wednesday, September 29, 2010
Update - Microsoft Certification
Yeah just finished my second CRM exam as MCTS and received my MCP ID & Access Code (been delayed for a week due to Iverson's admin key in my email as "jhotmail.com").
Spent some time to work on my virtual business card. I like the avatar actually, pretty cool where it took in Cherating valentine trip :).
Cool??
2 exam down and 2 more to go.
Targeted to complete the rest within 2month to achieve my MCITP - Developer for Microsoft Dynamics CRM 4.0.
Stay update.........
Updated :
Got my another cert on 29 October 2010.
3 down and 1 more to go...
Spent some time to work on my virtual business card. I like the avatar actually, pretty cool where it took in Cherating valentine trip :).
Cool??
2 exam down and 2 more to go.
Targeted to complete the rest within 2month to achieve my MCITP - Developer for Microsoft Dynamics CRM 4.0.
Stay update.........
Updated :
Got my another cert on 29 October 2010.
3 down and 1 more to go...
Friday, August 27, 2010
Share Reassigned Records with Original Owner
In the Settings --> Administration --> System Settings window, right on the General Tab. There is a section marked as "Set whether reassigned records are shared with the original owner". You can then choose whether or not to share reassigned records with the original owner.
What this does is any time you reassign a record it will share the record with the previous owner. Not just the original creator, but every owner after.
Note : This will not undo anything that is already shared, but it will stop the system from sharing anything more if you don't want it to.
What this does is any time you reassign a record it will share the record with the previous owner. Not just the original creator, but every owner after.
Note : This will not undo anything that is already shared, but it will stop the system from sharing anything more if you don't want it to.
Friday, July 2, 2010
Sorting custom entities for security roles in CRM
We are busy with a huge crm implementation and currently have about 100 custom entities.
When we started to look at the security matrix for the system and it became a nightmare to set the privileges on the security roles as CRM does not sort the custom entities alphabetically.
I found a solution where add sorting to custom entities tab in security roles.
Locate the file called edit.aspx located at:
\Program Files\Microsoft Dynamics CRM\CRMWeb\Biz\Roles\edit.aspx
Add the following code in bottom of the page:
Note:
When we started to look at the security matrix for the system and it became a nightmare to set the privileges on the security roles as CRM does not sort the custom entities alphabetically.
I found a solution where add sorting to custom entities tab in security roles.
Locate the file called edit.aspx located at:
\Program Files\Microsoft Dynamics CRM\CRMWeb\Biz\Roles\edit.aspx
Add the following code in bottom of the page:
<script type="text/javascript">
var tbl = document.getElementById('tab7').children(0).children(0).children(0).children(0).children(0);
var x = [];
for (var i = 0; i < tbl.rows.length; i++)
x[i] = [tbl.rows[i].cells[0].innerHTML,tbl.rows[i].outerHTML];
var str = x[0][1];
for (var i = 1; i < x.length - 1; i++)
for (var j = i + 1; j < x.length; j++)
if (x[i][0] > x[j][0]) {//sort by alphabet
var tmp = x[j];
x[j] = x[i];
x[i] = tmp;
}
for (var i = 1; i < x.length; i++) {
var rows = x[i][1];
if ((i % 2) != 0) {//background color for odd number rows
if (rows.indexOf('<TR class=on>') > -1) {
rows = rows.replace('<TR class=on>', '<TR>');
}
}
else {//background color for even number rows
if (rows.indexOf('<TR class=on>') < 0) {
if (rows.substring(3, 5) == 'TR') {
rows = rows.replace(rows.substring(3, 5), 'TR class=on');
}
}
}
str += rows;
}
document.getElementById('tab7').children(0).children(0).children(0).children(0).innerHTML = '<TABLE class=ms-crm-Form-Area onmouseover=SetAltText(); ondblclick=ProcessClick(); onclick=ProcessClick(); cellSpacing=0 cellPadding=2><COL><COL width=70><COL width=70><COL width=70><COL width=70><COL width=70><COL width=70><COL width=70><COL width=70>'+ str + '</table>';
</script>
Note:
- This is unsupported. Please do backup before editing.
Friday, May 21, 2010
Collapsable CRM section
attachCollapsableToSections();
function getElementsByCondition(condition, container) {
container = container || document;
var all = container.all || container.getElementsByTagName('*');
var arr = [];
for (var k = 0; k < all.length; k++) {
var elm = all[k];
if (condition(elm, k)) arr[arr.length] = elm;
} return arr;
}
function attachCollapsableToSections() {
var sections = getElementsByCondition(function(elm) {
if (elm.className.indexOf("ms-crm-Form-Section") != -1)
return true;
}, null);
for (var i = 0; i < sections.length; i++) {
sections[i].innerHTML = '<img id="' + i + '_imgid" src="/_imgs/navup.gif" alt="Expanded, click to collapse" style="cursor:hand;"/> <label id="' + i + '_lblid" />' + sections[i].innerHTML;
sections[i].childNodes[0].attachEvent('onclick', toggleVisibility);
sections[i].childNodes[2].attachEvent('onclick', toggleVisibility);
}
}
function toggleVisibility(e) {
var sectionContainer = e.srcElement.parentNode.parentNode.parentNode;
var elements = getElementsByCondition(function(elm) {
if (elm.vAlign == "top") return true;
}, sectionContainer);
for (var i = 0; i < elements.length; i++) {
if (elements[i].style.display == "none") {
elements[i].style.display = "";
if (e.srcElement.id.indexOf("_lblid") != -1) {
var _imgid;
_imgid = e.srcElement.id.replace(/(^\d+)(.+$)/i, '$1') + "_imgid";
document.getElementById(_imgid).src = document.getElementById(_imgid).src.replace("navdown", "navup");
}
else {
e.srcElement.src = e.srcElement.src.replace("navdown", "navup");
}
} else {
elements[i].style.display = "none";
if (e.srcElement.id.indexOf("_lblid") != -1) {
var _imgid;
_imgid = e.srcElement.id.replace(/(^\d+)(.+$)/i, '$1') + "_imgid";
document.getElementById(_imgid).src = document.getElementById(_imgid).src.replace("navup", "navdown");
}
else {
e.srcElement.src = e.srcElement.src.replace("navup", "navdown");
}
}
}
}
Tuesday, May 11, 2010
LINQ on CRM SDK 4.0.12
- Download here.
- Generate linq code for CRM, from a command line – go to the SDK folder/Microsoft.xrm/Tools and run the following command line – replacing MyCrmServer with your actual server name, replace MyCrmOrg with your actual CRM Org and MyEntitiesFolder with the name. Note : This assumes using integrated authentication for on-premise – support is available for many different scenarios – check the docs.
crmsvcutil /connectionString:"Authentication Type=AD; Server=http://servername/crm_orgname; User ID=domain\username; Password=password;" /out:"C:\Entities"
I’m very excited to talk about the new LINQ to CRM libraries available recently. Say you need to retrieve an Account Number, given the Account Name…
Using the traditional webservice methods:
ColumnSet cols = new ColumnSet();
cols.AddColumns(new string[] {"accountnumber"});
QueryByAttribute query = new QueryByAttribute();
query.ColumnSet = cols;
query.EntityName = "account";
query.Attributes = new string[] {"name"};
query.Values = new string[] {"Microsoft Dynamics CRM"};
RetrieveMultipleRequest req = new RetrieveMultipleRequest();
req.Query = query;
req.ReturnDynamicEntities = true;
RetrieveMultipleResponse resp = oService.Execute(req) as RetrieveMultipleResponse;
BusinessEntityCollection becMultipleRecords = resp.BusinessEntityCollection;
if (deSalesOrder.Properties.Contains("accountnumber"))
{
//And So On
//And So Forth
}
Using LINQ to SQL:
var accounts = (from a in context.Accounts
where a.Name.Equals("Microsoft Dynamics CRM")
select a).ToList();
LINQ2CRM.Account acc = (Account)accounts.First();
Response.Write("Account name = " + acc.Name.ToString());
Subscribe to:
Posts (Atom)
