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

Question

Question

Is there a way to use java jquery script when saved to laserfiche?

asked on October 4, 2018

I Created a forms speacially to save the forms in Laserfiche and I added some jquery Scripting to handle the way the forms will look like when some fields are hide by the rule

$(document).ready(function() {
    $('#q100').addClass('classoption1').removeClass('classoption2');
    $('#q5').addClass('IToption').removeAttr('style');
    var MyVar = $('#q1 select option:selected').val();  
    
switch(MyVar)
          {
                       case 'New Employee': $('#q100').addClass('classoption2').removeClass('classoption1');break;
                       case 'Redeploy': $('#q100').addClass('classoption2').removeClass('classoption1');break;
                       case 'Return to Vendor': $('#q100').addClass('classoption2').removeClass('classoption1');break;
              		   case 'Device Upgrade': $('#q100').addClass('classoption1').removeClass('classoption2');break;              				
          }
    });

It works if I open the form in a web broswer, means if I pass by a user task in the BP workflow of forms, here the result in the web broswer

but if I send it to a save to laserfiche task I got this result in the laserfiche document view

 

is there a way to get the javascript working when do save to laserfiche, it looks like it works just in half part of the first line works but as soon they is faced to a cif or swith condition to do comparaison, the script do not work

0 0

Answer

SELECTED ANSWER
replied on October 5, 2018

It is tricky, but not impossible, to write JavaScript that interacts with field values (so like your select box on line 4) that works both during the submission process and the save/view process.The key thing to realize is that when the form is rendered for saving/viewing, all of the textual input elements (selects, inputs, textareas, etc...) get replaced with div elements that just have html inner text. So you have to put a bunch of conditionals in your code... so that your line 4 would look something like this:

var MyVar
if($('#q1 select).length == 1)
{
  MyVar=$('#q1 select').val();
}
else
{
  MyVar=$('#q1 div.ro').text();
}

 

2 0
replied on October 11, 2018

Thank you I get your sugestion and use that code

 

but where did you get the info $('#q1 div.ro').text();

is there a way to know how to get it?

$(document).ready(function() {
  
  $('#q100').addClass('classoption1').removeClass('classoption2');
  $('#q5').addClass('IToption').removeAttr('style');
  
  var MyVar;
  
  if($('#q1 select').length == 1)
  {
  	MyVar=$('#q1 select').val();
  }
  else
  {
  	MyVar=$('#q1 div.ro').text();
  }
     
  switch(MyVar)
    {
        case 'New Employee': $('#q100').addClass('classoption2').removeClass('classoption1');break;
        case 'Redeploy': $('#q100').addClass('classoption2').removeClass('classoption1');break;
        case 'Return to Nova': $('#q5').removeClass('IToption').removeAttr('style');break;        
        case 'Reassign to New Employee': $('#q100').addClass('classoption2').removeClass('classoption1');break;
  	}  
});


 

0 0
replied on October 12, 2018

The easiest way is to go through the monitoring tools and look at a completed process. When you view the submitted copy of the form there, it will be in "read-only" mode. From there you can use your browser's developer tools to explore the DOM and figure these things out. It is also a good way to validate your javascript without having to submit a whole bunch of forms and check the results from a save-to-repository task. 

3 0
replied on October 15, 2018

Thank you Scott for this trick.

1 0
replied on April 30, 2021

For those that are unaware of how to access the form image of a save to repository task: In the process diagram save to repository task turn on Save XML with the form. Inside the XML will contain the link to the saved form. There might be a better way, but that's how I've done it.

Replies

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

Sign in to reply to this post.