locked
Template Entity - Body and Subject fields is not updating in UI of Dynamic CRM 2013 RRS feed

  • Question

  • Hi All,

    Currently I am working on Template entity of Dynamic CRM 2013. I know that we can change all the fields of Template like Title, Body, Subject, description etc. I am changing all the fields from C#.NET using primary Id(GUID of email).

    Here I am facing problem is that when I changed body and subject of specific email template, it is NOT updating in UI (other fields like title, description is updating in UI). I don't know why body and subject is not updating from C# code for Dynamic CRM 2013. Is it known issue ? or Am I am missing something ?

    Code is as follows :

     case AttributeTypeCode.Memo:

                        if (!String.IsNullOrEmpty(fieldValue))
                            property.Add(SetAttributeData(fieldName, GetProperResult(fieldValue)));
                        else
                            property.Add(SetAttributeData(fieldName, ""));

                        break;

            private string GetProperResult(string inputData)
            {
                return "<?xml version=\"1.0\" ?>"
                    + "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">"
                    + "<xsl:output method=\"text\" indent=\"no\"/><xsl:template match=\"/data\">"
                    + "<![CDATA["
                    + inputData
                    + "]]></xsl:template></xsl:stylesheet>";
            } 

    Once this property is created it is assigned to entity attributes and executed on server. Title, Description is updating on UI, but Body and Subject is not updating.

    Please Help. Thanks


    • Edited by Sud Gujar Sunday, September 14, 2014 11:49 AM
    Sunday, September 14, 2014 11:23 AM

All replies

  • Hi

    The logic of your code sound correct.  The only thing I suggest is to remove the check for IsNullOrEmpty.  If you then do get an error you no that you might have spelled something incorrectly.  On c# also make sure that you are passing the entity as an image an add all the appropriate fields.

    Did you maybe try to create a new type template instead of editing one?  


    Christo Vermeulen


    Monday, September 15, 2014 1:43 PM
  • Hi Christo,

    Thanks for replying.

    >> The only thing I suggest is to remove the check for IsNullOrEmpty.  If you then do get an error you no that you might have spelled something incorrectly.

    I didn't get you property.

    When I got the response from the server after execution of update operation, it didn't show any exception. Note that the "tittle" and "Description" fields are getting updated on UI, but "Body" and "subject" are not getting updated.

     >> Did you maybe try to create a new type template instead of editing one? 

    Yes, I tried to create new template and succeed. But failed for Update.

    In general, I think that Template is predefined structure that can be use to send common mails. So "Title" and "Description" can be different for different users, but "Body" and "Subject" are common, that's why these fields are not getting updated. (May be behavior of Dynamic CRM, But I am not sure.)

    What do you think ?


    Tuesday, September 16, 2014 6:14 AM
  • Change your code : 

      if (!String.IsNullOrEmpty(fieldValue))
                            property.Add(SetAttributeData(fieldName, GetProperResult(fieldValue)));
                        else
                            property.Add(SetAttributeData(fieldName, ""));
    
                        break;

    to 

                          property.Add(SetAttributeData(fieldName, GetProperResult(fieldValue)));
    
                        break;
    If you then do get an error it means that you cannot update the field because it is indeed null or empty.  If you can create template successfully, but not update you are maybe not getting the entity in correct way.  Are you using an image?


    Christo Vermeulen

    Tuesday, September 16, 2014 6:45 AM
  • Hi Christo,

    Thanks for comment. 

    No. I am not passing an entity as image.

    >> If you can create template successfully, but not update you are maybe not getting the entity in correct way.

    After updating, when I query (getting all the attributes updated value from server using unique primary key) the template, I can get updated values for "Subject" and "Body" fields. This means I am getting an entity in correct way. 

    Note that After I created the template, In the same way I tried to update it (It gets updated for all the fields, except "Subject" and "Body").

    Here I tried few observations - 

    “Body’ and ‘Subject’ attribute’s data type is Memo.

     1> If we pass normal string (Not in xml format/tags) to “Body” and “Subject” fields then attributes for "Body" and "Subject" get updated on server but changes not shown on UI.

    After updating if we do query(retrieved all attributes value from server using primary key), it returns updated values (Note that updated values are not displayed on UI.)

    2>  If we pass string in XML format/tags to “Body” and “Subject” attributes, then values doesn’t get updated at all.

    e.g. XML format is as 

    '<?xml version="1.0" ?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="text" indent="no" /><xsl:template match="/data"><![CDATA[Your case has been closed]]></xsl:template></xsl:stylesheet>'

    Please comment.

    Thanks


    Tuesday, September 16, 2014 1:12 PM
  • Did you modify your code as stated in previous post?


    Christo Vermeulen

    Tuesday, September 16, 2014 1:18 PM
  • Hi Christo,

    I implemented your solution, but in vain. I know that your assumption was the fields which were necessary for updating the entity will get blank value and thrown an exception. But we only update those fields to which we have given value only. 

    Please comment.

    Tuesday, September 23, 2014 5:11 AM