locked
Problem with displaying Html.Encoded special characters using Dynamics CRM Sdk RRS feed

  • Question

  • Hello,

    When I used Dynamics Crm sdk to create/update an Account in Dynamics CRM, I had to use Html.Encode to encode some special account names such as AT&T, Steve's Co etc, otherwise the Sdk service call will throw exception. My question is, when the account name is displayed in Dynamics Account UI, it does not automatically Html.Decode to restore name to AT&T. I am a back end developer so not sure if the UI field can be configured to display Html coded text, or is there anything I can do from back end to ensure that the encoded name will be saved to AccountBase table as AT&T instead of AT&T?

    Thanks in advance for any insight!


    bjs

    Monday, October 31, 2016 9:25 PM

Answers

  • The simple answer is - don't use that encoding approach. I usually don't use Early Binding but that shold not bring an issues.

    Post an exception you get (when you create an account with special characters) here please.


    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    • Marked as answer by shigangy Tuesday, November 1, 2016 7:40 PM
    Tuesday, November 1, 2016 1:01 PM
    Moderator

All replies

  • Have you tried parsing with Hexcode?
    Monday, October 31, 2016 10:25 PM
  • Hello,

    Can you please provide code you used to create/update accounts?


    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Tuesday, November 1, 2016 10:48 AM
    Moderator
  • using (var service = new OrganizationService(_connection))
                {
                    var sdkAccount = new Account()
                    {
                        Name = System.Web.HttpUtility.HtmlEncode(account.AccountName),
                        AccountCategoryCode = new OptionSetValue((int)account.CategoryCode),
                        CustomerTypeCode = new OptionSetValue((int)account.CustomerTypeCode),
                       
                        ....

                    };
                    var accountId = service.Create(sdkAccount);
                    if (accountId != Guid.Empty && account.Contacts.Any())
                    {
                        AssociateContactsToAccount(account.Contacts, accountId, service);

                    }
                    return accountId;
                }


    bjs

    Tuesday, November 1, 2016 12:52 PM
  • The simple answer is - don't use that encoding approach. I usually don't use Early Binding but that shold not bring an issues.

    Post an exception you get (when you create an account with special characters) here please.


    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    • Marked as answer by shigangy Tuesday, November 1, 2016 7:40 PM
    Tuesday, November 1, 2016 1:01 PM
    Moderator
  • Well, now it does not throw exception any more after I removed the encoding and the previously non-valid names now have no issue passing through. There must be some sdk update or upgraded version CRM that has taken care of this.

    Thanks a lot for your help!


    bjs

    Tuesday, November 1, 2016 7:40 PM