Friday 27 April 2018

Dynamics CRM: Chrome Console


Declaration: - This article is only for learning purpose. Use these articles only in development environment. I am not prompting this to use in any production environment.
This article only for CRM developer. I am not prompting this to use by any end customer.



Problem: - As a developer some type we do not remember each, and every function given by XRM library or some time syntax not correct. We can find many options to add XRM intellisense in for visual studio. XRM Intellisense
But some time if we do not have access to visual studio? And these intellisense are not updated automatically when our Dynamics CRM versions are update and we are not aware about new function added or removed by Microsoft.
Or If there is any beginner who not aware of function present in XRM Javascript library.



Solution: -
As we aware Chrome give better performance for Dynamics 365 as compared to Internet Explore.
Here, I am going to introduce one another great feature of Chrome that is “Console”. We mostly use console.log(“our message”) in Javascript to write information or error that can help us later.
But we can also use Chrome Console option to use XRM intellisense.



Steps: -
  1. Open your development Dynamics CRM environment. Navigate to any CRM record. I am taking case record for example.
















2.Go to form property and add a function onSave event. That function need to have debugger; so our Chrome Debugger tools can work.

















3. I am using a sample function which only contain debugger statement.
function test()
{
debugger;
}
If debugger is not written in our code, we will receive real time or property will return null.
4. Publish your changes and refresh your record page (Press Ctrl+ r)
Now we are ready to use Chrome Console.
5. Press F12 or Ctrl+ Shift + I or using Chrome tools option to open developer tool.




















6. Now Click on save button this transfer control to Developer Tools.

















7. Go to “Console” tab of developer tools.

When you start typing X it intellisense will start working. As in below image I have entered Xrm.Page.ge

It starts showing all available functions.
















Even we can check how our code will behave same as written in Javascript file.

In my example I am using Xrm.Page.getAttribute('description') function. When you click on _proto_: link it will start showing all the method available to “getAttribute” method for field type “Single line text”















You will also see some additional method for “Lookup” attribute which is normally not shown in any intellisense.



















Even when you use make any change it will show real time. I am going to change attribute required level using this.
Without My code











After using code: -
 Xrm.Page.getAttribute('description').getRequiredLevel('required')










We have changed form behavior without writing any code in our Javascript file. So, we can use intellisense and real time code impacts.
This Console can also override Dynamics 365 customization. But this will not breach field level security field, which is great.

Example: - There is one “Read-Only” field on form which cannot be update by user. But with this cheat code allow you to update “Read-Only” field also. 













Use this feature only for development and testing.

Monday 16 April 2018

Dynamics CRM : Bulk Execution Workflow


Bulk Execution Workflow

Case Study: -
Some time we need to run on demand workflow for selected set of records. This task need manual intervention.  In some scenario we want to schedule this task on hourly basis or daily basis. In Dynamics CRM there is no provision for scheduling on demand workflow execution for set of selected records. Like Dynamics CRM provide provision to schedule Bulk deletion workflow scheduling.

Solution: -

In below solution I will provide a way how we can schedule our bulk on demand workflow execution.
I have used below one custom entity to schedule bulk workflow execution.

Entity Name: -Bulk Execution Task
Below are the field used in this entity: -

Field name
Data Type
Fetchxml Query
 Multiple Lines of Text
Last Run Time
Date and Time
Next Run Time
Date and Time(Calculated)
Repeat Duration(Hours)
Whole Number
Termination Date
Date and Time

Calculated field: -
















Workflow Used: -

In this solution a OOB workflow is used name “Bulk Workflow Execution”.
This workflow will trigger when record is created in “Bulk Execution Task”.

















In this workflow Child process needs to check.
If record is created and conditions are meet a custom workflow will execute. This custom workflow responsible to run our on-demand workflow based fetch query we have specified.
























You can download solution from here: - Download Here

This solution is created in “Dynamics 365” version.


