Friday, August 31, 2012

Privileges Problems!!!


Dear All,
If you are facing with the below error
 You don’t have enough privileges to access the Microsoft Dynamics CRM object or perform the requested operation. For more information ,Contact your Microsoft Dynamics CRM administrator.

Check the Append and AppendTo privileges for that particular entity set to Org level.

Limit the No. of records per page in MS CRM


if the user want to see only 10 records per view in the entire CRM
You can set this in the Personal options by setting the Records Per Page:
Though records per page can set minimum 25 and  maximum  250.
if some one wants to restrict to 10 records per page??
Then run the below SQL against the Organization you desired to do so.
update UserSettings  set PagingLimit=10 where SystemUserId='User GUID'

Friday, August 24, 2012

How to Speed up the Performance of MS CRM Forms

  • Add your CRM site to the list of trusted sites
  • Disable Form Assistant
  • When you have scores of data in the CRM database, the Form Assistant loads the data during the form loads. Shutting this functionality off could greatly boost the loading time of the form.
  • Disable Antivirus scan for CRM site
  • One of the major factors that affect CRM's performance is the Antivirus scan. Disabling this, the difference in load time of the form becomes quite noticible.
  • Use a higher version on IE. (IE7 or higher)

Thursday, August 23, 2012

How to save a record in CRM 2011 using javascript


In CRM 2011, you could save an entity record using javascript.
There are 3 types of save possible using javascript in CRM 2011.

1. Equivalent to 'SAVE' button found on the entity form
Xrm.Page.data.entity.save();

2. Equivalent to 'SAVE AND NEW' button found on the entity form
Xrm.Page.data.entity.save('saveandnew');

3. Equivalent to 'SAVE AND CLOSE'  button found on the entity form
Xrm.Page.data.entity.save('saveandclose');

Wednesday, August 22, 2012

Checking condition for last 15 days date using JavaScript in MS CRM


var currentDate = new Date();
var dateOfContact = crmForm.all.new_submissiondate.DataValue;
if(dateOfContact != null)
{
  var pastMaxDate = new Date();

  currentDate.setHours(0);
  currentDate.setMinutes(0);
  currentDate.setSeconds(0); 
  currentDate.setMilliseconds(0);
 
  pastMaxDate.setDate(currentDate.getDate()-14);
  pastMaxDate.setHours(0);
  pastMaxDate.setMinutes(0);
  pastMaxDate.setSeconds(0);
  pastMaxDate.setMilliseconds(0);

  //Checking condition for last 15 days
  if( !((dateOfContact <= currentDate) && (dateOfContact >= pastMaxDate)) )
  {
    crmForm.all.new_submissiondate.DataValue = null;
    alert("Valid date range is from "+ pastMaxDate.toLocaleDateString() + " to till today.");
  }
}

Tuesday, August 21, 2012

Microsoft Dynamics CRM E-mail Router


Email router will not send any mails unless we configure Outlook.
We cannot install CRM Email in Windows Server 2008 32-bit editions, Windows Server 2003, Windows Vista, and Windows XP editions are not supported for installing and running Microsoft Dynamics CRM E-mail Router or E-mail Router Configuration Manager.

Please refer the below link for further assistance

Friday, August 17, 2012

Check the User Security Role in CRM 2011/4.0 using JScript


if(UserHasRole("System Administrator")==true)
{
alert("System Administrator");
}
if(UserHasRole("SalesHead")==true)
{
alert("SalesHead");
}

function UserHasRole(roleName)  
{  
 //get Current User Roles, oXml is an object  
 var oXml = GetCurrentUserRoles();  
 if(oXml != null)  
 {  
  //select the node text  
  var roles = oXml.selectNodes("//BusinessEntity/q1:name");  
  if(roles != null)  
  {  
   for( i = 0; i < roles.length; i++)  
   {  
    if(roles[i].text == roleName)  
    {  
     //return true if user has this role  
     return true;  
    }  
   }  
  }  
 }  
 //otherwise return false  
 return false;  

  
function GetCurrentUserRoles()  
{  
 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>role</q1:EntityName>" +  
 " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +  
 " <q1:Attributes>" +  
 " <q1:Attribute>name</q1:Attribute>" +  
 " </q1:Attributes>" +  
 " </q1:ColumnSet>" +  
 " <q1:Distinct>false</q1:Distinct>" +  
 " <q1:LinkEntities>" +  
 " <q1:LinkEntity>" +  
 " <q1:LinkFromAttributeName>roleid</q1:LinkFromAttributeName>" +  
 " <q1:LinkFromEntityName>role</q1:LinkFromEntityName>" +  
 " <q1:LinkToEntityName>systemuserroles</q1:LinkToEntityName>" +  
 " <q1:LinkToAttributeName>roleid</q1:LinkToAttributeName>" +  
 " <q1:JoinOperator>Inner</q1:JoinOperator>" +  
 " <q1:LinkEntities>" +  
 " <q1:LinkEntity>" +  
 " <q1:LinkFromAttributeName>systemuserid</q1:LinkFromAttributeName>" +  
 " <q1:LinkFromEntityName>systemuserroles</q1:LinkFromEntityName>" +  
 " <q1:LinkToEntityName>systemuser</q1:LinkToEntityName>" +  
 " <q1:LinkToAttributeName>systemuserid</q1:LinkToAttributeName>" +  
 " <q1:JoinOperator>Inner</q1:JoinOperator>" +  
 " <q1:LinkCriteria>" +  
 " <q1:FilterOperator>And</q1:FilterOperator>" +  
 " <q1:Conditions>" +  
 " <q1:Condition>" +  
 " <q1:AttributeName>systemuserid</q1:AttributeName>" +  
 " <q1:Operator>EqualUserId</q1:Operator>" +  
 " </q1:Condition>" +  
 " </q1:Conditions>" +  
 " </q1:LinkCriteria>" +  
 " </q1:LinkEntity>" +  
 " </q1:LinkEntities>" +  
 " </q1:LinkEntity>" +  
 " </q1:LinkEntities>" +  
 " </query>" +  
 " </RetrieveMultiple>" +  
 " </soap:Body>" +  
 "</soap:Envelope>" +  
 "";  
  
 var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");  
  xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);  
 xmlHttpRequest.setRequestHeader("SOAPAction"," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");  
 xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");  
 xmlHttpRequest.setRequestHeader("Content-Length", xml.length);  
 xmlHttpRequest.send(xml);  
  
 var resultXml = xmlHttpRequest.responseXML;  
 return(resultXml);  
}


Go to Entitiesà Select an entityà Forms [Open the main Form]à select Form Properties à the below screen will appearsà click on Add à create new àcopy the above code and publish



Note: No need to add any Function in Event Handlers. 
we can use the same code in CRM 4.0 Form OnLoad.