You are viewing limited content. For full access, please sign in.

Question

Question

Event ID in Field rules

asked on September 11, 2024

It appears that using {/_current_step_id} as a default field value does not reflect the actual step ID for a given task (step). I need to be able to count on the correct value to use in field rules. Has anyone developed a solution for this? Or am I using an incorrect system variable?

 

Form reports the following ID for the task which has an ID of 24

0 0

Answer

SELECTED ANSWER
replied on September 11, 2024

Unless I misunderstand, the current_step_ID should change to reflect the current task and indicate so each time a subsequent task is opened. Based on this, I intend to show/hiding collections and also to use the value in javascript to disable fields filled in previous tasks (to prevent changes). I have found that the current_task_name has the same problem. It still holds the next previous tasks name/ID. Actual Task name is 'HR Director Final Approval. The value attribute of the field still has the previous task name.

 

0 0
replied on September 11, 2024

Although it is accurate to say that current_step_id should match the current step, I think perhaps there is some misunderstanding about default values.

Default values will never overwrite an existing/submitted value.

For example, when you load the starting form, the field is blank so it would populate with the step id value as a default (probably where the 14 originates).

When you load the user task, that field already has a value, so it's not that current_step_id is wrong; it is not being applied because the field already has a value from the previous submission (i.e., default only fills empty fields).

This is all expected behavior.

 

One option would be to use workflow; you could have it run a workflow service task that uses the Set Business Process Variables activity to set that field back to NULL and then the default should be applied in the next user task.

You could use a different field/variable for the second task.

 

Another way to handle this would be to use a hidden "helper" field.

Instead of using the default directly in the display field, add a new field with the step values as the defaults. Then, add field rules to Hide Always and Ignore the value so it doesn't get saved.

Next, instead of using the default, use a calculation to set the display field equal to the hidden source field.

Because the hidden field is ignored, it will update to the correct step id on the next task, so at that point all you need to do is trigger the calculation to run.

 

Adding CSS class to source field for easy identification

Calculation on display field

Field rule for source field

Quick-and-dirty javascript example to trigger the calculation to refresh based on the configuration above.

$(document).ready(function(){
    // trigger calculation after form load
    setTimeout(function (){
      $('.stepIdSource input').change();
    }, 100);
});

 

0 0

Replies

replied on September 11, 2024

Here is a link to a post where I did this back in 2018: Field Rules Not Working on Value Changed by JavaScript Bug? - Laserfiche Answers

1 0
replied on September 11, 2024

Thanks Blake.

0 0
replied on September 11, 2024

Are you sure that value wasn't just populated in a previous step?

If the value is not ignored with field rules, then it submits like any other field; the default value only applies when the field is empty.

0 0
replied on September 11, 2024

Here's the jquery from a 'solution' trying to use the step name posted some years ago...

$('.vCurrentStepName input').val('')
  var step = $('.vStepName').text();
  $('.vCurrentStepName input').val(step);

 

Custom HTML field...

<p><span style="font-weight: 700; color: rgb(85, 85, 85);">Displays current step name on the vStepName javascript variable</span><br></p>
<div class="vStepName">{/_current_step_name}</div>
<div class="vStageName"></div>

0 0
replied on September 11, 2024

Thanks for your help Jason.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.