Passing data to a CDT from a editable grid

Certified Senior Developer

Hello! 

I am working on an interface which shows a editable grid. The grid gets data from a expression rule , which I pass to interface using a local variable. 

Now I want to save the values showed in the grid to the CDT (rule input), but save function doesn't seems to work for me. the rule input is still null. 

Which is the best practice to do that? Or is another way to pass directly the value load into a local variable to rule input?

Thank you

a!localVariables(
  local!user:rule!MV_readCSVcontent(
    if(
    isnull(ri!day),
    today()-1,
    ri!day)),
  local!exportDocId ,
  local!errorMessage  ,
 
 
 
  { 
    
    a!sectionLayout(
      label: "",
      contents: {
        a!sideBySideLayout(
          items: {
            a!sideBySideItem(
              item: a!dateField(
                label: "Date",
                labelPosition: "ABOVE",
                value:ri!day,
                saveInto: ri!day,
                validations: if(
                  ri!day>=today(),
                  "This day is in the future. Please select a past day",

                  if(
                    ri!day < (today()-30),
                    "Can not select a day before 30 days from today",
                    {}
                    
                  )
                ) 
              )
            )
            
          
          }
        )
      }
     
    ),
    
    a!gridLayout(
      label: "grid",
      labelPosition: "COLLAPSED",
      headerCells: {
        a!gridLayoutHeaderCell(label: "Username")
        
      },
      columnConfigs: {
        a!gridLayoutColumnConfig(
          width: "DISTRIBUTE"
        )
       
      },
      rows: {
        a!forEach(
          items: local!user,
          expression:{
            a!gridRowLayout(
              id:fv!index,
              contents: {
                a!textField(
                  label: "Username",
                  value: fv!item,
                  saveInto:  a!save(ri!users.username, fv!item,)
                  
                )
               
              }
            )
          }
        )
      },
      selectionSaveInto:  a!forEach(
        items:local!user,
        expression: a!save(ri!users, local!user)
      ),
      
      showwhen: if(isnull(ri!day),
      false(),
      true()),
      validations: {},
      shadeAlternateRows: true,
      
    ),
    {
      if(
        isnull(local!exportDocId),
        a!linkField(
          labelPosition: "COLLAPSED",
          links: a!dynamicLink(
            label: "Export to Excel File",
            saveInto: {
              a!exportDataStoreEntityToExcel(
                entity: cons!MV_INACTIVE_USER,
                documentName: "Excel Export " & now(),
                saveInFolder: cons!MV_FolderDocumentReference,
                onSuccess: a!save(
                  local!exportDocId,
                  fv!newDocument
                ),
                onError: a!save(
                  local!errorMessage,
                  "Error Exporting File to Excel"
                )
              )
            }
          )
        ),
        {}
      ),
      if(

        not(isnull(local!exportDocId)),

        a!linkField(
          links: a!documentDownloadLink(
            label: "Download Excel File",
            document: local!exportDocId
          )
        ),
        a!textField(
          value: local!errorMessage,
          readOnly: true
        )
      ),
     
    },
    
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          saveInto: a!save(ri!users,ri!users),
          submit: true,
          style: "PRIMARY"
        )
      }


      


    ),
    
    
   
  }
 
  
)

  Discussion posts and replies are publicly visible