Skip to main content
arockiaprincyv0003
January 3, 2024
Question

Couldn't write the multiple records into related record

  • January 3, 2024
  • 1 reply
  • 0 views


  a!formLayout(
    label: if(
      ri!isUpdate,
      "Update Assessment",
      "Create Assessment"
    ),
    contents: {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!richTextDisplayField(label: local!consequence),
              a!dateField(
                label: "Perform Date",
                labelPosition: "ABOVE",
                required: true,
                value: ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.fields.{d5ec6e7b-3eb6-4ff9-80d8-e8d66785f8a5}performDate'],
                saveInto: ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.fields.{d5ec6e7b-3eb6-4ff9-80d8-e8d66785f8a5}performDate']
              ),
              a!radioButtonField(
                label: "Assessed",
                choicelabels: "People",
                choiceValues: { 1 },
                value: ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.fields.{86f22ac9-15f5-4104-aa21-0f9c1219e436}hazardtypeid'],
                saveInto: ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.fields.{86f22ac9-15f5-4104-aa21-0f9c1219e436}hazardtypeid']
              ),
              a!multipleDropdownField(
                label: "Problems",
                placeholder: "--Select--",
                choicelabels: { "check car", "check train" },
                choiceValues: { 1, 2 },
                value: local!consequence,
                saveInto: {
                  local!consequence,
                  a!save(
                    local!consequenceMap,
                    if(
                      a!isNullOrEmpty(local!consequenceMap),
                      append(
                        local!consequenceMap,
                        a!map(likelihood: "", severity: "")
                      ),
                      if(
                        length(local!consequenceMap) <= length(local!consequence),
                        append(
                          local!consequenceMap,
                          a!map(likelihood: "", severity: "")
                        ),
                        remove(local!consequenceMap, save!value)
                      )
                    )
                  ),
                  a!forEach(
                    items: local!consequence,
                    expression: a!save(
                      ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.relationships.{f8b00574-a976-49bc-9e1b-0f9e61c5a1cb}consequence.fields.{2e89a90f-389b-4280-847d-e9e2b9857766}consequencetypeid'],
                      fv!item
                    )
                  )
                }
              ),
              a!forEach(
                items: local!consequence,
                expression: a!boxLayout(
                  label: fv!item,
                  contents: {
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: a!radioButtonField(
                            label: "Likelihood",
                            choicelabels: {
                              "Very High",
                              "High",
                              "Moderate",
                              "Low",
                              "Very Low"
                            },
                            choiceValues: { 1, 2, 3, 4, 5 },
                            value: local!consequenceMap[fv!index].likelihood,
                            saveInto: {
                              a!save(
                                local!consequenceMap[fv!index].likelihood,
                                save!value
                              ),
                              a!forEach(
                                items: local!consequenceMap.likelihood,
                                expression: a!save(
                                  ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.relationships.{f8b00574-a976-49bc-9e1b-0f9e61c5a1cb}consequence.fields.{566c05f5-9e11-456f-8cb6-fe71597296dd}likelihoodid'],
                                  fv!item
                                )
                              )
                            }
                          )
                        ),
                        a!sideBySideItem(
                          item: a!radioButtonField(
                            label: "Severity",
                            choicelabels: {
                              "Very High",
                              "High",
                              "Moderate",
                              "Low",
                              "Very Low"
                            },
                            choiceValues: { 1, 2, 3, 4, 5 },
                            value: local!consequenceMap[fv!index].severity,
                            saveInto: {
                              a!save(
                                local!consequenceMap[fv!index].severity,
                                save!value
                              ),
                              a!forEach(
                                items: local!consequenceMap.severity,
                                expression: a!save(
                                  ri!record['recordType!{c09e0e7e-5af6-43ec-b8ba-7fae37884015}PVS Assessment.relationships.{f8b00574-a976-49bc-9e1b-0f9e61c5a1cb}consequence.fields.{325519f1-1f74-4db5-9069-fd02d8aca25d}severity'],
                                  fv!item
                                )
                              )
                            }
                          )
                        )
                      }
                    )
                  }
                )
              )
            }
          )
        }
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget_23r3(
          label: if(ri!isUpdate, "Save", "Create"),
          submit: true,
          validate: true,
          style: "PRIMARY"
        )
      },
      secondaryButtons: {
        a!buttonWidget_23r3(
          label: "Cancel",
          value: true,
          saveInto: ri!cancel,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    
  )
)

Hi,

I have an interface with some fields are writing into parent record.

When I select the multiple values into multiple dropdown, the related data is not writing multiple records.Instead of that writing only one related record.When I select both problems from the drop down only it is happening.If I am selecting only one value from the multiple dropdown, there is no issue in writing

I created one to many relationship.

    1 reply

    stefanhelzle0001
    January 3, 2024

    In your code, you use local!consequence and local!consequenceMap. And I have a hard time understanding that logic. Are you sure you are doing the right thing?

    Then, did you check your local variables while toying around with the interface? Does the data you see meet your expectations?