Hi Robin,
What I understand is that you want to dynamically grant rights to users with a particular user group. As you cannot do this in IAM, you indeed have to make something yourself to determine whether or not a user may or may not modify a record in a particular state.
You can opt to write a Table-valued function (subroutine) that returns elements from the model in your application. This function is completely generated in the Software Factory, where you have access to the element table and the model_id and branch_id, and then can be deployed in your application.
If you wish to also obtain the user groups of users from IAM, I currently suggest to write a query to give to an Application connector. In your application, make a process flow that obtains the users and user groups via an Application connector, then store the result in your database for further usage.
Some handy information is shared in this blog: All about SQL-typed Control procedures | Thinkwise Community
We also use it for a function called get_dom_elemnts(), which returns all elements of a given domain; also completely generated dynamically.
Our template looks like this:
-- All elements of a given SF domain
return
(
select t.elemnt_id, t.db_value, t.transl
from
(
values
-- copy the above selected data records and paste in here
[ELEMENT_SET],
('-', '-', '-', '-') -- Dummy row
) as t(dom_id, elemnt_id, db_value, transl)
where t.dom_id = @dom_id
and t.dom_id <> '-'
)
Ant the control procedure code itself like this:
insert into #prog_object_item
(
prog_object_id,
prog_object_item_id,
order_no,
template_id
)
select
'func_get_dom_elemnt',
@control_proc_id,
10,
@control_proc_id
insert into #prog_object_item_parmtr
(
prog_object_id,
prog_object_item_id,
parmtr_id,
parmtr_value,
order_no,
no_line_when_empty
)
select
'func_get_dom_elemnt',
@control_proc_id,
'ELEMENT_SET',
'('''+ e.dom_id + ''',' +
''''+ e.elemnt_id + ''',' +
''''+ e.db_value + ''',' +
''''+ coalesce(replace(t.transl, '''', ''''''), '[' + e.elemnt_id + ']') + ''')',
99 + row_number() over(order by e.dom_id, e.abs_order_no),
0
from elemnt e
left join transl_object_transl t
on t.model_id = e.model_id
and t.branch_id = e.branch_id
and t.type_of_object = 2 -- Dom element
and t.transl_object_id = e.elemnt_id
and t.appl_lang_id = 'en-US'
where e.model_id = @model_id
and e.branch_id = @branch_id
Hope this gives the inspiration you need!