Showing custom warning message on an entity form in CRM


Hi,

I was searching for a way to show custom warning message in an entity’s form and came across these two helpful posts

For CRM 4 :-

http://social.microsoft.com/Forums/br/crmdevelopment/thread/1791ab40-a1e6-4099-bb4b-6e52a9a45c18

For CRM 2011 : –

http://crm2011wiki.wordpress.com/2012/04/16/showing-custom-alerts-in-notifications-area/

Hope it helps.

 

“Object doesn’t support property or method ‘setFormMode’” error while closing the record’s form in CRM 2011.


Hi,

We had recently written a plugin for sending email. In the description of the email we were inserting the URL of the record

string recordUrl = string.Format(“<a href=’{0}/userdefined/edit.aspx?etc=4300&id={1}‘>Click here to open the record</a>”, this.serverName, marketingListGuid.ToString());

While clicking the link the record opens properly, however when we try closing the form’s window we get the below error

We have UR8 installed in our on premise development environment there we don’t get this error, however we are still getting the above error for our online dev and production environment.

http://social.microsoft.com/Forums/lv-LV/crmdevelopment/thread/0c0aa09e-0ea6-4150-8056-a2b7b91f3256?prof=required

Bye.

“The import file is too large to upload” error while importing csv file of more than 8 mb in CRM 2011.


Hi,

I was importing a csv file of size 11 mb using import data feature and got the below error.

The unsupported way we can resolve it for our on premise environment is by running the following update query against MSCRM_CONFIG database.

UPDATE ServerSettingsProperties

SET IntColumn =15

where columnname=‘ImportMaxAllowedFileSizeInMB’

Also refer to this support article

http://support.microsoft.com/kb/918609

Bye.

Could not load file or assembly ‘Microsoft.Crm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies while running Stunnware Tools (SWTools) in CRM 2011


Hi,

While trying to run SWTools for CRM 2011, we might receive the “Could not load fie or assembly Microsoft.Crm.Sdk” error.

The solution is to create a file named SwTools.exe.config with the following content


<configuration>
 <runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 <dependentAssembly>
 <assemblyIdentity name="Microsoft.Crm.Sdk" publicKeyToken="31bf3856ad364e35" culture="neutral" />
 <publisherPolicy apply="no" />
 </dependentAssembly>
 </assemblyBinding>
 </runtime>
</configuration>

And place the file where the SwTools.exe is.

Thanks to David for providing the solution.

http://mscrmuk.blogspot.com/2011/02/using-crm-40-assemblies-on-crm-2011.html

Have a look at this post as well

http://blog.aggregatedintelligence.com/2012/03/unable-to-run-website-that-uses.html

Bye.


Sample code to use Template’s content while sending mail using SendEmailReuquest in CRM 2011


Hi,

At times we would like to send email using SendEmailRequest but still want to make use of template and replace the content in it.

For e.g. this is our sample template (Global template)

Here we would replace the [subject] and [url] placeholders.

Sample Code used

</p>
<p>private void SendMail(object sender, EventArgs e)<br />
 {<br />
 IOrganizationService orgService = GetOrganizationService();<br />
 Entity entity = GetGlobalTemplate("My Test Template", GetOrganizationService());<br />
 Entity email = new Entity();<br />
 email.LogicalName = "email";</p>
<p>// get the Subject content from template and replace it with "My New Subject"<br />
 email.Attributes["subject"] = GetDataFromXml(entity.Attributes["subject"].ToString(), "match");<br />
 email.Attributes["subject"] = email.Attributes["subject"].ToString().Replace("[subject]", "My New Subject");</p>
<p>// get the description from template and replace [url] placeholder with a bing's url<br />
 email.Attributes["description"] = GetDataFromXml(entity.Attributes["body"].ToString(), "match");<br />
 string urlToReplace = "&lt;a href='http://www.bing.com'&gt;Open Bing&lt;/a&gt;";<br />
 email.Attributes["description"] = email.Attributes["description"].ToString().Replace("[url]", urlToReplace);</p>
<p>List&lt;Entity&gt; fromtoEntities = new List&lt;Entity&gt;();<br />
 Entity activityParty = new Entity();<br />
 activityParty.LogicalName = "activityparty";<br />
 activityParty.Attributes["partyid"] = new EntityReference("systemuser", new Guid("FC480E73-77A9-E111-B151-00155D882D40"));<br />
 fromtoEntities.Add(activityParty);<br />
 email.Attributes["from"] = fromtoEntities.ToArray();<br />
 email.Attributes["to"] = fromtoEntities.ToArray();<br />
 email.Attributes["regardingobjectid"] = new EntityReference("contact", new Guid("2CCB57AA-A9B3-E111-B151-00155D882D40"));</p>
<p>Guid emailCreated = orgService.Create(email);<br />
 SendEmailRequest req = new SendEmailRequest();<br />
 req.EmailId = emailCreated;<br />
 req.TrackingToken = "";<br />
 req.IssueSend = true;<br />
 SendEmailResponse res = (SendEmailResponse)orgService.Execute(req);<br />
 }</p>
<p>private static string GetDataFromXml(string value, string attributeName)<br />
 {<br />
 if (string.IsNullOrEmpty(value))<br />
 {<br />
 return string.Empty;<br />
 }</p>
<p>XDocument document = XDocument.Parse(value);<br />
 // get the Element with the attribute name specified<br />
 XElement element = document.Descendants().Where(ele =&gt; ele.Attributes().Any(attr =&gt; attr.Name == attributeName)).FirstOrDefault();<br />
 return element == null ? string.Empty : element.Value;<br />
 }</p>
<p>public static Entity GetGlobalTemplate(string title, IOrganizationService orgService)<br />
 {<br />
 Entity emailTemplate = null;<br />
 try<br />
 {</p>
<p>QueryExpression query = new QueryExpression();</p>
<p>// Setup the query for the template entity<br />
 query.EntityName = "template";</p>
<p>// Return all columns<br />
 query.ColumnSet.AllColumns = true;<br />
 query.Criteria = new FilterExpression();<br />
 query.Criteria.FilterOperator = LogicalOperator.And;</p>
<p>// Create the title condition<br />
 ConditionExpression condition1 = new ConditionExpression();<br />
 condition1.AttributeName = "title";<br />
 condition1.Operator = ConditionOperator.Equal;<br />
 condition1.Values.Add(title);</p>
<p>query.Criteria.Conditions.Add(condition1);</p>
<p>// Execute the query and return the result<br />
 EntityCollection entityColl = orgService.RetrieveMultiple(query);</p>
<p>if (entityColl.Entities.Count &gt; 0)<br />
 {<br />
 emailTemplate = entityColl.Entities[0];<br />
 }<br />
 }<br />
 catch<br />
 {<br />
 throw;<br />
 }<br />
 return emailTemplate;<br />
 }</p>
<p>

The email activity created :-

Bye.

Advertisements

Creating Entity with an invalid parent exception. Entity : Email, ReferencingAttribute:regardingobjectid in CRM 2011.


Hi,

We got this error while trying to send email programmatically. The issue was we were setting regarding object id as one of the entity for which Email was not enabled.

 

Hope it helps.