Solved

Self referenced table shows validation error

  • 9 November 2022
  • 3 replies
  • 51 views

Userlevel 2
Badge +3

Hi,

My objective is to have Next task button in each form with fields to enter, after clicking Next button, data will be saved and move to next page. So i came across this question in community and tried to follow it.

So i created a table with fields and at least an identity column and current_step (int domain) column. Made three self references. No fields are mandatory except identity column. 
While running the creation, validation throws error message. How to properly define the self referenced table and make this scenario work? Please advice.
 

 

 

Validate error messages

 
Variants assigned for each reference

 

Process code group for table task

if @current_step=1begin update ce      set ce.current_step=ce.current_step+1 from container_employee ce      where ce.container_employee_id = @container_id and ce.current_step  = @current_step select @execute_tab_task_container_employee_activate_detail_container_employee = 1endelse if @current_step = 2begin update ce     set ce.current_step = ce.current_step+1 from container_employee ce     where ce.container_employee_id = @container_id and ce.current_step  = @current_step select @execute_tab_task_container_employee_activate_detail_container_employee_3  = 1end else if @current_step = 3begin update ce    set ce.current_step = 100 from container_employee ce    where ce.container_employee_id = @container_id and ce.current_step  = @current_step select @execute_tab_task_container_employee_close_document_container_employee = 1end

 

 

 

icon

Best answer by Anne Buit 10 November 2022, 13:16

View original

This topic has been closed for comments

3 replies

Userlevel 2
Badge +3

After setting the Show look-up off, the creation went successful.

Will be adding few more task and settings to complete the scenario and update you. 

Thank you, i am going to use the code block from now on 👍🏻

 

 

Userlevel 7
Badge +5

The general idea is fine but the validation warns about multiple self-references on the column using Check integrity or Show lookup.

From the screenshot I can see that Check integrity is turned off (dotted line) so can you verify the ‘Show look-up’ setting for these references?

 

ps. you can insert ‘Code’ blocks for even better formatting

 

Userlevel 2
Badge +3

The data model looks like this, missed to add it earlier. 

Adding the same code again with better readable format :-) 

 

if @current_step=1

    begin

        update ce

          set ce.current_step=ce.current_step+1

          from container_employee ce

          where ce.container_employee_id = @container_id

          and ce.current_step  = @current_step

       select @execute_tab_task_container_employee_activate_detail_container_employee = 1

    end

   

    else if @current_step = 2

    begin

        update ce

         set ce.current_step = ce.current_step+1

         from container_employee ce

         where ce.container_employee_id = @container_id

         and ce.current_step  = @current_step

        select @execute_tab_task_container_employee_activate_detail_container_employee_3  = 1

    end

    else if @current_step = 3

    begin

        update ce

        set ce.current_step = 100

        from container_employee ce

        where ce.container_employee_id = @container_id

        and ce.current_step  = @current_step

   

        select  @execute_tab_task_container_employee_close_document_container_employee = 1

    end