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

  • hi,

    you can create a some variables:


    - here you can load alldetails which are relevant for your invoicing. you can do this in your form or in process script task in advance 

    you can load them by creating a queryEntity with a entityFilter and search for your FK_STUDENT_ID

    Then if you have your editibale grid, you update your student_Trianing_details by an a!save().

    But the exact approach depends stongly on your CDT and form structue. 

    possible solution

        label: "Training completed at",
        value: ri!Invoice_Detail.Training_Completed_Date,

  • 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:

      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