Archive
Execute Custom Action using Late Binding – CRM 2013
Custom Actions provide the ability to write reusable modules of logic that can be triggered through client-side or server-side code.
Custom actions run synchronously and can take in parameters as well as return values.
In this article I will walk you through creation of a Custom Action with Input Parameters and execute the same using SDK call.
My Custom Action created on ‘Account’ entity and will do below actions
- Takes a Input Parameter of type ‘Entity Reference’ to User, to set Owner of the Task to Accounts Owner
- Create a new Task
- Sets Owner of Task to Account’s Owner
- Make sure you publish the ‘Custom Action’
Execute Custom Action :
- We can execute Custom Action using Early or Late binding approach
- For early binding we need to generate wrapper using exe tool by including ‘generateActions’ tag in console command.
CrmSvcUtil.exe /url:http://<serverName>/<organizationName>/XRMServices/2011/Organization.svc /out:<outputFilename>.cs /username:<username> /password:<password> /domain:<domainName> /namespace:<outputNamespace> /serviceContextName:<serviceContextName> /generateActions
- Below is the code to execute using Late Bound technique
OrganizationRequest executeCreateTaskOnAccount = new OrganizationRequest(“new_CreateTaskOnAccount”);
// Set Account Owner EntityReference Input Parameter
Guid accountOwnerId={Account Owner GUID};
var accountOwner = new EntityReference(“systemuser”, accountOwnerId);
executeCreateTaskOnAccount.Parameters.Add(new KeyValuePair<string, object>(“AccountOwner”, accountOwner));
organizationService.Execute(executeCreateTaskOnAccount);
Few points :
- Custom actions can be triggered using JScript and SDK calls
- We cannot execute Custom Actions from a workflow
- However you can create a Custom Workflow with ‘Custom Action’ execution logic and call from a Workflow
- A security privilege named Activate Real-time Processes (prvActivateSynchronousWorkflow) is required to activate an action’s real-time workflow so that it can be executed
🙂
Teams vs Access Teams vs Access Team Templates – CRM 2013
As we know “Access Teams” are one of the new feature in CRM 2013.
Let’s see how this is different from Legacy Owner Team and finally how is it different from “Access Team Templates”.
Consider a scenario, Where we need to change the Accessibility of ‘Account’ records frequently
- I have 3 Accounts in my system
- Account 1 can be (Read/Write/Delete) only by User 1,User 2, User 3
- Account 2 can be (Read/Write/Delete) only by User 4,User 5, User 6
- Account 3 can be (Read/Write/Delete) only by User 6,User 7, User 8
We can achieve above requirement by below approaches.
Approach 1:
- Create 3 teams with a Security role having Read, Write, Delete Privileges to Account
- Team 1 (User 1,2,3), Team 2 (User 4,5,6), Team 3 (User 6,7,8)
- Change the Ownership of Accounts to
- Owner of Account 1 = Team 1; Account 2=Team 2 and Account 3 =Team 3
- Or Share the Account records to Teams instead of Ownership.
Drawbacks of Approach 1 :
- Sharing records to a Team with the same sets of users, with the same rights is a performance over head.
- Add/remove users from team require CRM to reset the Cache and must be recreated by querying the SQL next time the user tries to perform any action.
- We cannot show who all are working on the Account on the form (Only was is to open Share window and go to the Team to see the list of Users).
Approach 2:
- Using Access Teams; Let’s see how it is different from old Team approach.
Access Teams :
- In simple terms, Access Team is a kind of Team with no security role (i.e., No specific privileges at that time of Team creation)
- Privileges are determined when you align the Access Team to a record via Sharing.
Access Team Templates :
- We define a set of privileges while creating ‘Team Template’
- Add a “Access Team” sub grid on the form. (How to create and add as Sub grid)
- Add different Users to the “Access Team Sub Grid” for different Accounts. (i.e., User 1,2,3 for Account 1;User 4,5,6 for Account 2…).
Access Team vs Access Team Templates :
- Underlying principle for both Access Team and Access Team Templates are same that No associate security role.
- With ‘Access Team Templates’ privileges are pre-determined, but the people are not. With Access Teams, the people are pre-determined, but the privileges are not.
Team vs Access Teams :
- Teams associated with a Security Role but not the case with Access Teams.
- Records cannot be owned by Access Teams.
- You can create views or reports on Access Team Members but not with Teams.
Few more points :
- Users have to have to Share privilege to add Users to “Access Team” sub grid.
- We can have more than 1 Access Team sub grid on a form
- The default number of access teams templates for each entity is two
- The number of access team templates you can have for each entity is controlled by the MaxAutoCreatedAccessTeamsPerEntity deployment setting.
- MaxEntitiesEnabledForAutoCreatedAccessTeams deployment setting has a default value of 5. This controls the number of entities it’s possible to enable for auto-created access teams.
- We can change the MaxEntitiesEnabledForAutoCreatedAccessTeams , MaxAutoCreatedAccessTeamsPerEntity only on Premise installations and cannot edit them for Online.
- To delete a Access Team Template, we need to remove all the associated ‘Access Team Template’ sub grids before.
- A system generated Access Team isn’t created for each record until you add a user to the sub grid on the entity.
- We can covert normal Teams to Access Teams.
🙂
Target CRM Version in Solutions – CRM 2013 Spring feature
With Spring update we got a new option “Target CRM Version” while exporting the solution.
Available options are 6.1 (default) and 6.0.
If you choose 6.0, any new capabilities of version 6.1 will not be included in the exported solution and any organizations still using version 6.0 will be able to install the solution.
All the removed or modified components will be listed out in a dialog.
Note – “Target CRM Version” option is unavailable if you export Default solution.
IntroducedVersion Property
- In CRM 2013, solution component has an IntroducedVersion property.
- This value captures the current product version number of the solution that the solution component was associated with when it was created.
Refer these links for more info
🙂
CRM Developer Toolkit for Visual Studio 2013
There is no release of CRM Developer Toolkit for VS 2013.
However by hacking the CRM Developer toolkit for VS 2012 we can get Developer Toolkit work for VS 2013.
Refer steps mentioned in this article.
🙂
Loading dependent jscript libraries in ribbon button’s execution CRM 2013
In CRM 2011, To load the dependent Jscripts on execution of ribbon button command actions
- We can add the dependent script as a Library in the “Javascript Command” and pass “isNaN” as Function Name (Refer my existing article)
In CRM 2013, I observed a slight change in the execution w.r.t the order.
The dependent script files has to be ordered before the actual script file.
Dependent script file is not loading if the order of the file next to the actual script file.
In the above scenario there are 2 “Javascript Command” pointing to different web resources.
The “Javascript Command:isNaN” is my dependent script file hence I put that as 1st command.
Quick Create Forms – CRM 2013
‘Quick Create’ form is the latest addition in CRM 2013 new set of features.
‘Quick Create’ form enable you to create records quickly by just filling the key information (i.e., fields) using global ‘Create’ button.
In this article I would like to provide few key points about ‘Quick Create’ form
- To enable ‘Quick create form’ for an entity, you have to check “Allow quick create” check box under Data Services in entity properties.
- To create a new ‘Quick create form’, go to Entity -> Forms -> New -> Quick Create Form
- Quick form only contain one Tab and three Section , we can’t add new tab or section.
- Publish the Customizations.
- Click on global ‘Create’ button on Navigation bar and select the entity and you get the form
‘Business Rules’ on Quick Create forms
- ‘Business Rules’ work on ‘Quick Create Forms’
- To enable ‘Business Rule’ to work on ‘Quick Create Form’, we just need to set the scope of ‘Business Rule’ to ‘All Forms’.
I will keep adding few more points, if I come to know.
🙂
CRM 2013 new form lay out and Notes control
In CRM 2013 when you create a new entity and open ‘Main’ Customization form, it looks as below
It’s not how CRM 2011 form looks. In CRM 2011, you get separate ‘General’ and ‘Notes’ tabs
How to get back CRM 2013 form like CRM 2011 with separate General and Notes tabs
- Double click ‘General’ tab and select ‘tab layout’ as ‘One column’
- You get a warning as mentioned in below screen
- Now you will get only ‘General’ tab and lose the ‘Notes‘ tab from the form.
- So, to get back ‘Notes’ tab back
- Add a new ‘One Column’ tab and select the tab
- From the ribbon choose ‘Notes’ control
- Now the ‘Notes’ tab will be back on the form
- Now the end user form looks below
Notes Control
- In CRM 2013, we can define the way how Notes, Activity Feeds and Activities are displayed on the form.
- These three elements are now combined into a single control.
- You just need to add the ‘Notes’ control on to the form and open properties and choose ‘Default’ tab (I.e., Activities o Posts or Notes)
🙂
Duplicate detection functionality in CRM 2013
In CRM 2013, Duplicate record detection feature on create/update form has been removed due to the ‘Auto Save‘ functionality, which saves the form frequently.
Below are the 2 ways we can bring back the functionality.
Solution provided in CRM 2013 SDK
- In SDK there is a recommend approach to enable the duplicate detection feature on a required entity Create\Update form.
- Download the CRM 2013 SDK, navigate to “SDK\SampleCode\JS\DuplicateDetection\ReadMe.docx” document to get more information.
- Here is an useful article with screen shots on the same.
Note –
- We might need to disable your ‘autosave’, otherwise ‘autosave’ keeps triggering the duplicate detection
- Refer this article how to skip autosave on onload or onsave.
CRM 2013 Duplicate Detection tool codeplex
- There is a solution on codeplex which gives you the duplication detection functionality.
- Download
🙂
New JScript syntaxes – CRM 2013
With the advent of CRM 2013, below are the new set of client API methods
Context
- Xrm.Page.context.getUserName() – Returns username of the currently logon user
- Xrm.Page.context.getClient() – Returns the client (i.e., Returns “Outlook”, “Web”, or “Mobile”)
- Xrm.Page.context.client.getClientState() – Returns whether user is working online or offline.
Note – Xrm.Page.context.isOutlookOnline and isOutlookClient methods are deprecated
Data
- Xrm.Page.data.refresh() – Asynchronously refresh data on form without reloading the page
- Xrm.Page.data.Save().then(successCallback, errorCallback) – Allows you to save the record asynchronously with the option to set callback functions to be executed after the save operation is completed.
- Xrm.Page.data.getIsValid() – Validates the form and returns a Boolean.
- Xrm.Page.data.setFormDirty() – Allows to set IsDirty options on the form to (true/false).
Entity
- Xrm.Page.data.entity.getPrimaryAttributeValue() – Returns a string value of the primary attribute for the entity.
Xrm.Utility
- Xrm.Utility.openWebResourceDialog(webResourceName,webResourceData,width,height) – Displays html web resource as dialogs window.
- Xrm.Utility.alertDialog(message,onCloseCallback) – Displays alert box with a callback function.
- Xrm.Utility.confirmDialog(message,yesCloseCallback,noCloseCallback) – Displays confirm dialog with different callbacks depending on Yes/No button clicks.
Set Notifications
- Check this link for syntaxes
Number Fields
- Xrm.Page.ui.controls.get(controlName).setPrecision(2) – Overrides field’s precision
Date Fields
- Xrm.Page.ui.controls.get(controlName).setShowTime(true) – Controls whether to show the time for a date field.
- Xrm.Page.ui.controls.get(controlName).setIsAllDay() – Allows to set the date control to all day date time.
Look up Fields
- Xrm.Page.ui.controls.get(controlName).addCustomFilter(filter,entityLogicaName)
- Applies a custom filter to the lookup view
- entityType is optional and if it is not passed it will default to all entity views
- Xrm.Page.ui.controls.get(controlName).addPreSearch(handler) – Allows to add additional logic that will occur just before the search dialog box
- Xrm.Page.ui.controls.get(controlName).removePreSearch(handler) – Removes event handler functions that previously been set in addPreSearch event.
🙂