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

Question

Question

Javascript doesn't run on completed task forms.

asked on December 3, 2018

I have a process that dynamically inserts an iframe with a link into a custom html field to display a repository document needed for that process. Once the task is completed, everything on the form is read-only and the javascript doesn't run. Is there any way to allow a completed task to run some or even all of the javascript on a form after the task is completed?

0 0

Replies

replied on December 4, 2018

javascript is code executed in the client's browser. If you want to display the document in an iFrame, wouldnt you want to do that while the user has the task open, not after completing it.

Anything you want to do server side on submission, should be done in workflow.

0 0
replied on December 4, 2018

In this case, it's being used for Accounts Payable and some people or their supervisors like to look at the task after it's completed to check the actual invoice with what has been submitted. They like the idea of getting there from forms rather than going to weblink or any other client to look up the invoice that was already attached to the form at one point. When displaying the completed tasks, the javascript on the form is converted to read only and doesn't execute like it does if the task is active.

0 0
replied on December 4, 2018 Show version history

I am not very familiar with exactly how this works, but there is a method for running server side javascript immediately after submission. Put this inside your $(document).ready function

    //Code for modifying the repository archive
  if ($('[name=IsLocked]').val() == 'True'){
    
    //Enter code you want to run after submission here
    
    }

Since it is not running on the browser, you can't log to the console or test/see anything your doing so it is very difficult to work in this space.

I use a custom logging function which logs to the form itself, at the bottom, to experiment with this area. You can have it email you a PDF on submission, then check your log.

function Log(string){
  
  var customLog = document.createElement("div");
 
  customLog.innerHTML = string;
  
  var x = document.getElementsByClassName("cf-formwrap");

  x[0].appendChild(customLog);

}

 

Also, after submission, many things change. Fields change into different types etc, so you just have to blindly try things until you find something. It's like going through a conjugate space. Here is an example of finding an input fields value in this space.

$(document).ready(function() {
  
    //Code for modifying the repository archive
  if ($('[name=IsLocked]').val() == 'True'){
    
//Finding the value of my input field with class name "prod"
      var c1 = $(this).find('.prod div').first().text();
   
//Print the value out to the form image, the value is duplicated for some reason in this crazy space
     Log(c1);
  }
  
});


function Log(string){
  
  var customLog = document.createElement("div");
 
 customLog.innerHTML = string;
  
    var x = document.getElementsByClassName("cf-formwrap");

    x[0].appendChild(customLog);

}

 

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

Sign in to reply to this post.