Refresh data in editable grid coming from reord Type (data base)

a!localVariables(
 local!refreshVar:1,
  local!loggedInUser: loggedInUser(),
  local!now: now(),
  local!isLevelOneApproval: /*if(a!isUserMemberOfGroup(
    username: local!loggedInUser,
    groups: cons!AMS_DG_GP_ADMINISTRATORS,
  ),true(),false()),*/ false(),
  local!departmentId: if(
    a!isUserMemberOfGroup(
      username: local!loggedInUser,
      groups: {
        cons!AMS_DG_GP_SURGICAL_DEPARTMENT,
        cons!AMS_DG_GP_GENERAL_DEPARTMENT
      },
      matchAllGroups: true()
    ),
    {
      cons!AMS_DG_DB_DEPARTMENT_ID[1],
      cons!AMS_DG_DB_DEPARTMENT_ID[2]
    },
    if(
      a!isUserMemberOfGroup(
        username: local!loggedInUser,
        groups: cons!AMS_DG_GP_SURGICAL_DEPARTMENT,
        
      ),
      cons!AMS_DG_DB_DEPARTMENT_ID[1],
      cons!AMS_DG_DB_DEPARTMENT_ID[2]
    )
  ),
 
  local!appointmentInfo: a!refreshVariable(
    value: if(
    or(local!isLevelOneApproval),
    rule!AMS_DG_GetAppointmentInfo(
      isDS: false,
      fields: {
        {
          'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment',
          'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{960b6dcd-9533-4ba9-b203-341ccc7e3abe}doctor.fields.{191b8c9e-b56e-4953-9bb3-cfb4f097a858}doctorName',
  
        }
      },
      statusIdArray: {
        cons!AMS_DG_DB_STATUS_ID[1],
        cons!AMS_DG_DB_STATUS_ID[8]
      }
    ),
    rule!AMS_DG_GetAppointmentInfo(
      isDS: false,
      fields: {
        'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment',
        'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{960b6dcd-9533-4ba9-b203-341ccc7e3abe}doctor.fields.{191b8c9e-b56e-4953-9bb3-cfb4f097a858}doctorName'
      },
      statusIdArray: cons!AMS_DG_DB_STATUS_ID[2],
      deptIdArray: local!departmentId
    )
  ),
  refreshOnVarChange: local!refreshVar),
  local!approvedOrRejectedAppointments,
  a!formLayout(
    label: "Approve Appointments",
    contents: {
      {
        a!gridLayout(
          label: "Pending for approval",
          labelPosition: cons!AMS_DG_LABEL_POSITION[1],
          headerCells: {
            a!gridLayoutHeaderCell(label: "Appointment Id"),
            a!gridLayoutHeaderCell(label: "Patient Name"),
            a!gridLayoutHeaderCell(label: "Gender"),
            a!gridLayoutHeaderCell(label: "Age"),
            a!gridLayoutHeaderCell(label: "Doctor Name"),
            a!gridLayoutHeaderCell(label: "Appointment Date"),
            a!gridLayoutHeaderCell(label: "Session"),
            a!gridLayoutHeaderCell(label: "Created On"),
            a!gridLayoutHeaderCell(label: "Total appointments",showWhen: not(or(local!isLevelOneApproval))),
            a!gridLayoutHeaderCell(label: ""),
            a!gridLayoutHeaderCell(label: "Comment")
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(width: "DISTRIBUTE")
          },
          rows: {
            a!forEach(
              items: local!appointmentInfo,
              expression: a!gridRowLayout(
                contents: {
                  a!integerField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{274539be-ac91-4f4c-95ed-69bd50175dae}appointmentId',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!textField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{ebbdfb59-46f0-4749-95d2-4ae5866a0b43}patientName',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!textField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{6467d9c9-119e-43b6-834f-4ae90ff83f2e}patientGender',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!integerField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{0f20356b-2a82-464a-b422-aa713158404b}patientAge',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!textField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{960b6dcd-9533-4ba9-b203-341ccc7e3abe}doctor.fields.{191b8c9e-b56e-4953-9bb3-cfb4f097a858}doctorName',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!dateField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{5026132f-9111-432f-bd37-6df4c30723f4}appointmentDate',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!textField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{0097e5d1-71d8-4930-bf32-7f36dbcdfa4a}session',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!dateField(
                    value: index(
                      fv!item,
                      'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{19a1f573-e088-4dd7-bc12-285695cf99c0}createdOn',
                      null
                    ),
                    readOnly: true()
                  ),
                  a!textField(
                    showWhen: not(or(local!isLevelOneApproval)),
                    helpTooltip: "Total number of appointment already exist for perticular day, doctor and session",
                    value: rule!AMS_DG_GetAppointmentInfo(
                      isDS: true(),
                      statusIdArray: cons!AMS_DG_DB_STATUS_ID[3],
                      deptIdArray: local!departmentId,
                      sessionArray: index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{0097e5d1-71d8-4930-bf32-7f36dbcdfa4a}session',null),
                      doctorIdArray: index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{09414ca6-3f27-44c9-8aa8-b2316ed8319c}doctorId',null),
                      appointmentDate: index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{5026132f-9111-432f-bd37-6df4c30723f4}appointmentDate',null)
                      
                    ).totalCount,
                    readOnly: true()
                  ),
                  a!radioButtonField(
                    choiceLabels: cons!AMS_DG_CHOICE_LABEL,
                    choiceValues: if(or(local!isLevelOneApproval), { 2, 4 }, { 3, 4 }),
                    value: if(
                      or(
                        contains(
                          {
                            cons!AMS_DG_DB_STATUS_ID[1],
                            cons!AMS_DG_DB_STATUS_ID[8]
                          },
                          fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId']
                        ),
                        and(
                          {
                            cons!AMS_DG_DB_STATUS_ID[2] = fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId']
                          },
                          not(or(local!isLevelOneApproval))
                        )
                      ),
                      {},
                      index(
                        fv!item,
                        'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId',
                        null
                      )
                    ),
                    saveInto: {
                      fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId'],
                      a!save(fv!item,remove(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{e99aa21c-4dbe-4cb9-943d-e453d2021ea6}comment'))
                      
                    }
                  ),
                  a!textField(
                    value: index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{e99aa21c-4dbe-4cb9-943d-e453d2021ea6}comment.fields.{a8163266-6e90-4df8-b1bf-f5cf7c1a8d01}comment',null),
                    required: or(index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId',null)=cons!AMS_DG_DB_STATUS_ID[4]),
                    disabled: or(index(fv!item,'recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId',null)<>cons!AMS_DG_DB_STATUS_ID[4]),
                    saveInto: {
                      fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{e99aa21c-4dbe-4cb9-943d-e453d2021ea6}comment.fields.{a8163266-6e90-4df8-b1bf-f5cf7c1a8d01}comment'],
                      a!save(fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{e99aa21c-4dbe-4cb9-943d-e453d2021ea6}comment.fields.{651fe152-a76b-40cd-9799-459ad44bc666}commentedBy'],local!loggedInUser),
                      a!save(fv!item['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.relationships.{e99aa21c-4dbe-4cb9-943d-e453d2021ea6}comment.fields.{d4431660-082a-4388-90d0-46ce685714d8}commentedOn'],local!now)
                      }
                  )
                }
              )
            )
          },
          selectionSaveInto: {},
          validations: {},
          shadeAlternateRows: true
        )
      }
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          value: true,
          saveInto: {
            a!save(
              local!approvedOrRejectedAppointments,
              (
                remove(
                  local!appointmentInfo,
                  wherecontains(
                    1,
                    local!appointmentInfo['recordType!{5746f330-8c31-4ea7-9807-cbbd2fd557eb}AMS_DG Appointment.fields.{b78dde74-0103-4f5c-9980-6c1cc18db8a2}statusId']
                  )
                )
              )
            ),
            a!startProcess(
              processModel: cons!AMS_DG_PM_APPROVE,
              processParameters: {
                approvedOrRejectedAppointments: local!approvedOrRejectedAppointments,
                loggedInUser: local!loggedInUser,
                now: local!now,
                approvedId: if(
                  or(local!isLevelOneApproval),
                  cons!AMS_DG_DB_STATUS_ID[2],
                  cons!AMS_DG_DB_STATUS_ID[3]
                )
              }
            ),
            a!save(local!refreshVar,mod(local!refreshVar+1,2))
          },
          submit: true,
          style: cons!AMS_DG_SUBMIT_STYLE[1],
          loadingIndicator: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancel",
          value: true,
          saveInto: {},
          submit: true,
          style: cons!AMS_DG_CANCEL_STYLE[1],
          validate: false
        )
      }
    )
  )
)

I am working on editable grid. Grid shows multiple rows, user can select any row using radio button as ( approved, reject ). After that approved rows goes in DB and make status as approved while rejected rows goes in DB and make status as rejected. After clicking on submit button this scenario takes place for that I have used a!startProcessModel. The requirement is after clicking on submit  button fresh data should come from DB. I have also used refreshAfterOnVarChange  but approved rows doesn't filter out.

Any help will be appriciated.

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data