Security Role based Actions

function CheckUserRole() {

var isTrue = UserHasRole(“System Administrator”);

if (isTrue) {

alert(‘You are Admin’);

 }

else {

alert(‘You are not Admin’);

 

}

}

function UserHasRole(roleName) {

debugger;

var serverUrl = Xrm.Page.context.getClientUrl();

var oDataEndpointUrl = serverUrl + “/XRMServices/2011/OrganizationData.svc/”;

oDataEndpointUrl += “RoleSet?$top=1&$filter=Name eq ‘” + roleName + “‘”;

var service = GetRequestObject();

if (service != null) {

service.open(“GET”, oDataEndpointUrl, false);

service.setRequestHeader(“X-Requested-Width”, “XMLHttpRequest”);

service.setRequestHeader(“Accept”, “application/json, text/javascript, */*”);

service.send(null);

var requestResults = eval(‘(‘ + service.responseText + ‘)’).d;

// Change Started

if (requestResults != null && requestResults.results.length == 1) {

var role = requestResults.results[0];

// Change Ended

var id = role.RoleId;

var currentUserRoles = Xrm.Page.context.getUserRoles();

for (var i = 0; i < currentUserRoles.length; i++) {

var userRole = currentUserRoles[i];

if (GuidsAreEqual(userRole, id)) {

return true;

}

}

}

}

return false;

}

function GetRequestObject() {

if (window.XMLHttpRequest) {

return new window.XMLHttpRequest;

}

else {

try {

return new ActiveXObject(“MSXML2.XMLHTTP.3.0”);

}

catch (ex) {

return null;

}

}

}

function GuidsAreEqual(guid1, guid2) {

var isEqual = false;

if (guid1 == null || guid2 == null) {

isEqual = false;

}

else {

isEqual = guid1.replace(/[{}]/g, “”).toLowerCase() == guid2.replace(/[{}]/g, “”).toLowerCase();

}

return isEqual;

}

 

Posted in Uncategorized | Leave a comment

What is the difference between Service.Create and SvcContext.AddObject?

What is the difference between Service.Create and SvcContext.AddObject?

Service.Create: This Method directly creates record, uses the raw create of the organization service proxy.

Service.addObject: This operation use the OrganizationServiceContext, which implements the Unit of Work patter, this operation is not transmitted to the server until you call SavceChanges()

The entity is put into the tracking set of the OrganizationServiceContext in the Added state. The OrganizationServiceContext will attempt to insert the entity into the CRM on the next call to the SaveChanges. This method does not add entities and related to the specified entity to the OrganizationServiceContext. Each object must be added through a separate call to AddObject.

Example 1
account _account = new account();
{
_account.name = “Name_Test”
}
service.Create(_account) 

Example 2
var svcContext= new OrganizationServiceConext(service)
svcContext.AddObject(record);
svcContext.SaveChanges();

Posted in Uncategorized | Leave a comment

How to Implement Enable and Disable custom button using Ribbon Workbench

How to Implement Enable and Disable custom button using Ribbon Workbench

1. Create a Custom Button on your desired entity. In this case Lets assume you want to Create a button on “Quote” Entity
2. Create a Desired Option, I am using Status Code, with custom status called “Ready for a Quote”
3. I want this button by defeault disabled and only visible When the status moved to “Ready for a Quote”
4. Create button using ribbon work bench
5. Create enable rule as follows
6. Call the rule into Command button

E.g Statuscode = ReadyForQuote = ShowButton Value = 100000088

Enable Rule
Default=True
Field=StatusCode
InvertResult=False
Value=100000088

Posted in Uncategorized | Leave a comment

MSCRM Toolkit: Workflow Execution Manager

Workflow Execution Manager is one of the best tool, I have used for bulk updating records in CRM.  I have used this tool in 2013 and 2015. The result and performance is very good. It has really save lot of time from creating your own custom console application. or Manually selecting and running bulk update.

This uses the power of Workflow, FetchXML Query, with a minimum configuration from this tool, you can schedule the jobs to push the data into CRM.

The best thing about this tool is running workflow on more than 250 records. It works fantastic on the FetchXML query. You design a view get the Fetch query, run the workflow refresh the view to see the result get updated.

What you need, to do bulk update with this tool.
1. A fully test workflow: Create a workflow and test this with all your condition and try to run it manually, ensure it is fully qualified to update records.

2. A View for Data verification: Create view with all your condition and pull all the records on which the workflow needs to be run.

3. A FetchXML Query: Use the above view and download the FetchXml query.

The tool can be download from the following link and steps are specified to configure the Solution.

http://mscrmtoolkit.codeplex.com/documentation#workflowexecutionmanager

Note: If it is CRM Online, just make sure you have the correct OrgName, sometime it is slightly different from URL that you

are using.

Once all connection is setup, you can schedule all the workflow in bulk and Click on Execuate workflow.
The bulk workflows are launched in CRM and from there id CRM to job to update the data.

I use 10000 records per bactch so that I can verify the workflow and data. it took less than 30 min to launch the workflow.

You can run this for many thousands of records.

Posted in Uncategorized | Leave a comment

CRM 2015 Update 1.0: Revise Quote does not respond

Issue

After upgrading from CRM 2015 to Update 1.0, the Revise Quote functionalities does not work, when I click on the button it shows nothing, no error message, no form load, no status change. Current status of the form is Active and Read Only .

Cause

Some of the Standard OOB attributes that are required for this functionalities to complete are not available on the form.

Attributes: Description, Freight Amount (Base)

Resolution

Place the above said attributes on the form try to make use of it. If you feel it is not required hide label and field from form.

Save form and publish. Try to Activate Quote and Revise, form should change to draft status for you revise/update the quote.

Note: This issue occurs only on CRM 2015 Update 1.0. Turbo form, if you must use legacy form and do not face this issue, don’t bother to make the changes. however keep in mind that legacy form option will be removed from future release.

Posted in Uncategorized | Leave a comment

Jscript unable to get property ‘$o_3’ of undefined or null reference CRM 2015 Update1.0

This error got introduced on CRM 2015 after upgrading to 1.0.

Error:

CRM2015Update1.0Propertyo_3error

Error Message:

unable to get property ‘$o_3’ of undefined or null reference

Cause:

This error caused due to unsupported customization in the Java script on form load. The new form rendering mechanism does not recognise this script. using document.getElementById is unsupported. If you are using pre-filter default view on form load, this error will pop-up.

Note that this error only occurs when you turn on the “Use Legacy form rendering”

CRM2015 Use Legacy Form rendering

You only need to turn on this form rendering, when there is lot of JS functionality is used and not behaving in intended manner.

Solution:

If you are trying to add a custom view to the lookup and set that as the default, then you can use the

Xrm.Page.ui.controls.get(“[tablename]”).addCustomView(viewID, “[tablename]”, “[viewname]”, “[fetchXMLString]”, “[TSAlayoutXMLstring]”, true);

Posted in Uncategorized | 5 Comments

How to Import Contact for existing Accounts

Please remember you are only importing Contacts referencing to Account. This means you are going find out existing Account and tag all the contacts that you are going to import into CRM System.

One-Account-Will have many contacts. This will display all the contacts associated to the account you are mapping.

Data Mapping

You can use existing data mapping from CRM “Generic contacts and accounts” to import data.

You will see both (Account and Contact) entities displayed at the left hand side. Our aim is to push only contact for the existing accounts. we select only Contact and start the mapping.

  1. Mandatory lastName is displayed at the top so you can do direct mapping.
  2. when comes to other fields mapping choose respective fields and do the mapping, ensure it is all coming from contact entity only.
  3. Now lastly map CompanyName lookup option will dropdown choose account only.

Click next to proceed and when you done mapping all the fields until you hit finish button .

Data import system  jobs for any error and continue to fix.

I only foresee one error, that if there is duplicate company exist, contact may not be imported correctly. So just ensure duplicate account does not exist.

Not even, deactivated duplicate accounts.

This is way you can separate the accounts and contact in two jobs to import separately and link them.

I have migrated and tested 10000 records so far all seems to be good.

Posted in Uncategorized | Leave a comment

CRM 2015: Plug-in Trace Log

CRM 2015: Plug-in Trace Log

 

CRM 2015 Update 1 has a new feature that is more relevant to Error Logging on the CRM Application itself.

Plug-in Trace Log is a new feature that has been introduced with CRM 2015 Update 1. This feature now gives the flexibility to the system administrator and developers to configure it in CRM and write the trace into new CRM Entity. This could be one of the very good feature for the CRM Online project/product development, where you can have the complete solution clubbed into one packaged.

  1. In the past if we need to log error in CRM, it needs to be designed and we use to manually create custom entity and write errors into it. Or use “Download log” dialog to download error details, well now CRM does provide its own standard entity to write these logs like System jobs.
  2. These logs can be viewed within CRM application in Trace Log Entity.
  3. Trace Log entity can be found under Settings>>Administrator>>Customization>> Trace Log Entity
  4. There are 3 configurable options are provided
    1. Off (Default): turn off the feature.
    2. Exceptions: The trace log will be written to CRM entities, only the developers
    3. All: The Trace logs will be written to the CRM entities when the plug-in or workflow code is run regardless of whether and exception is returned.
  5. Select any of the option given and click ok to configure trace log.
  6. Once this is enabled, you should be able to view logs written CRM from with CRM Web Application.
  7. To view the logs In CRM Application go to Settings>>and Under the Customization menu, select Plug-in Trace Logs.
  8. Similar to System Jobs you will be able to see the error listed.
  9. This entity can also be found from advance find.
    I have listed few screenshots to get better idea.
    TraceLog3

     

    TraceLog1 

TraceLog2 

 

Posted in Uncategorized | Leave a comment

CRM Diagnostics tool to understand Network performance

Network performance is a key factor to understand better on how CRM Application performs. Many times we hear from remote users, complaining that the application is loading slowly. There could be several other reasons, there are several methods to test network performance. CRM by default offers this diagnostics tool since Update Rollup 4 to check CRM application performance. This diagnostic tool helps produces a simple report on bandwidth, latency and JavaScript rending performance.

This diagnostic page will issue series of pings from client to server and transfer several blobs of data. Based on this data it will provide the latency in milliseconds and max transfer speed achieved. This is a quick and easy to identify the network performance without having to install any tools on client or server. It helps us to gather some baseline performance from various locations and determine expected response times based on the users bandwidth and latency. This should be considered for CRM environment planning to provide best user experience.

So how to interpret this report, based on Microsoft document Optimizing and Maintaining Client Performance for Microsoft Dynamics CRM 2011 and CRM Online it states that CRM is designed to work with latency under 150 milliseconds.

To use the diagnostics page you can simply browse to the page by using the URL http://<YourCRMServerURL>/tools/diagnostics/diag.aspx and click the Run button to start the tests. This page is available for both CRM Online and OnPremise.

CRMDiagnostics

Posted in Uncategorized | Tagged | Leave a comment

Not able to activate CRM 2013 List component in SharePoint?

Hello All,

I have been facing this weird problem, unable to activate List component in SharePoint.
I am successfully able to install the list components when I click on “Activate” nothing happens. If you assume it is activated and try to integrate the Document management from CRM it will not work.|
If you experience the same problem, try the below steps hope it helps.

Resolution: Start “Microsoft SharePoint Foundation Sandboxed Code Service”

To Run the Microsoft SharePoint Foundation Sandboxed Code Service, follow the below steps.

1. SharePoint Central Administrator
2. Under>> Service Applications
3. Manage services on server
4. Look for>>Microsoft SharePoint Foundation Sandboxed Code Service is running
5. Start the service

After completing all the 5 steps

To Install List Components in SharePoint

1. Go to Site Settings
2. Under>> Web Designer Gallery>> Click on “Solutions”
3. Click on Upload solution
4. and Click on Activate

To Set Broser File handling to Permissive

1. Go to SharePoint Central Administration
2. Application Management
3. On the Ribbon click onthe General Setting
4. Web Application Generation Setting pop-up window will appear
5. Scroll down to look for Browser file handling >> Select >>Permissive
6. Click Ok, save settings and restart the server/IIS
7. try to Activate the List compoent
8. Ensure the after successful activation will enable the Deactivate button.
9. Sometime it is very annoying you need to do several click to get this working.
10. Go to CRM and add the URL into Document management, all will work fine.

Posted in Uncategorized | 2 Comments