Search

Tuesday, March 22, 2011

CRM stop working after imported SiteMap

Sometimes change the SiteMap by adding privileges to hide area for some users will cause an error.

















From event log,

Exception type: ArgumentException
Exception message: Invalid privilegeId: ReadDeep
Parameter name: privilegeId


Solution:

Just browse through following link and do import of the backup Sitemap

http://HostName/OrganizationName/tools/solution/import/SolutionImportWizard.aspx


Monday, March 14, 2011

CRM 2011 Javascript Intellisense

With Visual Studio 2008 onwards, we can have some javascripts intellisense when writing our codes. However, Visual Studio doesn’t know anything about MS CRM. So we don’t get a lot of advantage from this but we can extend the use of the intellisense functionality by using MS CRM Javascript Intellisense Generator
Once downloaded the tool, all you need to do is enter the name of the discovery server and (optional) the credentials, select the organization and save the output. This will create the folder with 1 javascript file for each entity.
 
If you have Visual Studio open you will need to close and reopen your project to see the new folder.All that is left is adding a reference in you account.js file to let visual studio know where to look for intellisense.
 















*Updated for CRM 2011 Xrm.Page.
Download this js file XrmPage-vsdoc.js and now you can have IntelliSense for Xrm.Page.

Tuesday, February 22, 2011

Tips - Installing Microsoft CRM for Outlook Offline with SQL 2008 Express

You have to name your SQL 2008 Express instance “CRM” before installing CRM for Outlook with Offline Access.

When CRM for Outlook installation, it looks for an instance called “CRM,” and if it doesn’t exist, it downloads and installs SQL 2008 Express.

Tuesday, February 1, 2011

Impersonation



//createdby     - user 1
//owner         - user 2
//impersonate   - crm-service
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; // Use Active Directory authentication.
token.OrganizationName = "LP";

// Use the global user ID of the system user that is to be impersonated.
token.CallerId = new Guid("C0C0A8E9-A72D-E011-80B9-00155DC85005"); //user 1

CrmService crmService = new CrmService();
crmService.Url = "http://tl:5555/MSCRMServices/2007/CrmService.asmx";
crmService.CrmAuthenticationTokenValue = token;
crmService.Credentials = new System.Net.NetworkCredential("CRM-Service", "Password2k", "company");

// Create a new account owned by the impersonated user.
account account = new account();
account.name = "Fabrikam !!";
Owner owner = new Owner();
owner.Value = new Guid("D57CC3F3-A92D-E011-80B9-00155DC85005"); //user 2
owner.type = EntityName.systemuser.ToString();
account.ownerid = owner;
Guid accountid = crmService.Create(account);

Wednesday, January 19, 2011

Showing Number of Notes on Notes Tab

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;
}

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.