Skip to main content
varuntejg243705
January 14, 2024
Question

Cannot write to records from interface

  • January 14, 2024
  • 3 replies
  • 0 views

a!localVariables(
  local!emails:{
   "def@gmail.com","abc@gmail.com"},
  local!a,
  a!formLayout(
    label: "Form",
    contents: {},
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          submit: true,
          saveInto: {
            a!forEach(items: local!emails,
          expression: 
            a!writeRecords(
            records: 'recordType!{c5b11a4d-cd52-43c4-ab87-2e1ef53bfcee}BMA Emails'(
              'recordType!{c5b11a4d-cd52-43c4-ab87-2e1ef53bfcee}BMA Emails.fields.{20167940-35f1-4106-9a3b-6a585ba2fff2}email': fv!item,

            ),
            onSuccess: {a!save(local!a,append(local!a,1))},
            onError: {}
          ))},
          style: "SOLID",
          loadingIndicator: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancel",
          value: true,
          saveInto: {},
          submit: true,
          style: "OUTLINE",
          validate: false
        )
      }
    )
  )
)

Hello I want to send a list of emails to record type using a local variable, but couldn't able to do,

Thanks

3 replies

rithanir5887
January 14, 2024

Hello [mention:3f9551bc38d94a79ae62f9d520dbad6d:e9ed411860ed4f2ba0265705b8793d05] ,

Construct your data in a local variable and and then write the data to the record type using a!writerecords() in the button.

a!localVariables(
  local!countries: { "Italy", "Germany" },
  local!recordConstruct: a!forEach(
    items: local!countries,
    expression: 'recordType!{c6aa3272-8051-4553-92f9-1e8da444ec27}FWC Country'(
      'recordType!{c6aa3272-8051-4553-92f9-1e8da444ec27}FWC Country.fields.{0476d6f9-4a1b-4d0c-bb29-f06e74fd6a95}name': fv!item
    )
  ),
  a!formLayout(
    label: "Form",
    contents: {},
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          submit: local!recordConstruct,
          saveInto: a!writeRecords(
            records: local!recordConstruct
          ),
          loadingIndicator: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancel",
          value: true,
          saveInto: {},
          submit: true,
          validate: false
        )
      }
    )
  )
)

varuntejg243705
January 14, 2024

Working [mention:07e65f9e440e41fdad9b01615263f43d:e9ed411860ed4f2ba0265705b8793d05] , Thank you!!!

harshitb6843
January 14, 2024

a!writeRecords are capable of writing multiple records at once. And this behavior is the same with deleteRecords and writeToDataStoreEntity and other related smart services. 

PRO Tip - You can only execute one smart servcie in a saveInto.