Question

Create a Task for all tables with the dynamic model - how to set the task parameter

  • 5 January 2022
  • 3 replies
  • 35 views

Userlevel 3
Badge +4

Perhaps my train of thought is off, so perhaps I need a completely different approach… but for now

 

Hi,

With the dynamic model i've written a script that creates a task 'delete_row’. I want this task to 'delete’ the row by updating the row column ‘is_deleted’ from 0 to 1. With a hidden prefilter I filter these deleted-values out. This preserves the records, and makes them easier to restore than a true deleted record from a sql system version table. 

I want to show this task 'Delete row’ on all tables, instead of the SF native delete button. So far, ok. 

However, I can't grasp on how to set the [table]_id parameter. Do I need to create X parameter, one per table? Or can this also be done dynamically? Something like @[table_id] instead of @account_id

With the Sf native delete button, a record is removed from the table, and only available in the history table. I have used this but these history views are not available in other ways currently. If you delete an 'account’ you cannot see this row anymore, and therefore cannot see the history or restore this. 

afaik I cannot e.g create a 'History Menu’ - where a superuser can also see deleted items. Because these views are not in the SF datamodel. (is this correct?) .

Therefore, and is_deleted column + prefilter will give a superuser an option to toggle this filter, and simply change the is_deleted value back to 0 and it should all be ok. 

 

But, as said, perhaps my train of thought is not correct, so any other tips in this matter in more than welcome. 

 

Alexander 

 


3 replies

Userlevel 6
Badge +18

Hi Alexander,

The creation of Tasks with parameters can be fully up to your desire. You can decide to create a Task for each table you have with a name like “task_delete_row_[tab_name]”. With Task parameters, you'll need the Primary key for the table that it is desired for. Insert into task_parmtr all primary key columns of the tab and also use these parameters to connect them to the primary key columns of the table.

Next to that you'll (of course) also need a Control procedure that assigns one or more templates to each delete task you have created with the Dynamic model procedure. 

I can understand this is not a piece of cake, but I hope with some table names and directions this can help:

SF-Tables you'll need to use for sure are:

  • Tab
  • Col
  • Task
  • Task_parmtr
  • Tab_task
  • Tab_task_parmtr
Userlevel 3
Badge +4

Thnx for the input.

I now have a dynamic model script that create a Task per table, adds the correct parameter, add it to the table on tab_task, with the correct parmtr for that table. The task “works” and is ok per table

So, that is good. 

However, now I still need to create a Functionality for this task. 

Now I wonder, can i create 1 Template with something like;

UPDATE [table]
SET is_deleted = 1
WHERE [table]_Id = @[table]_Id

And that this will be generated if the Functionality is set to “SQL” and I add some code there. 

OR, Do I need to create a template per table? 

I have a feeling that above code should work, but before i spend hours trying and searching, a hint would be nice. I know the first part will work - just not sure about the @[table]_id parameter..

Thanks! 

edit; Well, I tried something, and I do think this works :) 

Userlevel 6
Badge +18

Your code template could indeed work if your datamodel corresponds with it of course :wink: one template can be enough indeed. You can weave this template on all program object items that it needs to be assigned to - assigned to all tables that have this is_deleted column (for example). The program object item parameters should also be filled for each program object item your are assigning to. The parameter will then be "table” → "tab_id”.

You may need multiple templates in case the primary key of the table is different, an additional where clause check is needed or other business rules apply; something I cannot judge right now. Hope it helps!

Reply