Add Custom attribute on form using c# RRS feed

  • Question

  • Hi,

    I want to add field(suppose-"new_test") in salesorder using c#

    I can create field in existing entity but how can I put that field in form?

    I try this way:-

    public void UpdateEntityForm(String entityLogicalName)
    QueryExpression qe = new QueryExpression("systemform");
    qe.Criteria.AddCondition("type", ConditionOperator.Equal, 2); //main form
    qe.Criteria.AddCondition("objecttypecode", ConditionOperator.Equal, entityLogicalName); //for new_bankaccount entity
    //Retrieve the first main entity form for this entity
    SystemForm bankAccountMainForm = (SystemForm)_serviceProxy.RetrieveMultiple(qe).Entities[0];

    XDocument bankAccountFormXml = XDocument.Parse(bankAccountMainForm.FormXml);

    bankAccountFormXml.Root.SetAttributeValue("showImage", true);

    String formTabXmlString = @" <tab name=""custom_attributes"" id=""{824792c4-ea85-1504-40e2-b780b26dc6ab}"" IsUserDefined=""0"" locklevel=""0"" showlabel=""true"" expanded=""true"">
    <labels> <label description=""Custom Attributes"" languagecode=""1033"" /></labels>
    <column width=""100%"">
    <section name=""custom_section"" showlabel=""false"" showbar=""false"" locklevel=""0""
    id=""{9bda81ec-e41b-7a4d-08b4-4536c5862ce1}"" IsUserDefined=""0"" layout=""varwidth""
    columns=""1"" labelwidth=""115"" celllabelalignment=""Left"" celllabelposition=""Left"">
    <labels><label description=""Section"" languagecode=""1033"" /></labels>
    <cell showlabel=""true"" locklevel=""0"">
    <labels><label description=""Test"" languagecode=""1033"" /></labels>
    <control id=""modifiedon"" classid=""{5B773807-9FB2-42DB-97C3-7A91EFF8ADFF}""
    datafieldname=""modifiedon"" disabled=""false"" />

    </row></rows> </section></sections></column></columns></tab>";

    XDocument formTabXml = XDocument.Parse(formTabXmlString);

    //Adding this tab to the tabs element

    //Updateing the entity form definition
    bankAccountMainForm.FormXml = bankAccountFormXml.ToString();
    //saving the bank account form
    catch (Exception ex)


    But this way I need to redesign form with all the field..I only want to add one field in already created form.

    If I am using this way it also add a custom tab bt without adding tab ,I only want to add one column or row..

    how can I achieve this?

    • Edited by NikkiShah Monday, September 7, 2015 9:40 AM
    Thursday, September 3, 2015 4:49 AM