Working: -

Create record in Setting->Bulk Execution Workflow->New.
Provide workflow ID.
Open your workflow need to execute and copy ID from address bar. Make sure On-demand is checked for this workflow.












Provide your fetch XML query to select records. You can used “Advance Find” to get fetch query.
Provide other details.















When you save the record. Your Workflow start execution based on your information.

Click on follow to keep update from my blogs.


Thursday 12 April 2018

Dynamics CRM: Entity Security

In CRM as a developer we sometime need to see permission given to any entity in each security role.
But in Dynamics CRM/365 there is no provision to see this in single glance. We need to open each security role to check permission for any entity.

Case Study: -
Developer X is working in an organization as support engineer. He was not part of implementation team.
Now an issue in raised by users they can update notes of other users. Now X must check permission of user for note entity.
He checks security role of user1 not found:
User have assigned 15 security roles.
User have assigned 13 teams.
He goes to security roles and found there are 150 security roles are present in their organization.
He need to check all 150 security roles to verify permission given in note entity.

Solution: -
To tackle this case study, I have created a XrmToolBox Plugin which help Developer X.
1. User can see permission given to entity in each security role.
2. User can check team and user list based on selected security role for any business unit.
3. User able to see all security roles.

Download XRMToolBox from given URL and install.

xrmtoolbox

Install EntitySecurityRole Plugin in your XRMTollBox using plugin store.

If you are not able to find EntitySecurityRole.
Go to given Link :  Download Plugin
And download plugin from here. Install in XRMToolBox by clicking Settings->Path->Storage folder->Plugin folder.
Copy assembly in Plugin folder.
















































Connect your organization and open plugin Entity Security Role



























Click on “Retrieve Entities” and select your Entity.

Now you will see list of all security roles in security role list and Permission given to selected entity in each security role.


Now if you want to list of team and user based for any security role.

Select your business unit and then select required security role. And now you will able to see all team and user have for selected security role based on your selected business unit.
You can also export security role result in excel.


























Now Developer X will easily able to find in which security role permission need to change.
Note: - Plugin based on .net framework 4.5.2

Follow my blog so you will not miss my new upcoming blogs.

Wednesday 4 April 2018

Dynamics CRM: Sorting of related column in view


In Dynamics CRM sometimes we need to change sorting of a view. We can use main entity columns to configure sorting. But Out-of-box Dynamics CRM not allows to use column of lookup entity.


Example: - 
We need to sort the “Active Account” view based on Primary contact email.
Issue: - If we go to the view of “Active Account” and try to configure sorting we will see only column of Account entity. Even we have added email address of primary contact in our view.



View: -










Sorting: -





Here we can’t see Email address of contact entity to configure sorting.
Solution: -  
  •   Create a Solution.

            Go to setting-> Solution -> New solution
Name the solution and publisher and version.













  
  • Add “Active Account” view in solution

Click on Entity from solution component.
     Click on “Add Existing” Button and select account entity and press OK.
  • Now select “Active Account” view and click on Finish.

Do not include “Add All Assets”.

  • Now export the solution.

Click on Export solution button.

  • Open customizations.xml file in notepad or visual studio.

  • Go to fetch node and add email in order


<order attribute="emailaddress1" />
Remove other working order from fetchxml
<order attribute="name" descending="false" />


You can also use fetch builder to add/remove order.

  • Go to layoutxml node in your file and Remove disableSorting="1" from email cell.

Save the changes in customization.xml file.
  • Re-import the solution in your organization. And publish all customization.
  • Refresh your browser (press f5) or relogging. And go to “Active Account” view.
  • Now you will see sorting is activated on contact’s Email column.

You can also use “View Designer” plugin of Xrmtoolbox to make these changes.





















Field Security Profile - Based on Owner

 Recently received requirement related to Field security profile. Expectation : - 1.       Set to users need access of secure attributes. 2....

Test