Need to edit data in 2 tables using editable grid

A Score Level 1

Hi all, 


I am working on editable grid where I am adding invoice items for students training. I have two tables which are Invoice_Details and Student_Training_Details. When I am adding the Invoice_Details in the editable grid, I also need to enter the Training_Completed_Date for each student which is a field in Student_Training_Details. How can I achieve this? I have the foreign key FK_STUDENT_ID in both the tables. Thank you.

  Discussion posts and replies are publicly visible

Parents
  • My personal preference when having data that should apply to multiple tables is to set up the data so that it gets saved on clicking your submit button. You can be confident that the data is in the correct state on button click, so it's easy to then save any data to the appropriate fields at that point.

    Here's an example - I'm assuming in this case that the "Student_Training_Details" is a very simple CDT, with just an ID, FK_STUDENT_ID, and TRAINING_COMPLETED_DATE. Then, I'm running a forEach across each item in the "Invoice_Details" to create a new item of the "Student_Training_Details" for each row in the "Invoice_Details". Here's a sample expression for the button click:

    a!buttonWidget(
      label: "Submit",
      submit: true,
      style: "PRIMARY",
      saveInto: a!save(
        target: ri!studentTrainingDetails,
        value: a!forEach(
          items: ri!invoiceDetails,
          expression: type!TYPE_InvoiceDetails(
            studentId: fv!item.studentId,
            trainingCompletedDate: fv!item.trainingCompletedDate
          )
        )
      )
    )

Reply
  • My personal preference when having data that should apply to multiple tables is to set up the data so that it gets saved on clicking your submit button. You can be confident that the data is in the correct state on button click, so it's easy to then save any data to the appropriate fields at that point.

    Here's an example - I'm assuming in this case that the "Student_Training_Details" is a very simple CDT, with just an ID, FK_STUDENT_ID, and TRAINING_COMPLETED_DATE. Then, I'm running a forEach across each item in the "Invoice_Details" to create a new item of the "Student_Training_Details" for each row in the "Invoice_Details". Here's a sample expression for the button click:

    a!buttonWidget(
      label: "Submit",
      submit: true,
      style: "PRIMARY",
      saveInto: a!save(
        target: ri!studentTrainingDetails,
        value: a!forEach(
          items: ri!invoiceDetails,
          expression: type!TYPE_InvoiceDetails(
            studentId: fv!item.studentId,
            trainingCompletedDate: fv!item.trainingCompletedDate
          )
        )
      )
    )

Children
No Data