CRM 2013 – Investigation into replacing the Assign functionality

I had a small one line change request for a CRM 2013 implementation

Replace Assign functionality with will show users of the current users team.

I thought it would be easy to write a technical specification for this requirement.

First thoughts

Assign form is a special CRM form, I know this cannot be edited or manipulated (in a supported way).

This was much trickier than I initially thought it would be.  As an added bonus finding what users are in a team is not straight forward and you have to use a link entity when you do it in an advanced find.

Here are my thoughts of possibles solutions

Method 1

Create a new form to replace the Assign form.

Work

  • Create ASP page to include a filter lookup to CRM
  • Interact with CRM SDK to retrieve rows and update values
  • Ribbon button change

Pro’s

It would offer the functionality required

Con’s

It would take quite a bit of effort for a seemingly small change

 

Method 2

Open a standard lookup form, calling the lookup form in CRM and filter it

I researched this idea (which I found very difficult to find on the internet)

I go this page

HowTo: Open standard lookup window and get selected record(s)

CRM 2013 Open lookup as dialog in Custom HTML

This method wasn’t suitable because it’s unsupported and I couldn’t see how to filter the lookup.

Method 3

Using a dialog to first return the a list of teams the user is a member.

The user would select a team, press next

This would then return a list of users

Work

Create a dialog

Create custom workflows 1.  retrieve the users team, 2.  Retrieve users in team.

A ribbon button could call the dialog (This can be done using the Ribbon workbench Create a Dialog Short-Cut Ribbon Button)

Pro’s

It should deliver the functionality required

Con’s

Dialog’s are not the quickest

There is still quite a bit of work, two custom workflows and a dialog

 

Method 4

The easiest solution would be to add a user lookup on the form and if the set a value I could trigger a plugin or workflow to assign the records.

The lookup would need be filtered to the team.

I had heard CRM 2013 had prefilters, which allowed you to add filter to a lookup.  When investigating this it turns out you cannot create a filter with a linked entity and can only filter on values which exist on the SystemUser (user) entity.

This excellent blog post

CRM 2013 Using addCustomFilter() to get Filtered Lookup Field based on Linked Entity

Mentions the problem and you can get around it by using the addcustomview but this means you have to create a whole view.

Instead I tried out the functionality in Miss Dynamics CRM blog and use the addCustomFilter()

I thought I would try this out because I had not yet used the AddCustomFilter() solution and this seemed the easiest and quickest

First I created a view in the Advanced find (Why the advanced find is a CRM Developers best friend)

Assign Team problem

 

I then got downloaded the Fetch XML and put it into the FetchXML Builder

Assign Team problem 1

I could then get the guids, Aileen Gusni mentioned some workarounds in her blog to get  AddCustomFilter() to work you could use OData to retrieve the data you needed and


var Hosk = Hosk || { __namespace: true };
Hosk.Functions = Hosk.Functions || { __namespace: true };
Hosk.Functions.HoskTest = Hosk.Functions.HoskTest || { __namespace: true };

; (function () {

this.formLoad = function () {
addEventHandler();

};

function addEventHandler() {
// add the event handler for PreSearch Event
Xrm.Page.getControl("hosk_userassignid").addPreSearch(addFilter);
};

function addFilter() {
//create a filter xml
var filter =
"<filter type='and'>" +
"<condition attribute='systemuserid' operator='in'>" +
"<value>{9fed63fe-c0cc-e411-80c7-000c292122be}</value>" +
"<value>{cba24eea-bacc-e411-80c7-000c292122be}</value>" +
"<value>{2ed69167-0bcf-e411-80c7-000c292122be}</value>" +
"<value>{92c6d456-7bdf-e411-80c8-000c292122be}</value>" +
"</condition>" +
"</filter>";

//add filter
Xrm.Page.getControl("hosk_userassignid").addCustomFilter(filter);
}
}).apply(Hosk.Functions.HoskTest);

The code work, I had filtered the User lookup to those records.

Assign Team problem 2

The filtering kept true even when you clicked look up more records.

The next step I could retrieve the data from an OData call and Dynamically create the line

“<value>{cba24eea-bacc-e411-80c7-000c292122be}</value>” +

Then have a workflow/plugin to assign the records

Work

new field

Javascript change to add filtering

plugin/workflow to assign records.

PRO’s

The quickest solution in time to create and running time

Con’s

It’s different from the current assign button, this may confuse users

The option chosen was….

After spending time thinking about the problem and coming up with some choices the customer decided they didn’t want it.

This is something which happens to developers, one day you can create a change and the next day a customer decides they don’t want it and you have to take it out.

The customer didn’t want the change but I did get to investigate some CRM functionality I hadn’t used yet.

If you have a better solution please leave it in the comments.

Advertisements

CRM 2015 – How to change the option set default value

I recently had a few issues with Status Reasons and the number associated with a status reason

CRM 2013 – Understanding Status and Status Reason – think before deleting them

This lead me to have to add a Status Reason into CRM using CRM SDK because I couldn’t figure out where the default number of a new status reason was being calculated.

CRM 2013 – How add a status reason using the CRM SDK

Default option set value

Today I figured out where the number was coming from when you create a new option set.  This value is set in the publisher.  There is a field called Option Value Prefix

OptionSet default value

When I go into my Hosk Solution, which uses the Hosk Publisher and create a new option set, it takes the default value from the publisher

OptionSet default value 1

The default value is also used for new Status Reasons

OptionSet default value 2

Customize from the default solution

The default solution includes all the customizations in CRM and this is the solution you access when you choose customize the system.

To understand solutions read more in the blog post below

CRM 2013 – Understanding Solutions and how they work

What values will be used when you add a new option set or status reason when editing the default solution

The status reason seemed to still use the default value in my new publisher.  This was unusual because I would have expected it to use the value in the Default publisher which was 10000 because this is the publisher specified in the Default Solution?  The default publisher is read only so this cannot be changed.

OptionSet default value 4

I did a bit more digging and found CRM seems to calculate which solution the entity is in and then uses the solution option value prefix even if you edit it using whilst in the default solution.

When I added a new optionset it did use the value in the default publisher

OptionSet default value 3