Saving user input values in cdts from the editable grid

Certified Lead Developer

Hi,

I have editable grid having two columns one is readonly field for showing label and in the second column the user will enter the data. The data for this columns is getting from a local variable . The user can delete the rows and he add row upto 5 rows.

Now I have a cdt with fields like r1, r2, r3, r4, r5. Now I want to map the data entered by the user to cdt.

  Discussion posts and replies are publicly visible

Parents
  • You can just a!save() into the CDT with the local! values like below:

    a!save(ri!CDT.field, index(local!data, "fieldName", null)) <-- you may need an additional level of indexing if the data is nested and/or use type casting if the data types would differ

    You could also build an expression rule, that would be applied over using apply(), to construct the data into the given CDT and save it all in one shot (assuming this is when they submit the form, in a 'saveInto', use the examples below:

    --Rule being used/referenced--
    a!save(
    ri!cdtName,
    apply(
    rule!AppName_buildCDTName(_),
    local!varName /* <---This is assuming you're saving all the user's entries into a single variable */
    )

    --Within rule!AppName_buildCDTName--
    'type!{namespace}CDTName'(
    r1:index(ri!varName, "fieldName", null),
    r2:index(ri!varName, "fieldName", null),
    r3:index(ri!varName, "fieldName", null),
    r4:index(ri!varName, "fieldName", null),
    r5:index(ri!varName, "fieldName", null)
    )

    Note: Don't forget null checks on the a!save()

    You may also have to do some tinkering with the above code, but the options above should generally give you what you want. If you want a more precise answer, please provide the data structure of your local variable after the user has saved X entries.

  • 0
    Certified Lead Developer
    in reply to Reggie

    my local variable:

    local!data: {

       {

         id: 1,

         label: "r1",

         value: ""

       },

       {

         id: 2,

         label: "r2",

         value: ""

       }

     },

    The data entered by user will be inserted into value parameter of the local variable.

    And eventually the data need to be entered to particular field of cdt.

    Is it possible or can anyone suggest what should be the structure of cdt to save the data.

  • 0
    A Score Level 2
    in reply to santoshd378

    Santosh, could you tell me if my assumptions below are correct?

    1. ID is just an auto-generated number which would serve as the identifier in a grid
    2. A label is just context to the value. In other words, the label tells the user what the value is for.
    3. Value is provided by the user which could be anything(?)

  • 0
    Certified Lead Developer
    in reply to Reggie

    Yes, id is an identifier,
    In my editable grid there will be two columns, in 1st column just label will be displayed and in second column a text box will be provided to save the value.

Reply Children
No Data