Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

remove a particular field from a record before persisting

Certified Lead Developer

Which function do we use to remove a particular field from a record before persisting it?

For example:

recordType!sampleRecord1(
id: null,
column1: A,
column2: B,
column3: C,
column4: D,
column5: E,
column6: F,
column7: G,
column8: H,
relationA: recordType!relationA(
id: null,
column1: A1,
column2: B2,
column3: C3
)
)

I want to remove the id field from both sampleRecord1 and relationA before persisting them.

Reason: The downstream database does not handle id: null well, but if the field is missing or field have a value, it works fine.

The output I want to save should be:

recordType!sampleRecord1(
column1: A,
column2: B,
column3: C,
column4: D,
column5: E,
column6: F,
column7: G,
column8: H,
relationA: recordType!relationA(
column1: A1,
column2: B2,
column3: C3
)
)

Which function do we use to achieve this? i want to handle it dynamically rather mapping individual fields and then persisting .

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    The below code might help you. It gives you the fields which are having only non null values

    a!localVariables(
      local!record: 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'(
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{190df1d5-68fc-404f-8f5a-a520aa180a6e}id': null,
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation': "Lead",
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{e236bd92-5be6-4638-a80c-2ffeeb87962f}isActive': true()
      ),
      reject(
        fn!isnull,
        a!foreach(
          a!keys(local!record),
          if(
            a!isNullOrEmpty(local!record[fv!item]),
            "",
            fv!item
          )
        )
      )
    )

    Output:

Reply
  • 0
    Certified Senior Developer

    The below code might help you. It gives you the fields which are having only non null values

    a!localVariables(
      local!record: 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'(
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{190df1d5-68fc-404f-8f5a-a520aa180a6e}id': null,
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation': "Lead",
        'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{e236bd92-5be6-4638-a80c-2ffeeb87962f}isActive': true()
      ),
      reject(
        fn!isnull,
        a!foreach(
          a!keys(local!record),
          if(
            a!isNullOrEmpty(local!record[fv!item]),
            "",
            fv!item
          )
        )
      )
    )

    Output:

Children