{Resolution} Object does not support method or property “setSrc” in web resource control–Dynamics CRM outlook client

Recently my customer integrated their Dynamics CRM with outlook client. Everything was going fine until they reported that reported that when the CRM fields for Email entity are loading in Outlook client, they are getting the below error.

image

 

Ok. So first things first. Where and why is setSrc method is being used?

Well, my customer had a web resource on the email form and they were dynamically setting the URL of the webresource using the below code.

function FormLoad(){

var webResource = Xrm.Page.getControl("<WebResourceName>");

if(webResource != null){
webResource.setSrc(Xrm.Page.context.getClientUrl() + "<path to webresource>");
}

}

The code seemed to work perfectly fine in Web Client. However in Outlook client it started throwing the above error.

So instead of setting the source of the Web Resource control, we decided to use the getObject method of the WebResource control. The getObject method returns the HTML IFrame element representing the webresource control.

And as many of you might be thinking whether it is supported to use this or not, the good news is, it is a documented method. So you can use it. And to my surprise, many were not aware of the same and was not sure whether it is supported or not.

And the last step would be to set the source of the IFrame element using its src attribute. To make the code more generic, the below code would work across your web as well as outlook clients.

var webResource = Xrm.Page.getControl("<WebResourceName>");

if (webResource != null) {
    try{
        webResource.setSrc(Xrm.Page.context.getClientUrl() + "<path to web resource>");

catch(error){
        var iframeObject = webResource.getObject();
        iframeObject.src = Xrm.Page.context.getClientUrl() + "<path to web resource>";
  }
}

Off course you can be more explicit in the catch for the specific errors but this is just a demo code and you can modify as per your needs.

 

Hope this helps.

Debajit Dutta

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

{New Tool} Autonumbering solution for Dynamics CRM. Configurable, flexible options to choose from and uniqueness guaranteed

I am pleased to announce the new Auto Number tool from the stable of XrmForYou.com.

Before I walk you through all the features and how you can use the tool to your benefit, the eternal question, why again a new tool for an old requirement? Agreed it’s a requirement which every company implementing CRM must had at some point during their implementation lifecycle. And yes there a whole lot of solutions available which are targeted for that as well.

However, there are usually the following limitations I have faced while using many of the solutions

  • Not all generates unique numbers. Specially in case of data migration and during bulk uploads.
  • Many solutions uses Mutex lock. Even that does not guarantee uniqueness. And not an ideal solution for Online.
  • Many lack a good configuration page. Setting up an entity and field for an entity for auto number configuration is something you need to do manually many of the time
  • And last but not the least, how much a solution burns your pocket. You have impressive solutions in the market which covers all but perhaps you back down from implementing them because of budget constraints. We have tried to make this solution affordable as much as possible.

We have tried to cover up most of these scenarios and we hope you would find it useful for your business.

For trial and pricing, please write to info@xrmforyou.com

So let’s jump to the documentation.

The tool comes in the form of managed solution. Once you install the managed solution, open the configuration page.

image

Select an entity from the drop down. For my example, I selected Contact entity. Once you select the entity, all the ‘String’ and simple ‘Whole  Number’ fields would be populated for the selected entity.

image

For my example, I have created a String field ‘Auto Number Field’ which I will be using for the Auto Number.

I select the field.

I will explain the other options visible in this screen.

  • Disable configuration – By default, auto number configuration is enabled automatically once you select an entity and save your configurations in the tool. However you may choose to just disable the auto number for that entity without actually deleting your configurations that you took so much time to set-up.
  • Starting Number – By default it is set to 1. You can change it as required
  • Next Number – This field is for display purposes only and shows what number would be there in the next record that would be created. You can always reset the  ‘Next Number’ to the ‘Starting number’ by click on the ‘Reset Next Number’ button. 
  • Increment By – This field is used to determine by how much will the next number increment for the next record. You can set it to as desired. By default it is set to 1.

 

Prefix:

You have an option to choose a prefix value for you Auto Number. For that, just need check the checkbox ‘Insert Prefix’.

Once you check that you get the below options.

image

 

  • Prefix Value – Since I am using Contact entity, say for example I prefer my auto number value to be prefixed with C000. You can just put this value in the prefix.
  • Prefix Separator – Suppose I want that my auto number value and prefix value should be separated by a symbol. You can choose your desired list from the symbols provided in the dropdown. I have selected Hyphen(-) in my case.

P.S – If the field you have selected for Auto Number configuration is of type Whole Number, then prefix and suffix options will not be visible. Just for example – I have selected No. of Children which is of type Whole Number. Hence you could not see Insert Prefix & Insert Suffix Options.

image

 

Suffix:

The next option you have is to have a suffix appended to your auto number. For suffix, the tool provides you a whole lot of options. Let’s explore them

image

  • Suffix Generation Method – The first option you get is the Suffix Generation Method which can have two values
    • Auto Generated – If you select this option, you would see two additional fields showing up.
      • Suffix Length – The length of the suffix value
      • Suffix Type – You can choose between Whole Number & Alpha Numeric depending on the business requirement. Please note that you would have no control on the number generated. All the system would guarantee that it won’t be more than the length specified in the ‘Suffix Length’ field.

image

    • Manual – If you select this option, you would get the below option
      • Suffix Value– It’s a fixed value that you want to show for the suffix.

image

  • Suffix Separator – Same as explained for Prefix separator.

 

For my example  I have chosen Suffix Generation Method = “Auto Generated” & Suffix Separator = “At symbol(@)”

My final settings screenshot.


image

I click on Save to save my configurations.

Now let’s see, how an auto number is generated.

I create a new contact record and below is the auto number I get.

image

If you remember the I have selected alphanumeric for my suffix and put the suffix length – 5. that’s why the suffix is generated as a combination of numbers and characters of length 5.

 

This tool would give generated unique number for manual creation, bulk-imports or through data migration.

Last but not the least. The solutions comes with a security role – ‘Auto Number Reader’. Please make sure that all users using the the Auto Number are provided that role. Otherwise users other than system administrators would get the access error.

For trial and pricing, please write to info@xrmforyou.com

 

-Debajit Dutta

Try our tools

Sharepoint Metadata Manager and Attachment Extractor (http://www.xrmforyou.com/sharepoint-integrator-1.html)

Role Based Views in Dynamics CRM (http://www.xrmforyou.com/role-based-views.html)

Multiselect Picklist Control (http://www.xrmforyou.com/multi-select-picklist.html)

Record Cloner (http://www.xrmforyou.com/record-cloner.html)

{Utility} A UI based utility to pick and choose and update all the roll-up fields for your entity on-demand

Could not explain much about this utility with the title, so let me detail out the requirements here. Roll-up fields are great and here I am not going to talk about how it works and all. And after all it’s old enough topic I guess by now.

So what made to create this utility for such hackneyed topic. Well the requirement goes like this.

My customer had multiple roll-up fields on the account entity and they were scattered throughout the form across multiple tabs and sections to comply with their business. As good as roll-up fields are, they are updated every hour. However to calculate the roll-up fields on-demand you would need to click the refresh icon for each field.

We could have asked the users to do just like that. However there were couple of problems to it.

  • Some of the roll-up Fields were in the views but not on the forms. So even if the user wanted to manually update it, could not be done
  • The roll-up fields were scattered throughout the form across multiple tabs and sections as I mentioned earlier. So if a user needed to update a rollup field on-demand, he/she would literally need to find them across the form and click on refresh. Not a great idea everyone would agree.

 

So the customer walked up to me and asked. Can we have something which will allow me to pick and choose the roll-up fields for the entity even if not on the form and then allow me to update those fields on demand. And also he wanted something which could be easily moved across the environments and does not need a developer to maintain it.

Well, I thought for sometime and came out with a managed solution. All you need to do in install the managed solution in your environment.

The solutions are available for download at the following codeplex link – https://rollupfieldcalculator.codeplex.com/releases/view/631015

 

Once you install the managed solution in your environment, open any entity and you should see a button called ‘Calculate Roll-up Fields’

image

Once you click the button, a window will pop-up with all the roll-up fields for the entity.

 

image

As you can see from the above screenshot, the pop-up shows the ‘RollupField Email’ which rolls up the count of emails related to the account. The other two fields ‘Open Deals’ and ‘Open Revenue‘ which are not present on the form but still showing up.

 

You can pick and choose the fields that you want to Update and then click on the ‘Update’ button.

image

Once clicked, it will calculate all the roll-up fields that you have selected for update and then will refresh the form so that new values becomes visible to you.

Currently there are five emails associated with the account. Hence after I click on update the form refreshes and shows me the value “5” in the field.

image

Just a solution import and all you need is pick and choose your fields. No code, no customizations.

Hope you liked this tool.

 

Try our tools

Sharepoint Metadata Manager and Attachment Extractor (http://www.xrmforyou.com/sharepoint-integrator-1.html)

Role Based Views in Dynamics CRM (http://www.xrmforyou.com/role-based-views.html)

Multiselect Picklist Control (http://www.xrmforyou.com/multi-select-picklist.html)

Record Cloner (http://www.xrmforyou.com/record-cloner.html)

Enabling Opportunity and other non-listed OOB entities for Interactive Service Hub in Dynamics 365

As a dynamics CRM consultant, you come up with variety of requirements from customers. Some we achieve easily using the OOB ways with some customizations, some others need a complex workaround and then there would be some where we just have to be honest to our client and tell them that the feature they are looking for is currently not available in Dynamics.

And I came across a requirement of the last category from one of our customers very recently. They were using Interactive Service Hub hugely for their service module and their business was just too happy with the Interactive service hub. After all why not? The mobile look & feel, the tile views, the form, all look so nice.

While you get lost in the beauty of ISH, how about this requirement to pull you out of your utopia? “We want to implement ISH for our sales module as well. Opportunities, Leads etc etc”

My first and immediate answer was a big NO. After all Opportunity and lead are OOB entities for which ISH can’t be enabled. The immediate reply from our customer was why? If we can enable complex custom entities for ISH, then why not opportunity?

Could not commit to the customer as this is outside of Microsoft recommendation but I decided to give it a shot. Certainly, it can’t be enabled for Opportunity and Lead from the UI, but hey! what about doing it using SDK. I wrote the below code to enable Opportunity entity for Interactive Service Hub.

RetrieveEntityRequest entRequest = new RetrieveEntityRequest();
entRequest.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Entity;
entRequest.LogicalName = “opportunity”;

                RetrieveEntityResponse entResponse = (RetrieveEntityResponse)service.Execute(entRequest);

                var entMetadata = entResponse.EntityMetadata;
entMetadata.IsInteractionCentricEnabled = true;

                UpdateEntityRequest updateEntRequest = new UpdateEntityRequest();
updateEntRequest.Entity = entMetadata;

                service.Execute(updateEntRequest);

 

I ran the code and it much to my surprise, it ran without any errors. So CRM does not stop enabling of ISH for non-listed entities using SDK? Is the restriction only from the UI perspective? Well before jumping to conclusion, let us first check if the flag really got enabled.

I went to the Opportunity entity customization and below is what I could see.

image

Cool! the box is checked. Means my code has done the wonders.

But wait, does making this field enabled really work. So let’s find out.

I first created a Interactive experience form for Opportunity. In am not going to explain here, what is an Interactive Experience form and all. If you are not aware of Interactive Service Hub, I suggest you first get to know about it and then come back to this post.

image

 

The next I do is design a card form for the Opportunity entity.

image

 

So far so good! The next I did was create an Interactive Service Dashboard for Opportunity entity.

image

 

I save and publish all customizations. Now comes the toughest part. I have done all the customizations. But will Interactive Service Hub framework be able to render this. After all Opportunity is not something which is listed in the list of entities for interactive service hub.

 

I open ISH. And voila! it works. Below are the screenshots of how it looks in ISH.

image

 

image

image

 

Awesome. Isn’t it. I have tried this procedure with multiple entities which are not listed and all works great!

I am still to suggest this to customer as this is not something that has been officially recommended by Microsoft. However if you check this, we haven’t done any sort of unsupported customizations.

The question of my customer still comes to my mind with a bit of improvisation. “If ISH can render awesome views even for the entities which are not-listed, what is the main reason behind not exposing these OOB entities directly for ISH?”

 

Would like to know your views as well.

Hope this helps!

 

Try our tools

Sharepoint Metadata Manager and Attachment Extractor (http://www.xrmforyou.com/sharepoint-integrator-1.html)

Role Based Views in Dynamics CRM (http://www.xrmforyou.com/role-based-views.html)

Multiselect Picklist Control (http://www.xrmforyou.com/multi-select-picklist.html)

Record Cloner (http://www.xrmforyou.com/record-cloner.html)

Useful Trick to debug your scripts in Dynamics CRM mobile client

No I am not going to put any MSDN link or try to explain how can you debug your scripts in tablet forms efficiently. After all we are in the world of interesting world of Dynamics 365 and writing something like that will be pretty banal.

However I am going to let you know one trick through which you can leverage the power of Developer tools of Chrome to debug your CRM scripts in tablets. And you might have been thinking that is something I have pulled out of my sleeve. Well, it’s not me but the brilliant Dynamics CRM Tip of the Day’ (http://crmtipoftheday.com/) guys where from I learnt this trick.

I was in one of the recent customer engagements and the customer was keen to bring in support for tablets and mobiles. They had some heavy customizations and they were getting left and right script errors when the forms were loading in tablets. Putting Xrm.Utility.alertDialog will only get you that far. And it was surprising that in-spite of they being pretty good on the platform, they were not aware of this trick suggested by ‘Dynamics CRM Tip of the Day’ guys. Below is a link to the same.

http://crmtipoftheday.com/2014/05/06/test-crm-for-tablets-from-a-pc-browser/

I  wonder why this is not suggested in many cases but this might really save you some serious time.

It’s a pretty old tip and hence I think people are not aware of it. Hence re-sharing. Believe me, after knowing this, if someone asks you to debug mobile scripts, you will find it easy like a piece of cake. And believe me, every tip I their blog is like gold dust.

I have been using it for pretty long time and yes it works for all versions. I have tried in Dynamics 365 and Dynamics 365 on-premises and it works like a charm. However do note that this works only in Chrome as far I have tested.

 

Sample Dynamics on-Premise with IFD url to access the mobile form in desktop browser.

https://<orgname>.<domainname>.com/nga/main.htm?org=<orgname>&server=https://<orgname>.<domainname>.com

Sample Dynamics 365 online url to access the mobile form in Desktop browser (North America Orgs)

https://<orgname>.crm.dynamics.com/nga/main.htm?org=<orgname>&server=https://<orgname>.crm.dynamics.com

 

You need to first launch chrome, put your Dynamics URL and then login. Once logged in successfully, take the mobile Url and paste in your browser. You should be good.

Debugging scripts is now just like the web client. All you need to do is put a debugger statement in script function you want and then just launch Chrome developer tools using F12. That’s all.

Below is the sample of screenshot of my Dynamics 365 on mobile client.

image

 

Hope this helps.

 

 

Try our tools

Sharepoint Metadata Manager and Attachment Extractor (http://www.xrmforyou.com/sharepoint-integrator-1.html)

Role Based Views in Dynamics CRM (http://www.xrmforyou.com/role-based-views.html)

Multiselect Picklist Control (http://www.xrmforyou.com/multi-select-picklist.html)

Record Cloner (http://www.xrmforyou.com/record-cloner.html)

{No Code Approach} Generic framework to delete all child records when a parent record is deleted in Dynamics 365 using Microsoft Flows

Here comes another requirement and here comes Microsoft flows again to bail me out. So let’s see what the requirement was and let’s see how can we implement Microsoft flows to achieve these easily which otherwise would have required extensive coding to achieve.

So it goes like this. Basically, there are lot of custom entities in the environment and there are many parent-child relationships in between those entities and they are referential in nature. Ideally parental would have suited for some, however due to the number of parental relationship limitation in Dynamics, they would set it up as referential.

Now whenever a parent record is deleted, the associated child records would be deleted as well. Since this is referential relationship, whenever we delete a parent record, the child records are left orphaned in the system.

Microsoft flows offers you an easy way to delete records in bulk. You could easily define a flow for each child record type and use the delete record step of Microsoft flows to achieve the same.

But wait? In the above approach, we need to create a flow for each child entity type and if the number of child record types are pretty large then suggesting to build flows for each of them is not something you would want. Also if a new entity or a new relationship comes into the picture, you would need to again write a flow for the same.

So now what? After a lot of brainstorming I finally came up with a solution which is pretty generic in nature and pretty scalable as well. So let’s see the design here.

  • Create a custom entity. I named it – ‘Child Record Delete Trigger’. The following are the fields I created for this entity with their purpose.
    • EntitySet Name – This would hold the entity set schema name for the child record type to be deleted
    • Child Record Id Name – This field would hold the schema name for the Unique Identifier of the child record
    • Parent Field name – The field would hold the schema name of the parent record field associated with the child record. Basically this would be the lookup field name of the parent record on the child record.
  • For testing this, I create a new entity named ‘Flow Test’ which has a N:1 relationship with Contact entity. Screenshot for reference.

image

  • The lookup field of the contact has the schema name – new_contactid as seen from the above screenshot.
  • The basic idea is to create a ‘Child Record Delete Trigger’ record whenever a parent record is deleted.
  • I created two records of Flow Test with Contact = ‘Catalina Weeks’

image

  • I go ahead and delete the contact ‘Catalina Weeks’. On delete of the contact record, I create a record of ‘Child Record Delete Trigger’ entity with the following values
    • EntitySet Namenew_flowtests (since this is entity set name)
    • Child Record ID Namenew_flowtestid (this is schema name of the primary key of the child record to be deleted)
    • Parent Field Name – new_contactid (lookup of the contact field on the child record)

I leave it up to you to determine on how to create this record, whether through a plugin or through a workflow or some other methods. As long as you create the record properly with all the fields populated, it is going to work.

So all set and done. The next step is to create the generic flow to delete the child records.

The first step is to select the Dynamics 365 Step – When a record is created.

image

Below are the configurations for this step.

image

Now when a parent record is deleted, all the child records parent reference would be null. So the next step is to determine all the child record for which the parent reference is empty.

For this, I select the Dynamics 365 – List Records step.

image

Below is the configuration for this step.

image

As you can see, I have selected dynamic properties for all the steps in List Records. I am getting all the child records where Parent reference is null. As you can see, no entity names and field names are hardcoded. It takes from the ‘Child Record Delete Trigger’ record we created when the Parent record has been deleted.

So far so good. So now what? Now we need to iterate through each of these records and  delete them

So we add the ‘Apply Each’ Step.

image

image

Now comes the hard part. To delete the record you would need to use the Dynamics 365 – Delete a record step which requires a unique identifier. However the problem here is that the flow designer at the design time does not know which entity record you are trying to delete. So it does not show up the UniqueIdentifier field in the designer.

So we have to basically make the runtime understand the Unique Identifier value (GUID of the record) so that the delete step is able to delete the record. For this we would use the Compose action.

image

image

So what we have done here? Remember when we created the Child Record Delete Trigger record, we populate the field ‘Child Record Id Name’ with the schema name of the primary key of the child record.

So we use the compose function to parse that Unique ID field schema name.

Great! Now the second task it get the schema name and pass it to the framework to get the GUID. For this we use another “Compose’ action but this time, we plugin some custom expression of our own.

image

So what are we doing above? We are taking each item of the iteration which is identified by item() and then getting the value of the Guid of the record by passing the name of the primary field which we composed from the earlier step. This is similar to accessing a value using an indexer.

The final step is the Delete Record Step of Dynamics 365 which is very simple as shown in the below screenshot. All we are doing is getting the guid value of the child record from the previous Compose action step and passing it to the delete step.

image

And we are done!

So I deleted the contact. As expected, the child records were left without the parent contact reference.

image

 

A record of Child Record Delete Trigger entity got created with the following information.

image

So the Flow should fire now.

I check that and confirm that my flow ran successfully. And when I visit my child records list, I could see that all my child records have been deleted.

Simple and powerful isn’t it.? The same generic flow can be used for any entity/ relationship and in the whole flow you have deleted the child entity records without even know which entity it is.

 

Hope you liked this.

 

-Debajit

(Visit our products page at www.xrmforyou.com to know about our offerings)

{Utility Update}–SharePoint Metadata Manager & Attachment Extractor. What’s new?

First of all, I can thank more to the Linked In community for the overwhelming response on our SharePoint Attachment Extractor and metadata manager tool. Your feedbacks, your comments and your patronage keeps us motivated to continuously excel and do better.

In case, you are not aware of the tool, this quick video on the link would help you get started.

http://www.xrmforyou.com/sharepoint-integrator-1.html

You can follow this blog link as well which explains in detail the functionalities of the tool

https://debajmecrm.com/2016/10/05/new-tool-dynamics-crm-sharepoint-metadata-manager-attachment-extractor/

Based on the feedbacks of many who have tried our tool and our customers, we have implemented multiple changes to the tool related to performance enhancements and adding new functionalities to aid you.

For trial and pricing, please reach out info@xrmforyou.com

1. Performance Enhancements

We are happy to let you all know that we have made some significant changes in the underlying framework to increase the performance. Many were facing performance issues while trying out our tool in the online trial environments specially in the EMEA and APAC regions as the online trials were performing reasonably slow in these environments.

We cannot do much for the online trials :). Hence we decided to work on the performance of our tool. You would find visible performance difference in the retrieve, upload, delete and even in the metadata management sections.

We would be sending out the new trials to all who queried for it and the updated licensed version to all our existing customers.

 

2. Support for SharePoint Document Locations

Our prior version just relied on the Document Management to be enabled between CRM & SharePoint. Once it was enabled, it would work independently. Meaning OOB CRM – SharePoint integration creates a SharePoint Document Location object for each record for which a document is uploaded.

However our previous version did not rely on this and it would communicate directly to SharePoint. Hence documents uploaded using our tool was not visible in the OOB upload section. This was a requirement for many. Hence we have included support for SharePoint document locations. This means documents uploaded from our tool and OOB Documents area would be visible through each of the areas.

Documents Uploaded through our tool

image

 

From OOB CRM Documents area

image

 

3. Drag & Drop

What’s a modern app without the feature to drag & drop. And that’s why we have enabled the drag and drop feature on our tool as well. All you need to do is drag an drop the files from your desktop to our control on the form and they will be uploaded for you.

P.S – Drag & Drop feature is currently only in the licensed version. However we are planning to bring that to trial very soon

 

4. On-Premise support.

Why leave out the old horse? In the days when Online is talked so much, we do care about our on-premise customers. Our tool now supports On-premise environments as well.

 

And finally a big announcement to make. We are going to come with just the attachment extractor to move your attachments from any entity in CRM to SharePoint. This tool maintains all its functionalities but we are separating out just the attachment extraction part of it and bundle it into a separate tool with lot of configurable options for you.

Stay tuned.

For trial and pricing, please reach out to info@xrmforyou.com.

Visit our products page http://www.xrmforyou.com/products-1.html

-Debajit Dutta