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

Question

Question

Hiding Form Fields based on User/Participant OR One Form, Multiple Edits/Reviewers

asked on December 9, 2014

Hi All,

 

This is a continuation of the following issue: https://answers.laserfiche.com/questions/68202. I'm not trying to repost a case, just more providing the business context and asking questions...

 

Here is the use context: We have a form where a preparer sets fields and submits. This form gets routed to a reviewer who validates and possibly modifies values on the submitted form. The reviewer also sets additional fields that are originally hidden, and selects approvers for routing. The reviewer can edit anything on the form. Lastly, the approvers approve the form in a read-only state. The approvers can see everything on the form.

 

Rather than create two or three forms (we have about 60-70 fields), we want to hide the reviewer section until the form is in the reviewer's queue, or has been submitted. I was contemplating ways to do this. A good approach seems like populating a Request ID field on form submit. Using this approach, we could hide the reviewer section until the Request ID field is no longer blank.

 

What other approaches exist to accomplish such scenarios? What are the recommended approaches?

 

I understand that Forms passes values from form-to-form (say that three times fast), but in our case, this would be double or triple the forms to maintain. We are still in a development phase, and it would be less than ideal to make the same change on three separate forms. We'd like the ability to be able to hide/show form sections based on user queue or form state/action context.

 

Suggestions welcome! Thanks!

2 0

Answer

SELECTED ANSWER
replied on December 10, 2014

This is doable but not recommend for you need to get some information directly from the forms database using SQL, following are the steps that you can accomplish it:

1. Open the process modeler for the process and find the number in the URL(http://formsserver/Forms/bp/routing/[number]

2.  run following query in the forms database to get all the steps for this process:

 SELECT * FROM [dbo].[cf_bp_steps] where process_id=(select process_id from [dbo].[cf_bp_processes] where bp_id=[number])

3. get the step_id for the step that you want to hide the related sections

4. use similar JavaScript as following to hide the related fields:

$(document).ready(
function() { 
if($('input[name="stepid"]').val() =="[step_id]") {
$("#q8").addClass('hidden');
}
});

 

1 0
replied on October 19, 2018

@████████, thank you for the JavaScript. One question though. If we set the default value of a field to the 'Current Step ID' it will populate the first steps value, but then the variable value will be set and for the following steps the value will not get updated. Do you have an idea of how we can continually update the current step id value in the field for your JavaScript to work?

0 0
replied on October 22, 2018

You can get the value of current step id with following script and set it as value for your field.

var stepId=$('input[name="stepid"]').val();
  $(".currentstepid input").val(stepId);

 

1 0
replied on December 11, 2018

When trying to use the following JavaScript it does not work correctly. If I open DevTools it gives the message 'Uncaught SyntaxError: Unexpected token ( '

$(document).ready(	function () {
  
  //Populates field with current step id
    var newStepID = $('#q222 input')[0].getAttribute('default-val');
    $('#q222 input').val(newStepID);  
  
  function() { 
    if($('input[name="Current_Step_ID"]').val() =="52") {
      $("#q223").addClass('dontshow');
    }
  }
});

Any idea what I am missing?

0 0
replied on December 23, 2018

Hi Blake, you can try with following script:

  
function () {  
  //Populates field with current step id
  //Check whether the input exist before get the attribute will avoid get error on submitted form as the elements are different
  if($('#q222 input')[0]!=null){
    var newStepID = $('#q222 input')[0].getAttribute('default-val');
    $('#q222 input').val(newStepID); 
};
  
    if($('input[name="Current_Step_ID"]').val() =="1") {
      $("#q223").addClass('dontshow');
    };
});

 

0 0

Replies

replied on December 9, 2014

One way you might accomplish this is to populate a hidden field with some kind of a value that would tell you whether it is a reviewer or an approver. It could be hard coded, or you populate it by doing a database lookup into the HR software to pull back the current employees position. Then based on that information you could do field rules to hide if the value of the hidden field matches certain values.

I imagine there is a way to use jQuery to do this as well, but I'm not sure on the details of that kind of implementation.

1 0
replied on February 6, 2015

I am using the JavaScript below to hide a section of a form for the first step in a business process, identified where the is_firststep column of the cf_bp_steps database table (for the relevant process-id)  = 1, but the field is not hidden when I play the business process and the form is first displayed.

 

$(document).ready(

function() { 

if($('input[name="is_firststep"]').val() == 1) {

$("#q10").addClass('hidden');

}

});

 

What am I doing wrong?

0 0
replied on February 19, 2015

Not sure but I noticed that there is no " " around you 1.

0 0
replied on January 6, 2023

Show/hide fields using field rules based on process step is supported in new form designer with Forms 11 Update 3.

You can see other changes of Forms 11 Update 3 from  https://support.laserfiche.com/kb/1014413/list-of-changes-for-laserfiche-forms-11-update-3 and get Forms 11 Update 3 from Laserfiche 11 package  https://support.laserfiche.com/kb/1014263/software-versions-and-fixes-included-in-the-laserfiche-11-download-package.

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

Sign in to reply to this post.