We were working on sending emails programmatically using CRM and all were working fine. Suddenly we got this error when we tried to send an email. It was strange to us as this functionality was working fine before. So we did some digging to find out what had changed to cause this issue. We found out that one of us had changed the email sending user from the admin user to another user.
We use a CRM user to work with a web portal and we have used the same user as the email sending user. Hence we didn’t get any errors as the same user can send emails to anyone using the same user account. (no impersonation is here).
But when you try to send an email from someone else using a different user account you get and error as the email sending user has not granted permission for others to send emails on behalf of him. You can grant the permission by going to personal user setting of the email sending user and selecting “Allow other Microsoft dynamics CRM users to send email on your behalf”.
After doing this our problem was solved and we were able to send emails.
You can refer the following articles for more details
http://social.microsoft.com/Forums/en/crm/thread/9fee0bd6-2ae9-4f33-a971-0bf83bcf43de
http://blogs.msdn.com/b/crm/archive/2009/12/07/configure-microsoft-dynamics-crm-online-e-mail-router-with-exchange-online.aspx
This blog describes mostly about the work (CRM 365, CRM 2016, CRM 2015, CRM2011, CRM 4.0, CRM 3.0, C#,Javascript and SQL Server) i do.
Thursday, September 6, 2012
Monday, August 13, 2012
Dependent Optionlist/Picklist values in CRM 2011
This is not possible with OOTB CRM features. We can use lookup options with cascading features from OOTB functions.
So is there a way to come around this? Yes, there is. There is a solution which has been created and shared among the developers. This is perfect when it comes to CRM interfaces.
The links below would take you to articles which describe it more.
http://blogs.msdn.com/b/paf/archive/2011/04/21/how-to-easily-create-dependent-picklist-in-crm-2011.aspx
The recurring problems have been included in this article.
http://blogs.msdn.com/b/paf/archive/2011/09/29/dependent-picklist-recurrent-problems.aspx
Please not you can have multiple picklist dependent on the same picklist in an entity. This is supported. All you have to do is to create a single web resource with all the mapping data inside it and it will work.
So is there a way to come around this? Yes, there is. There is a solution which has been created and shared among the developers. This is perfect when it comes to CRM interfaces.
The links below would take you to articles which describe it more.
http://blogs.msdn.com/b/paf/archive/2011/04/21/how-to-easily-create-dependent-picklist-in-crm-2011.aspx
The recurring problems have been included in this article.
http://blogs.msdn.com/b/paf/archive/2011/09/29/dependent-picklist-recurrent-problems.aspx
Please not you can have multiple picklist dependent on the same picklist in an entity. This is supported. All you have to do is to create a single web resource with all the mapping data inside it and it will work.
If you have any issues doing the above let me know.
Thursday, August 9, 2012
CRM 2011 Integer fields and comma symbol
In CRM if you create an integer field by default the CRM group 2 numbers together by using a comma. This is the standard feature.
However sometimes customers ask this comma to be removed. This is not possible with OOTB functionality in CRM. You have couple of options.
• Remove the integer field, have a text field and include javascripting to validate the field. This might be cumbersome.
• Can create another field (text) and using a workflow assign the value of the integer field to this. This field would be getting displayed in views and forms. The drawback is you have synch both these fields.
• You can have a javascript to remove the comma from the CRM form when it’s loading. Not much difficult. However you still would not be able to get rid of commas when you display a view.
Below I have given a common javascript function which can be used to get rid of commas. Add this to a web resource.
function RemoveComma(fieldname)
{
document.getElementById(fieldname).value = Xrm.Page.data.entity.attributes.get(fieldname).getValue();
}
• Add the web resource to form onload event.
• Call the function RemoveComma with the field name as the parameter.
This way you can use this function anywhere you want just by passing the field name to it.
However sometimes customers ask this comma to be removed. This is not possible with OOTB functionality in CRM. You have couple of options.
• Remove the integer field, have a text field and include javascripting to validate the field. This might be cumbersome.
• Can create another field (text) and using a workflow assign the value of the integer field to this. This field would be getting displayed in views and forms. The drawback is you have synch both these fields.
• You can have a javascript to remove the comma from the CRM form when it’s loading. Not much difficult. However you still would not be able to get rid of commas when you display a view.
Below I have given a common javascript function which can be used to get rid of commas. Add this to a web resource.
function RemoveComma(fieldname)
{
document.getElementById(fieldname).value = Xrm.Page.data.entity.attributes.get(fieldname).getValue();
}
• Add the web resource to form onload event.
• Call the function RemoveComma with the field name as the parameter.
This way you can use this function anywhere you want just by passing the field name to it.
Tuesday, July 24, 2012
Working with CRM 2011 Multiple Forms
Multiple forms concept came to CRM with 2011 edition. Previously we only had one form per entity. This was fine, but we needed to use javascript to hide fields based on the security role of the user (if the user was not supposed to see a particular field due to security)
With CRM 2011 we don’t have to use javascripts for this. Of course this is still possible. But there is another way of getting this done. You can use multiple forms.
You can have a form to represent a particular security role and you can have only the fields that particular user role should be seeing. So no more javascripts are needed for this.
However if this is not the reason that you have multiple forms in, but for another reason such as
• Depending on a particular response the form should be picked
then we need to do some changes.
We had the same scenario and were greatly helped by the following blog posts.
http://www.avanadeblog.com/xrm/2011/06/crm-2011-form-navigation.html
This post describes how to do it.
http://social.microsoft.com/Forums/zh/crmdevelopment/thread/c06033d2-e158-4931-9340-e1de39c1d09e
This blog post has implemented it.
There are pros and cons for each method. The best method to do this cannot be pinpointed as it would depend on the requirement.
In our case we went ahead with
Xrm.Page.ui.formSelector.items.get(itemId).navigate(); (itemId being the form name or form id)
With CRM 2011 we don’t have to use javascripts for this. Of course this is still possible. But there is another way of getting this done. You can use multiple forms.
You can have a form to represent a particular security role and you can have only the fields that particular user role should be seeing. So no more javascripts are needed for this.
However if this is not the reason that you have multiple forms in, but for another reason such as
• Depending on a particular response the form should be picked
then we need to do some changes.
We had the same scenario and were greatly helped by the following blog posts.
http://www.avanadeblog.com/xrm/2011/06/crm-2011-form-navigation.html
This post describes how to do it.
http://social.microsoft.com/Forums/zh/crmdevelopment/thread/c06033d2-e158-4931-9340-e1de39c1d09e
This blog post has implemented it.
There are pros and cons for each method. The best method to do this cannot be pinpointed as it would depend on the requirement.
In our case we went ahead with
Xrm.Page.ui.formSelector.items.get(itemId).navigate(); (itemId being the form name or form id)
Wednesday, July 11, 2012
Setting the Default Price List for a Product for the first time
When a product is created for the first time the default price list field is disabled. However you can set a value to this by using a javascript.
var lookup = new Object();
var lookupValue = new Array();
lookup.id = “Guid Value”;
lookup.entityType = “pricelevel”;
lookup.name = “Record Name”;
lookupValue[0] = lookup;
Xrm.Page.getAttribute(“pricelevelid”).setValue(lookupValue);
There are very good articles about this which I have given below.
http://mahenderpal.wordpress.com/2011/06/28/set-default-price-list-in-ms-crm-2011-using-java-script/
http://crmbusiness.wordpress.com/2011/02/18/crm-2011-how-to-set-up-a-lookup-using-javascript/
However you might face an issue here as the first time that this fields value is not getting saved to the database. The second time it gets saved.this functionality i have seen only with products. if you save an opportunity you don't get this issue. (If someone has overcome this using javascripts or have done this in any other way than using plugins i would be very much happy to hear about it.)
Is there a way to set the value when the record is saved?.
You cannot use a workflow as the form field is disabled and as you know if a field is disabled on a form then we cannot set a value to it. But using a plugin we can get this done.
We need to use a post create plugin with synchronous mode. I have given below the code for it.
This works correctly and the record is opening with setting a default price list for this field.
public void Execute(IServiceProvider provider)
{
IPluginExecutionContext context = (IPluginExecutionContext)provider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory OrganizationServiceFactory = (IOrganizationServiceFactory)provider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService OrganizationService = OrganizationServiceFactory.CreateOrganizationService(context.UserId);
switch (context.MessageName.ToLower())
{
case "create":
Entity target = context.PostEntityImages["Target"] as Entity;
EntityReference ent = new EntityReference("pricelevel", new Guid("D63F72CC-41CB-E111-B129-080027B1770C"));
target.Attributes.Add("pricelevelid", ent);
OrganizationService.Update(target);
break;
}
}
var lookup = new Object();
var lookupValue = new Array();
lookup.id = “Guid Value”;
lookup.entityType = “pricelevel”;
lookup.name = “Record Name”;
lookupValue[0] = lookup;
Xrm.Page.getAttribute(“pricelevelid”).setValue(lookupValue);
There are very good articles about this which I have given below.
http://mahenderpal.wordpress.com/2011/06/28/set-default-price-list-in-ms-crm-2011-using-java-script/
http://crmbusiness.wordpress.com/2011/02/18/crm-2011-how-to-set-up-a-lookup-using-javascript/
However you might face an issue here as the first time that this fields value is not getting saved to the database. The second time it gets saved.this functionality i have seen only with products. if you save an opportunity you don't get this issue. (If someone has overcome this using javascripts or have done this in any other way than using plugins i would be very much happy to hear about it.)
Is there a way to set the value when the record is saved?.
You cannot use a workflow as the form field is disabled and as you know if a field is disabled on a form then we cannot set a value to it. But using a plugin we can get this done.
We need to use a post create plugin with synchronous mode. I have given below the code for it.
This works correctly and the record is opening with setting a default price list for this field.
public void Execute(IServiceProvider provider)
{
IPluginExecutionContext context = (IPluginExecutionContext)provider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory OrganizationServiceFactory = (IOrganizationServiceFactory)provider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService OrganizationService = OrganizationServiceFactory.CreateOrganizationService(context.UserId);
switch (context.MessageName.ToLower())
{
case "create":
Entity target = context.PostEntityImages["Target"] as Entity;
EntityReference ent = new EntityReference("pricelevel", new Guid("D63F72CC-41CB-E111-B129-080027B1770C"));
target.Attributes.Add("pricelevelid", ent);
OrganizationService.Update(target);
break;
}
}
Adding a web resource as an image to site map
Is this necessary? This might seem not necessary if you have access to all the images that have been added and you do have them. But there are occasions when you don’t have the images or you haven’t kept the images in a repository and you wonder what to do now.
This problem can be solved by adding the relevant sitemap images (at least the navigational) as web resources and setting the image url to the web resource.
I have shown how this can be done below.
For this to work out you need to add the image as a web resource and should give the name pwks_Mngt to it. You can give any name you want. Then the image is distributed with the solution and you will not have any issues finding the image file.
This problem can be solved by adding the relevant sitemap images (at least the navigational) as web resources and setting the image url to the web resource.
I have shown how this can be done below.
For this to work out you need to add the image as a web resource and should give the name pwks_Mngt to it. You can give any name you want. Then the image is distributed with the solution and you will not have any issues finding the image file.
Sunday, July 8, 2012
Managed VS Unmanaged Solutions
This is a debate that most of the developers of CRM 2011 have. Whether to us a managed solution or an unmanaged solution in UAT and Production environments?
Some prefer to use managed solution as this way the customer will not be able to change the solution attributes that the developers have added. Some don’t think like that as they tender to think about the advantageous that using an unmanaged solution would give.
I would prefer having an unmanaged solution in the development and managed solutions in the UAT and Production environments as it would keep the control in our hands. However there are pros and cons to this as well.
There is a great article that has been written by Gonzalo Ruiz regarding this topic of managed and unmanaged solutions at the following link.
http://gonzaloruizcrm.blogspot.ca/2012/01/managed-or-unmanaged-solutions-in-crm.html
Also he has written another nice article about deleting an attribute from a managed environment in the following article.
http://gonzaloruizcrm.blogspot.ca/2012/05/crm-2011-deleting-attributes-entities.html
Both these articles are great articles to read if you are person working with CRM. This would give you some insight of how the things are happening and how you can cope up with them.
Some prefer to use managed solution as this way the customer will not be able to change the solution attributes that the developers have added. Some don’t think like that as they tender to think about the advantageous that using an unmanaged solution would give.
I would prefer having an unmanaged solution in the development and managed solutions in the UAT and Production environments as it would keep the control in our hands. However there are pros and cons to this as well.
There is a great article that has been written by Gonzalo Ruiz regarding this topic of managed and unmanaged solutions at the following link.
http://gonzaloruizcrm.blogspot.ca/2012/01/managed-or-unmanaged-solutions-in-crm.html
Also he has written another nice article about deleting an attribute from a managed environment in the following article.
http://gonzaloruizcrm.blogspot.ca/2012/05/crm-2011-deleting-attributes-entities.html
Both these articles are great articles to read if you are person working with CRM. This would give you some insight of how the things are happening and how you can cope up with them.
Subscribe to:
Posts (Atom)
Retrieving Calendar of a Bookable Resource in Dynamics
There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...
-
There is a bit of change in CRM 2011 than CRM 4. The code is below. Microsoft.Xrm.Sdk. EntityReference Moniker1 = new Microsoft.Xrm.S...
-
When you create a new security role from scratch and then assign only that role to a system user and when you log to the CRM site you might ...
-
There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...