Skip to main content
September 17, 2023
Question

Append empty value to record

  • September 17, 2023
  • 3 replies
  • 1 view

I have a record used in an interface and I want, as I press a dynamic link, in the save() part to add an empty vale to the array of the record, to do this I try a!save(recordtype,append(recordtype,save!vale) the save!value is the recordtype(), but it says it doesn't allow appends to records, how do I do it? I don't have much experience with records still.

I need this because I have a foreach with that recordtype as the item so I need a new row when I press the dynamic link so I can fill the fields that should appear

Thank you

3 replies

mathieud0001
Brainy
September 17, 2023

You need to make sure that your rule input or whatever you're using for the list has the proper type and needs to be set to an array.

Hope this helps,

{
  a!richTextDisplayField(
    value: a!richTextItem(
      text: "Add user",
      link: a!dynamicLink(
        saveInto: {
          a!save(
            ri!userRecords,
            append(
              ri!userRecords,
              'recordType!{SYSTEM_RECORD_TYPE_USER}User'()
            )
          )
        }
      )
    )
  ),
  if(
    a!isNotNullOrEmpty(ri!userRecords),
    a!richTextDisplayField(
      value: a!richTextBulletedList(
        items: ri!userRecords['recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_displayName}displayName']
      )
    ),
    {}
  )
}

September 17, 2023

It's a local variable so shouldn't it allow for arrays instantly?

mathieud0001
Brainy
September 17, 2023

Yeah it does. Here is the same example with local variables.

a!localVariables(
  local!values,
  {
    a!richTextDisplayField(
      value: a!richTextItem(
        text: "Add user",
        link: a!dynamicLink(
          saveInto: {
            a!save(
              local!values,
              append(
                local!values,
                'recordType!{SYSTEM_RECORD_TYPE_USER}User'()
              )
            )
          }
        )
      )
    ),
    if(
      a!isNotNullOrEmpty(local!values),
      a!richTextDisplayField(
        value: a!richTextBulletedList(
          items: local!values['recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_displayName}displayName']
        )
      ),
      {}
    )
  }
)