Skip to main content
mikes2058
December 14, 2023
Solved

What is the best practice for using a!save on a record in a record view?

  • December 14, 2023
  • 2 replies
  • 0 views

Hi, I'm trying to understand best practice here because what I did, works, but i'm not sure if it is the best way to be doing things.

I have a record view with an approve and deny button. A user starts from a table and clicks the master record id to drill in to the record view.

Once on the record view, upon clicking the approve or deny button I run an a!Save on the record to update the status of it to either approved or denied without ever executing a process model. It updates the records status. On the record view I see the record status update and when i return to the main screen which has a table of all the records it is updated there as well.

a!buttonLayout(
    secondaryButtons: {
      a!buttonWidget(
        label: "Deny",
        style: "DESTRUCTIVE",
        saveInto: {
          a!save(
            ri!record['recordType!{...}status'],
            cons!MP_DENY
          )
        },
        disabled: if(
          ri!record['recordType!{...}status'] <> cons!MP_PROCESSED,
          true,
          false
        )
      )
    },
    primaryButtons: {
      a!buttonWidget(
        label: "Approve",
        style: "PRIMARY",
        saveInto: {
          a!save(
            ri!record['recordType!{...}status'],
            cons!MP_APPROVED
          )
        },
        disabled: if(
          ri!record['recordType!{...}status'] <> cons!MP_PROCESSED,
          true,
          false
        )
      )
    },
)

Is this ok? Should I be doing this instead by calling a a!startProcess or a!recordActionField?

    Best answer by mikes0011

    It's ok - as long as it satisfies your requirements and any surrounding organizational requirements for traceability etc.  The one issue with this sort of "live, on-form write" approach is that it doesn't leave behind a trackable trail like a process instance will have.  In many cases that's just fine, but must be evaluated on a case-by-case basis of course.

    As an aside: i think there might be too many "Mike S"'s around here [emoticon:c28b2e4cc20f4ba28d1befdba6bed29c]

    2 replies

    mikes0011
    mikes0011Answer
    Brainy
    December 14, 2023

    It's ok - as long as it satisfies your requirements and any surrounding organizational requirements for traceability etc.  The one issue with this sort of "live, on-form write" approach is that it doesn't leave behind a trackable trail like a process instance will have.  In many cases that's just fine, but must be evaluated on a case-by-case basis of course.

    As an aside: i think there might be too many "Mike S"'s around here [emoticon:c28b2e4cc20f4ba28d1befdba6bed29c]

    mikes2058
    mikes2058Author
    December 14, 2023

    I shared the same concern. We lose it from a tracking as we don't have the process model intervening to say who approved it when. I'll let that weigh in on my use case to determine if I need that level of tracking or not. 

    I agree there are a bunch of us, lets just take over the world [emoticon:c4563cd7d5574777a71c318021cbbcc8]