Archive for June, 2012

Hi,

Sometimes we’d see our drop down list getting fixed i.e. drop down doesn’t appear when we click on the attribute.

One option is to either refresh the form or the other better option is to click on the tabs on the left side instead of refreshing the whole page.

More details here


http://social.microsoft.com/Forums/uk/crmdevelopment/thread/49737c72-f79a-428c-94bf-e26dc4b89cef

Bye.

Hi,

Today I created my first Metro Style App, A Blog Reader that would let me read blog posts of some of my close friends who love blogging.

For that watched the following training video on pluralsight

Introduction to building Windows 8 Metro Applications

And followed this wonderful article on MSDN


http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Few Screen shots of the app

Bye.

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.


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


private void SendMail(object sender, EventArgs e)
 {
 IOrganizationService orgService = GetOrganizationService();
 Entity entity = GetGlobalTemplate("My Test Template", GetOrganizationService());
 Entity email = new Entity();
 email.LogicalName = "email";

// get the Subject content from template and replace it with "My New Subject"
 email.Attributes["subject"] = GetDataFromXml(entity.Attributes["subject"].ToString(), "match");
 email.Attributes["subject"] = email.Attributes["subject"].ToString().Replace("[subject]", "My New Subject");

// get the description from template and replace [url] placeholder with a bing's url
 email.Attributes["description"] = GetDataFromXml(entity.Attributes["body"].ToString(), "match");
 string urlToReplace = "<a href='http://www.bing.com'>Open Bing</a>";
 email.Attributes["description"] = email.Attributes["description"].ToString().Replace("[url]", urlToReplace);

List<Entity> fromtoEntities = new List<Entity>();
 Entity activityParty = new Entity();
 activityParty.LogicalName = "activityparty";
 activityParty.Attributes["partyid"] = new EntityReference("systemuser", new Guid("FC480E73-77A9-E111-B151-00155D882D40"));
 fromtoEntities.Add(activityParty);
 email.Attributes["from"] = fromtoEntities.ToArray();
 email.Attributes["to"] = fromtoEntities.ToArray();
 email.Attributes["regardingobjectid"] = new EntityReference("contact", new Guid("2CCB57AA-A9B3-E111-B151-00155D882D40"));

Guid emailCreated = orgService.Create(email);
 SendEmailRequest req = new SendEmailRequest();
 req.EmailId = emailCreated;
 req.TrackingToken = "";
 req.IssueSend = true;
 SendEmailResponse res = (SendEmailResponse)orgService.Execute(req);
 }

private static string GetDataFromXml(string value, string attributeName)
 {
 if (string.IsNullOrEmpty(value))
 {
 return string.Empty;
 }

XDocument document = XDocument.Parse(value);
 // get the Element with the attribute name specified
 XElement element = document.Descendants().Where(ele => ele.Attributes().Any(attr => attr.Name == attributeName)).FirstOrDefault();
 return element == null ? string.Empty : element.Value;
 }

public static Entity GetGlobalTemplate(string title, IOrganizationService orgService)
 {
 Entity emailTemplate = null;
 try
 {

QueryExpression query = new QueryExpression();

// Setup the query for the template entity
 query.EntityName = "template";

// Return all columns
 query.ColumnSet.AllColumns = true;
 query.Criteria = new FilterExpression();
 query.Criteria.FilterOperator = LogicalOperator.And;

// Create the title condition
 ConditionExpression condition1 = new ConditionExpression();
 condition1.AttributeName = "title";
 condition1.Operator = ConditionOperator.Equal;
 condition1.Values.Add(title);

query.Criteria.Conditions.Add(condition1);

// Execute the query and return the result
 EntityCollection entityColl = orgService.RetrieveMultiple(query);

if (entityColl.Entities.Count > 0)
 {
 emailTemplate = entityColl.Entities[0];
 }
 }
 catch
 {
 throw;
 }
 return emailTemplate;
 }

The email activity created :-

Bye.

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.