Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Using JavaScript to update an Editable Grid

  • 1.  Using JavaScript to update an Editable Grid

    Posted 5 days ago
    I have a form that contains an editable grid, and I have the need to change multiple fields on the editable grid, based on a value entered by a user into a field on the form. In other words, the user is going to enter a discount percentage, and then I need to discount each line in the editable grid by that percentage. Is it possible to use JavaScript to do this? Has anyone done anything similar to this? If so, do you have any examples I can work from?

    Any help would be appreciated.

    Thank you.


    ------------------------------
    Scott Grimes
    Illinois Tool Works
    Troy OH
    ------------------------------


  • 2.  RE: Using JavaScript to update an Editable Grid

    Posted 5 days ago
    Since the records in the grid are in fact related entities, my approach from here would be to use the WebApi to Retrieve all the records, then use it to update each record, then refresh the grid when all updates are made.


    ------------------------------
    Jason DiMarzio
    Technical Lead
    Foundation Medicine
    Cambridge MA
    ------------------------------



  • 3.  RE: Using JavaScript to update an Editable Grid

    GOLD CONTRIBUTOR
    Posted 5 days ago

    Scott,

    This example from the "How To Use JavaScript for Editable Grids in Dynamics 365" blog posted by Magnetism on the Dynamics community board might help you get started:


    https://community.dynamics.com/crm/b/magnetismsolutionscrmblog/archive/2017/10/07/how-to-use-javascript-for-editable-grids-in-dynamics-365



    ------------------------------
    Patrick O'Donnell | VP - Business Development, the Americas
    mscrm-addons.com
    Patrick.ODonnell@mscrm-addons.com
    Atlanta GA
    770 781 8260 Cell
    ------------------------------



  • 4.  RE: Using JavaScript to update an Editable Grid

    Posted 4 days ago
    Thank you for your help!

    ------------------------------
    Scott Grimes
    Illinois Tool Works
    Troy OH
    ------------------------------



  • 5.  RE: Using JavaScript to update an Editable Grid

    TOP CONTRIBUTOR
    Posted 4 days ago

    My 2 cents on the js.

    1. Use a type system such as TypeScript or FlowJS. I recommend Flow JS
    2. Use Es6 standards let, stop using var(hoisting issues).
    3. Destruct to the closest object instead of constantly hopping back to the top object.
      let {attributes} = context.getFormContext().data.entity,
      telephone1 = attributes.getByName("attributes"),
      address1_county = attributes.getByName("address1_county");

      *I give the variables the same name as to the attributes that they are referring to. Why rename them?
    4. Know how to use falsy.

    Cheers!



    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------