Iโve been contracted to rapidly develop an app for medical services. Part of the requirement is for me to ensure that data is never destroyed in order for the app to be certified.
This is commonly implemented in the following manner:
Conceptually it works for me. The only hurdle is how to override the default system-generated CRUD actions. Iโve read a few articles here at the forum that makes me believe that it is possible, but I must be doing something wrong.
Can anyone point me to a YouTube video that demonstrates how to do it? Absent that, any articles or posts that you would recommend?
Iโm aware that I donโt need to override the โAddโ action. All I need to do is set these initial values: LifecycleStart=NOW() and LifecycleEnd=MAXDATE. So, I just need to override the โEditโ and โDeleteโ actions.
I also planned for the possibility that Lifecycle management is beyond AppSheetโs ability. Iโve made the client aware of possible shortcomings. They are onboard with contracting the development of a custom mobile app if AppSheet canโt meet this requirement. At least they rapidly get to market with my app, and then use it to demonstrate to a software shop exactly what they want. That saves them a lot of money. The downside is that AppSheet loses paying customers when the custom app replaces mine.
Iโm aware that I could log out data changes, but I donโt fancy having to re-create the app state by rewinding the audit trail. I prefer to simply go to the Slice filter condition and replace NOW() with a specific date in the past.
Any feedback is greatly appreciated.
Thanks,
Brian
Solved! Go to Solution.
Thanks Marc, your suggestion worked, but I had to be a little creative. I keep forgetting that the only state variables are those stored in columns. Youโll see my solution below:
First, I added a column called โEdit IDโ in my โActivityโ table. โEdit IDโ is a placeholder for a new key that will be generated when I execute the โLifecycle Create IDโ action.
Now, my reworked โLifecycle Editโ action executes the following actions:
โLifecycle Create IDโ
โLifecycle Deleteโ.
โLifecycle Create Copyโ.
โLifecycle Edit Copyโ.
Here is what โLifecycle Create IDโ does:
Data: set the values of some columns in this row
Set [Edit ID]=UNIQUEID() for this row.
Here is what โLifecycle Deleteโ does:
Data: set the values of some columns in this row
Set [LifecycleEnd]=NOW()
Here is what โLifecycle Create Copyโ does:
Data: add a new row to another table using values from this row
From/To table: Activity
Set ID=[Edit ID]
Set Activity name=[Activity name]
Set LifecycleStart=NOW()
Set LifecycleEnd=DATETIME(โ12/31/2999 23:59:59โ)
Here is what โLifecycle Edit Copyโ does:
App: go to another view within the app
LINKTOROW([Edit ID],โActivity_Formโ)
Here is a screenshot demo:
Hide the system-generated Delete and Edit Actions. Create your own Actions to replace them. Delete should be easy, just a data change. Edit should probably be a โGroupedโ Action, with the same data change as Delete, then an โAdd new rowโ.
As for the second portion of your post, Iโm afraid Iโm not even sure what youโre talking about.
Thanks for your reply, Marc. Sorry about that second portion of my post. I was just expressing frustration that I donโt have greater control. โNo Codeโ sounds great, but for a programmer it means โHandcuffsโ.
Iโve been experimenting prior to discovering your reply. I ended up doing exactly as you suggested by creating custom Actions. Everything works great except the final step in my Edit Action. Let me explain what Iโm doing:
I created an Action called โLifecycle Editโ.
It executes a sequence of Actions:
I created an Action called โLifecycle Deleteโ.
It sets [LifecycleEnd]=NOW() for this row.
I created an Action called โCopy this row and edit the copyโ.
It executes โApp: copy this row and edit the copyโ.
I created an Action called โPromote Lifecycle to Currentโ.
It sets [LifecycleStart]=NOW() for this row
and [LifecycleEnd]=DATETIME(โ12/31/2999 23:59:59โ)
When I click the โLifecycle Editโ button on the current row, everything works except the last step โPromote Lifecycle to Currentโ. I was expecting that the โcurrent rowโ would point to the copied record from the previous step. However, it appears as if the current row is undefined.
Do you know if this is expected behavior? Perhaps I should put in a ticket?
Thanks,
Brian
Hi @Brian_Morgan
I believe your sequence stops at the second action because this one involves a save and stops the process.
Added edit
You may need to use LINKTO FORM.
Thank you, Lynn, Iโll give that a try.
Brian
Sort of. It is because the โcopy and editโ Action is a navigation Action.
This is why I suggested the โAdd new rowโ Action, in which you can specify values for the fields in the new row. You may also wish to add a LINKTOROW() navigation as a 3rd Action in the group, if the record needs edited any further by the user.
Thanks Marc, your suggestion worked, but I had to be a little creative. I keep forgetting that the only state variables are those stored in columns. Youโll see my solution below:
First, I added a column called โEdit IDโ in my โActivityโ table. โEdit IDโ is a placeholder for a new key that will be generated when I execute the โLifecycle Create IDโ action.
Now, my reworked โLifecycle Editโ action executes the following actions:
โLifecycle Create IDโ
โLifecycle Deleteโ.
โLifecycle Create Copyโ.
โLifecycle Edit Copyโ.
Here is what โLifecycle Create IDโ does:
Data: set the values of some columns in this row
Set [Edit ID]=UNIQUEID() for this row.
Here is what โLifecycle Deleteโ does:
Data: set the values of some columns in this row
Set [LifecycleEnd]=NOW()
Here is what โLifecycle Create Copyโ does:
Data: add a new row to another table using values from this row
From/To table: Activity
Set ID=[Edit ID]
Set Activity name=[Activity name]
Set LifecycleStart=NOW()
Set LifecycleEnd=DATETIME(โ12/31/2999 23:59:59โ)
Here is what โLifecycle Edit Copyโ does:
App: go to another view within the app
LINKTOROW([Edit ID],โActivity_Formโ)
Here is a screenshot demo:
Marc and Lynn,
Thank you very much for your help, but I just came up with a scenario that can only be solved by the AppSheet core since it is aware of the schema. For example, say I have two related tables: Parent and Child. Suppose I create a Parent record: โCarolโ. Carol has two children: โAmandaโ and โMelissaโ. Now letโs say that I misspelled the parentโs name. It is really โCarolaโ. So I edit the parent record and Bam! The two child records point to the old retired โCarolโ record. Not good.
Like I said I think this behavior is best handled by the AppSheet team. Perhaps they might want to offer it in a future version. In the meantime, Iโll revert to Plan B, writing to an Audit log.
Thanks again for your help. I send you โLikesโ!
Brian
User | Count |
---|---|
40 | |
34 | |
28 | |
23 | |
17 |