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

Discussion

Discussion

Enhancement to LFForm Object and/or Layout Designer - Page Title and Notes Based on Action Buttons

posted on June 16, 2023 Show version history

The team at Laserfiche has asked us to let them know use cases of things where we still use the Classic Designer, with the intent of trying to recreate that functionality in the Layout Designer or the LFForm interface.

I have two examples I use on nearly every form, that I can't currently re-create using the Layout Designer.  I'd love to have a way to manage these in the Layout Designer, either built-in functionality or coding options with the LFForm interface.

The first is setting the page title (so it's something other than "New Submission").  I usually do this by setting it to the name of the task.  To do that, I add a custom HTML element to my form with   {/_current_step_name}   as the content of the field, and a CSS class name of getCurrentStepName.  Because it's a custom HTML element, it re-populates the content every time the form is loaded.  Then I can use Javascript to set the page title to that value, like this: 

  //Set the page title.
  if($('.getCurrentStepName').text() != '') {
    $('title').text($('.getCurrentStepName').text());
  }

 

The other one that I commonly use is associated with a notes table that I use on most forms.  The table includes three fields, the date, the user's name, and a notes field.  This is used by staff to add notes as forms move through the process, but I also automatically add notes when they complete a form task.  We find this works better for our needs than the standard comments box or referring back to the instance history.  The trick is the part about automatically adding the note.  This is handled by watching for the action buttons to be clicked.  After they are clicked, it forces the validation and if the validation succeeded, it will add a new note to the table with the name of the task (same custom html element used for the title) and the action taken (the title of the button).  The code looks like this: 

  //add a note regarding form routing when the Submit button is clicked.
  $(".action-btn.Submit").on('click', function() {
    var noErrors = true; 
    $('#form1').parsley().validate();
    $('.parsley-error').each(function() {
      noErrors = false; 
    });
    if (noErrors) { 
      //update the notes with the current action
      $('.notesTable .cf-table-add-row').trigger('click');
      $('.notesTable tr:last').find('.notesNotes textarea').val("Task: " + $('.getCurrentStepName').text() + "\nFunction: " + $('.Submit').val());
    } //end of if (noErrors) { 
  }); //end of $(".action-btn.Submit").on('click', function() {

 

I have versions of that code for the different buttons: Submit, Approve, and Reject.

These are the kinds of things that I want to replicate with the Layout Designer and cannot current do it.

7 0
replied on July 17

I have a couple that I've found workarounds for, but would be great to have:

  • Ability to re-try lookup rules
  • Ability to interact with HTML buttons/elements. For example, if I click on a custom button, be able to tie it to an onclick event and trigger a function.
  • Redirect to another website on approver action (approve/reject)
  • Set Comments field to required on rejection
  • Ability to display some sort of alert confirming whether the approver wants to reject the form.
1 0
replied on July 17 Show version history

FYI - this one:

Ability to interact with HTML buttons/elements. For example, if I click on a custom button, be able to tie it to an onclick event and trigger a function.

has been available in LFCloud since October 2023 and self-hosted since Forms 11 Update 5 (December 2023).

A user group from last week that I presented at included an example of this.  You can view the recording from that user group in Aspire (link) - I believe it's about at the 1 hour mark on the video if you want to jump specifically to it.

1 0
replied on July 17

Ah I thought so thanks!

0 0
replied on July 17, 2023

We use this code in many of our forms. This will ignore all required fields if the "Reject" action button is clicked (our end users didn't want to have to complete the fields if they were rejecting the form).

$(document).ready(function() {
  //When the user clicks the reject button, required fields are ignored.
  $(".action-btn.Reject").on('click', function() {    
    $("*[required]").each(function() { 
      $(this).removeClass('required');
      $(this).removeAttr('required');
    }); //end of $("*[required]").each(function() {  
  }); //end of $(".action-btn.Reject").on('click', function() { 
 }); /* end of $(document).ready */

 

6 0
replied on July 17, 2023

Oh!  I didn't list this in my original post - but I do this too.

The part of my original post that mentions doing notes via Javascript - I often add this kind of functionality as well when rejecting a form is allowed without required fields.

2 0
replied on June 20, 2023 Show version history

Another thing we've included in every form that isn't needed now but could potentially be needed again in the future is a browser check. This code snip checks to see if the user has launched the form in IE. If they have, they are redirected to a form that displays an HTML box that directs them to use another browser.

This code was written by @████████

/*Added code to detect if user is opening from IE.  If so, redirect to Incompatible Browser form*/
var isIE = document.documentMode;


if (isIE) {
  window.location.replace("https://our.formsportal.com/Forms/incompatible_browser");
};

 

incompatible_browser.png
4 0
replied on June 20, 2023 Show version history

We use "autogrow" in many of our forms. This expands a multi-line text field to fit the text entered. We have not found this same functionality in the Modern Designer.

This code was written by @████████


$(document).ready(function () {
  
  /*******************************************************************************/
  /*           START: Enlarging textareas so that all the text displays          */
  /*******************************************************************************/  
  
  /* when isInAutoGrow = true then the change event was form triggered not user triggered  */
  var isInAutoGrow = true;
  
  function setUpAutoGrow(){
    $('.autogrow textarea').on('input lookup change keyup focus', function () {
      this.style.height = 'auto';
      this.style.height =
        (this.scrollHeight) + 'px';
    });
  };
  
  function triggerTextareaChange(){
    isInAutoGrow = true;
    $('.autogrow textarea').change();
    isInAutoGrow = false;;
  };
  
  /* on load */   
  setUpAutoGrow();    
  
  /* when a row is added to a table or collection */ 
  $('.cf-table-add-row, .cf-collection-append ').on('click', function() {
    setUpAutoGrow();    
  });
  
  /* The code does not work on fields currently not visable                                 */
  /* Therfore in order to make sure that fields in next pages show properly, when the click */
  /* event is triggered for either the next button, previous button or a tab then trigger   */
  /* the change event on the textarea fields                                                */
  
  /* next button clicked */
  $(document).on('click','.cf-next-btn ',function(){ 
    triggerTextareaChange();
  }); 
  
  /* previous button clicked */
  $(document).on('click','.cf-prev-btn ',function(){ 
    triggerTextareaChange();
  });   
  
  /* a tab was clicked */
  $(document).on('click','.cf-pagination-tabs li',function(){ 
    triggerTextareaChange();
  }); 
  
  /* on load needed when they save to draft and then open the draft */ 
  triggerTextareaChange();
  
  /*******************************************************************************/
  /*            END: Enlarging textareas so that all the text displays           */
  /*******************************************************************************/
  
}); /* END: $(document).ready */

 

8 0
replied on March 28

Yes please!  Modern designer is gradually growing to the point where we can truly begin transitioning most of our Forms to it.  This functionality would definitely help move us further in that direction.

1 0
replied on March 29

@████████'s post had me reviewing the above code and there is one part missing. There is some CSS that goes with it. 

 

/* for autogrow */
textarea {
  display: block;
  overflow: hidden;
  resize: none;
  min-height: 26px;
};

 

1 0
replied on June 16, 2023

Just tagging you on this one @████████ and @████████

 

 

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

Sign in to reply to this post.