Start a new topic
Answered

Parallel steppers / workflows

Consider the follow scenario:

User A starts a stepper for authoring a car and changes color from red to black. However, the user does not finish the edit. Instead it is saved until later.

Meanwhile User B opens the same record in the same stepper and changes the color from red to grey and saves the data (completes the stepper)

When User A returns, he/she can happily complete the stepper. The GD value is changed to black without any error, notice or warning that someone else has updated the information in between.

Of course we could setup some kind of workaround that copies e.g. the load id from the originating golden record and then we create a validator for this, but we would of course want to avoid adding a custom solution like this for every workflow and stepper.

(these are all basic entities)


Best Answer

There is an existing enhancement request 'Display concurrent change indicator in browsing' in which you can mention the customer that is asking for this.

The workaround you mention is a good one.

Another way to do this is to add an indicator to show that the record is currently being edited.

It will call a custom procedure like this:

/* Return a comma separated list of users that are currently editing this record */

/* PostgreSQL */
create or replace function usr_get_change_indicator(p_id numeric)
 RETURNS text
 LANGUAGE plpgsql
AS $function$
declare 
  ret text;
begin

    select string_agg( b.b_loadcreator || ' (' || b.b_loadid || ')', ', ' order by b.b_loadid ) into ret
    from 
        sa_my_entity me
        inner join dl_batch b on b.b_loadid = me.b_loadid
    where me.id = p_id
    and b.b_status = 'RUNNING';

  return ret;
end
$function$
;

/* Oracle equivalent */
select LISTAGG(D.B_LOADCREATOR || ' (' || D.B_LOADID || ')' , ', ') within group (order by D.B_LOADID)
   from  
       SA_PRODUCT P
       inner join DL_BATCH D on P.B_LOADID = D.B_LOADID
   where P.ID = &p_id
   and D.B_STATUS = 'RUNNING';


It displays in a collection column where the id of the record being changed is passed to the procedure, so the indicator can warn that the record is being edited by another user.

Note: displaying this in the collection is sufficient for many use cases. But you can got a step further and add a Condition on the Edit Action Configuration using a call to the same function to really prevent a second user from editing the record.


Answer

There is an existing enhancement request 'Display concurrent change indicator in browsing' in which you can mention the customer that is asking for this.

The workaround you mention is a good one.

Another way to do this is to add an indicator to show that the record is currently being edited.

It will call a custom procedure like this:

/* Return a comma separated list of users that are currently editing this record */

/* PostgreSQL */
create or replace function usr_get_change_indicator(p_id numeric)
 RETURNS text
 LANGUAGE plpgsql
AS $function$
declare 
  ret text;
begin

    select string_agg( b.b_loadcreator || ' (' || b.b_loadid || ')', ', ' order by b.b_loadid ) into ret
    from 
        sa_my_entity me
        inner join dl_batch b on b.b_loadid = me.b_loadid
    where me.id = p_id
    and b.b_status = 'RUNNING';

  return ret;
end
$function$
;

/* Oracle equivalent */
select LISTAGG(D.B_LOADCREATOR || ' (' || D.B_LOADID || ')' , ', ') within group (order by D.B_LOADID)
   from  
       SA_PRODUCT P
       inner join DL_BATCH D on P.B_LOADID = D.B_LOADID
   where P.ID = &p_id
   and D.B_STATUS = 'RUNNING';


It displays in a collection column where the id of the record being changed is passed to the procedure, so the indicator can warn that the record is being edited by another user.

Note: displaying this in the collection is sufficient for many use cases. But you can got a step further and add a Condition on the Edit Action Configuration using a call to the same function to really prevent a second user from editing the record.

Hi Subham.


Is it possible to achieve the same result presented above but with the new data-driven workflows? Per my understanding workflow executions are not stored in the dl_batch and sa_ tables so I guess that the data needs top be retrieved somewhere else.

Hello Sebastian,


I have seen that the new gen workflow executions are stored in DL_BATCH but not in the sa_tables, so it might not possible in the new gen workflows.


Thanks

Hi Subham,

Thank you for the use case and proposed solution.

I have similar requirement and want to add little more functionality to that, and I need suggestion from you.

As you said : ..Note: displaying this in the collection is sufficient for many use cases. But you can got a step further and add a Condition on the Edit Action Configuration using a call to the same function to really prevent a second user from editing the record.", I have accomplished this part in my SQL server version.

Now I also want to configure an action or mechanism (to be triggered/controlled from Semarchy itself) to unlock all the records with 'RUNNING' status in 'DIRECT_AUTHORING' either in bulk or records by record. May be I need to write a db function(s) to achieve that, but trying to figure out that can be triggered from Semarchy through some action ('Enable Force Edit for Locked Record') or through a schedule job to run every midnight. 

Please suggest how I can approach that.


Regards,

Kousik

Hi Kousik,


Indeed, restricting the edit in the action set could work for you.


But as you mention, if restriction there is, you need to plan for reverting it.


So, in order to unblock that, you can either add another action in your action set which sole purpose would be to unblock the edition (via triggering a custom procedure in the associated stepper).

This way it would be a manual action at the end of the users that can be actioned whenever required.


If you want to have this automated, I guess you could still create a procedure on the DB and have it scheduled.

Or if you have any scheduling tool, it should be capable of doing that for you.


Hope that gives you material for your implementation.

Best regards,

Alexia


1 person likes this

Hi ,

Thank you for your previous inputs on restricting concurrent user editing.

I created a procedure to identify if the record is being edited by anyone through DL_Batch table  'B_STATUS' field value as 'RUNNNING' and placed that in the condition of EDIT action.

It is working as expected. Even I have also created a mechanism to unlock through some procedure.

Now I have an extended requirement to achieve similar functionality through an EDIT record validation workflow. We are not able to achieve that. 

As per our analysis: 

When we Edit a record through DirectAuthoring, there is an entry in the DL_BATCH with a new b_loadid and b_status = 'RUNNING' and after the editing is completed and user submits the record, b_status is update as 'DONE' for that load.

But when we trigger a workflow for editing, we do not see any entry of the load in the DL_BATCH table.

Then the edited record is sent for validation to the approver, and after the approver Submits the record we see an entry in the DL_BATCH table with B_loadtype='WORKFLOW_SUBMIT'

with b_status is updated as 'DONE'.

There is no entry in the DL_BATCH table when a Workflow is triggered, then please suggest how we can achieve the 'restricting concurrent users and unlocking those' functionality while using EDIT Record Approval workflow.






Hello Kousik,


Indeed, in the workflow cases, while the workflow is not submitted data is not present in the DL_BATCH table.

All workflow related metadata are stored in wf_xxx tables.

I'm not sure what kind of information you are looking for, but the wf_step_instance table contains the different workflow steps and the associated ids (that are specific to workflow management).


Hope this helps you achieve your requirement.

Best regards,

Alexia


1 person likes this

Thank you for the information, Alexia.

Login to post a comment