Saving editable grid

Hello Team,

I have build an editable grind and now I want to save the values inside my records. I have record table and rule input in my interface the problem is how I can save this data for each request I have. The data is a sample there are around 15 rows which I want the user to be able to save some of them can be null some of them can be filled out. Basically the property is read only, once user enter value we can use a!save to save the property for the respective row, but I always get cannot index rule input records..

rows: {
                            a!gridRowLayout(
                              contents: {
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextItem(
                                      text: {"Melting Point"}
                                    )
                                  }
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  disabled: false,
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"g/cm3", "kg/m3"},
                                  choiceValues: {"g/cm3", "kg/m3"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "Select",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  validations: {}
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"℃", "℉"},
                                  choiceValues: {"℃", "℉"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "Select",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"Property has not been measured"},
                                  choiceValues: {"Property has not been measured"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "--- Select a Value ---",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                )
                              },
                              showWhen: if(
                                or(
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "LIquid",
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "Solid",
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = ""
                                ),
                                true,
                                false)
                            ),
                            a!gridRowLayout(
                              contents: {
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextItem(
                                      text: {"Freezing Point"}
                                    )
                                  }
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  disabled: false,
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"g/cm3", "kg/m3"},
                                  choiceValues: {"g/cm3", "kg/m3"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "Select",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  validations: {}
                                ),
                                a!textField(
                                  label: "Text",
                                  labelPosition: "ABOVE",
                                  saveInto: {},
                                  refreshAfter: "UNFOCUS",
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"℃", "℉"},
                                  choiceValues: {"℃", "℉"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "Select",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                ),
                                a!dropdownField(
                                  choiceLabels: {"Property has not been measured"},
                                  choiceValues: {"Property has not been measured"},
                                  label: "Dropdown",
                                  labelPosition: "ABOVE",
                                  placeholder: "--- Select a Value ---",
                                  saveInto: {},
                                  searchDisplay: "AUTO",
                                  validations: {}
                                )
                              },
                              showWhen: if(
                                or(
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "LIquid",
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "Solid",
                                  ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = ""
                                ),
                                true,
                                false)
                            ),
                            a!gridRowLayout(
                              contents: {
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextItem(
                                      text: {"Boiling Point"}
                                    )
                                  }
                                ),

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    in reply to Shwapx

    Do you have a specific reason to use a grid for this?

  • What would be the other option to be able to save them in one table? Just text fields and dropdowns? But how to save them again in one table?

  • 0
    Certified Associate Developer

    This may be occurring due to the direct [ ] indexing. Try Using the property or Index function.

  • Can you give me an example with the full code which I provided in my previous comment. Thank you!

  • 0
    Certified Associate Developer
    in reply to Shwapx

    Sure. I have tried to replicate and solve this error in 1st and 2nd SS respectively.

    In the first SS, as you can see I am trying to access a field of a null row which is causing the same error mentioned
      

    In the 2nd SS, you can see I am trying to do the same thing with the property and index function, which is not giving an error this time.


    if you have done something like the one mentioned in 1st SS then try to replicate the 2nd SS logic

  • This is still saving only one value and it's not visible in the field.



  • 0
    Certified Associate Developer
    in reply to Shwapx

    Instead of using ri!AOS_physChemDetails use fv!index of foreach in save into of editable grid components. 

  • It's still not working.



    rows: {
                                a!gridRowLayout(
                                  contents: {
                                    a!richTextDisplayField(
                                      labelPosition: "COLLAPSED",
                                      value: {
                                        a!richTextItem(
                                          text: {"Melting Point"}
                                        )
                                      }
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      value: property(index(ri!AOS_PhysChemDetails,1,{}),'recordType!{45e1c911-2882-4182-a967-cf53ca64dedd}AOS_Phys_Chem_Details',{}),
                                      saveInto: fv!row,
                                      refreshAfter: "UNFOCUS",
                                      disabled: false,
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"g/cm3", "kg/m3"},
                                      choiceValues: {"g/cm3", "kg/m3"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "Select",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      saveInto: {},
                                      refreshAfter: "UNFOCUS",
                                      validations: {}
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      saveInto: {},
                                      refreshAfter: "UNFOCUS",
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"℃", "℉"},
                                      choiceValues: {"℃", "℉"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "Select",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"Property has not been measured"},
                                      choiceValues: {"Property has not been measured"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "--- Select a Value ---",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    )
                                  },
                                  showWhen: if(
                                    or(
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "LIquid",
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "Solid",
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = ""
                                    ),
                                    true,
                                    false)
                                ),
                                a!gridRowLayout(
                                  contents: {
                                    a!richTextDisplayField(
                                      labelPosition: "COLLAPSED",
                                      value: {
                                        a!richTextItem(
                                          text: {"Freezing Point"}
                                        )
                                      }
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      saveInto: {},
                                      refreshAfter: "UNFOCUS",
                                      disabled: false,
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"g/cm3", "kg/m3"},
                                      choiceValues: {"g/cm3", "kg/m3"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "Select",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      saveInto: {},
                                      refreshAfter: "UNFOCUS",
                                      validations: {}
                                    ),
                                    a!textField(
                                      label: "Text",
                                      labelPosition: "ABOVE",
                                      saveInto: {},
                                      refreshAfter: "UNFOCUS",
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"℃", "℉"},
                                      choiceValues: {"℃", "℉"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "Select",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    ),
                                    a!dropdownField(
                                      choiceLabels: {"Property has not been measured"},
                                      choiceValues: {"Property has not been measured"},
                                      label: "Dropdown",
                                      labelPosition: "ABOVE",
                                      placeholder: "--- Select a Value ---",
                                      saveInto: {},
                                      searchDisplay: "AUTO",
                                      validations: {}
                                    )
                                  },
                                  showWhen: if(
                                    or(
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "LIquid",
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = "Solid",
                                      ri!AOS_PhysChem['recordType!{1ddc2dbc-133e-49a3-a416-3e896db0beb4}AOS_Phys_chem.fields.{6862862b-7cbf-4b5d-be70-7944f6a23f5b}PhysicalState'] = ""
                                    ),
                                    true,
                                    false)
                                ),
                                a!gridRowLayout(

  • 0
    Certified Associate Developer
    in reply to Shwapx

    To iterate each row, You have to use foreach before gridRowLayout like below.

    {
    a!gridLayout(
    label: "Editable Grid",
    labelPosition: "ABOVE",
    headerCells: {
    a!gridLayoutHeaderCell(label: "Header Cell")
    },
    rows: a!forEach(
    items: ri!tableFromRecord,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    value: property(
    fv!item,
    'recordType!{c897e5ab-3e9a-4bd3-8bd0-4fcc5cd9882c}CT Table From Record.fields.{65173c83-afcb-405e-8d33-23ee406b1638}createdBy',
    null()
    ),
    saveInto: fv!item['recordType!{c897e5ab-3e9a-4bd3-8bd0-4fcc5cd9882c}CT Table From Record.fields.{65173c83-afcb-405e-8d33-23ee406b1638}createdBy']
    )
    }
    )
    ),
    selectionSaveInto: {},
    validations: {},
    shadeAlternateRows: true
    )
    }

  • How do you have defined 15 items I don't see that anywhere? And how to hide some rows for example if anything is selected? This is something i need that's why each row was independent.