locked
set the table rows dynamically depending on a field value RRS feed

  • Question

  • I have a custom field on account form - "number"

    I need to create a html webresource and place it on a section in the accounts form..

    This html page should have a table so that.... If i type number "5" in field .. this section containing html webresourse should display 5 rows of table.

    Hence the table rows should change according to the number given in the feild ..

    Can i get any help on how to create this table in html webpage in which i can give the field reference

    Tuesday, May 13, 2014 12:03 PM

Answers

  • Hi Amy,

    You'll need to use jQuery to dynamically generate the number of rows based on the field value. You can access the field value from the HTML web resource by using the following JavaScript:

    window.parent.Xrm.Page.data.entity.attributes.get("field_name").getValue();

    To dynamically add rows to a table using jQuery have a look here : http://www.ssiddique.info/different-ways-to-add-row-to-a-table-using-jquery.html


    Admin QuikView Solution for CRM 2013

    • Proposed as answer by Guido PreiteMVP Tuesday, May 13, 2014 1:35 PM
    • Marked as answer by Amy.4 Thursday, May 15, 2014 4:54 AM
    Tuesday, May 13, 2014 1:23 PM
  • Hi Amy,

    You can, in that case, have a JavaScript on change of your "number" field; access the html web resource page and dynamically create rows based on the number entered. To access the html web resource from the CRM form JavaScript, you can use the following snippet:

    var obj = Xrm.Page.getControl("IFRAME_Name").getObject();

    Have a look here for details on accessing HTML web resource from CRM form: http://msdn.microsoft.com/en-us/library/jj602964.aspx#BKMK_IFrameAndWebResourceControls.

    Once you have access to the HTML web resource, you can dynamically create a table using jQuery following the link I gave above.


    Admin QuikView Solution for CRM 2013

    • Marked as answer by Amy.4 Thursday, May 15, 2014 4:55 AM
    Wednesday, May 14, 2014 5:10 PM

All replies

  • Hi Amy,

    You'll need to use jQuery to dynamically generate the number of rows based on the field value. You can access the field value from the HTML web resource by using the following JavaScript:

    window.parent.Xrm.Page.data.entity.attributes.get("field_name").getValue();

    To dynamically add rows to a table using jQuery have a look here : http://www.ssiddique.info/different-ways-to-add-row-to-a-table-using-jquery.html


    Admin QuikView Solution for CRM 2013

    • Proposed as answer by Guido PreiteMVP Tuesday, May 13, 2014 1:35 PM
    • Marked as answer by Amy.4 Thursday, May 15, 2014 4:54 AM
    Tuesday, May 13, 2014 1:23 PM
  • Thanks for the help.. Iam very new to html... so i really do not know how to dynamically construct the table ... the main issue is that i want to add rows respective to the number given in the field... 

    I have placed a web resource into a section on account form... and if i insert "5" into "number" field then the section table should show 5 rows... and hence respective to the field number.. the rows should be reflected.. I dont want to use any buttons like "insert" or "delete"

    Can i get any exact code or helpfull links for this senario

    Wednesday, May 14, 2014 6:38 AM
  • Hi Amy,

    You can, in that case, have a JavaScript on change of your "number" field; access the html web resource page and dynamically create rows based on the number entered. To access the html web resource from the CRM form JavaScript, you can use the following snippet:

    var obj = Xrm.Page.getControl("IFRAME_Name").getObject();

    Have a look here for details on accessing HTML web resource from CRM form: http://msdn.microsoft.com/en-us/library/jj602964.aspx#BKMK_IFrameAndWebResourceControls.

    Once you have access to the HTML web resource, you can dynamically create a table using jQuery following the link I gave above.


    Admin QuikView Solution for CRM 2013

    • Marked as answer by Amy.4 Thursday, May 15, 2014 4:55 AM
    Wednesday, May 14, 2014 5:10 PM