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

Question

Question

Fields are on the form when Submit is clicked, but don't show on the copy in the repository

asked on April 7, 2017

I have two fields on a form that are visible when Submit is clicked.  But when the form lands in the repository as a tiff the fields are not there.  I've attached a screen shot of the before and after.  The Marital Status field and Spouse field have disappeared once submitted.  

Could some type of javascript effect whether or not they appear on the saved tiff copy in the repository?

 

 

Before

 

After

1 0

Answer

SELECTED ANSWER
replied on April 11, 2017

By the way, if you use the "code" tags  it makes it a little easier to read and gives line numbers, etc.  But that's okay, I copied all the text into an editor (Notepad++) to work with it.

I'm going to tackle the martial status field - if this helps you resolve the issue, hopefully you can extrapolate the changes to the other field(s) that are giving you trouble.  There are only two bits of code that show or hide the marital status field.

1st on line 45 the field is hidden.  This line works with either the in-process version of the form or the read-only version of the form, and this line also runs regardless of anything else going on with the form (it's one of the opening lines of code and there is no evaluating criteria to prevent this code from executing) - so it never fails to hide the field.

2nd on line 129 the field is shown.  However two bits of code could prevent this from occurring:  

  1. The code between lines 92 and 141 is only run when an event is triggered, on line 91, the code is: 
    $(field.fafsaStatus).on("change", function() {
    
  2. The code between lines 128 and 133 is only run when a value equates as true, on line 127, the code is: 
    if (fafsa == "Independent Student") {

     

Neither of these two items are going to occur on the read-only version of the form.

The change event is not going to occur, because there is no user interaction to cause the event to occur.  The easiest way around this would be to trigger a change event when the form first loads, forcing it to always run at least once (this could probably go somewhere around line 47): 

$(field.fafsaStatus).trigger("change");

The if statement is not going to evaluate as true because in the read-only version of the form, the fafsa value that is supposed to be populated on line 92 will be populated with a null value: 

var fafsa = $(field.fafsaStatus).val();

The problem we have is the .val() part of command.  In the in-process version of the form, this works great, but in the read-only version, it won't work, there isn't a value to retrieve, in this case, we need to retrieve the text.

Let's try this.  After line 92, after we've populated the fafsa variale, let's add a new variable, I'm calling it altfafsa: 

var altfafsa = $(field.fafsaStatus).text();

Then, when you evaluate the contents of the fafsa field (on line 127 and several other places), we'll evaluate both values instead of just the one: 

if (fafsa == "Independent Student" || altfafsa == "Independent Student") {

Now it should evaluate as true, because either the fafsa variable or the altfafsa variable should return the expected value.

I haven't actually built out the form to test the code changes myself, but I've dealt with this kind of problem myself several times, so I'm pretty sure this will do it.

2 0

Replies

replied on April 12, 2017

I admit, I don't know for certain why the programmers have set it up that way.  My best guess is that the read-only version has a different look and feel, so when you are viewing the history view of a completed form or a copy archived to the repository, that it is cleaner and simplier and doesn't give the user the impression that it is an in-process functionality.

That being said, I really wish that at the very least, any javascript functionality (like the val() command) that worked in the in-process version would also work in the read-only version, it would save a lot of headache.  At this point, I've learned to work around it, but it is annoying in the respect that it adds an extra layer of testing that a form developer has to complete with any new process.

1 0
replied on April 12, 2017

I tried your approach and could not get it to work for me.  But in the process discovered something that seemed to work better in this situation.  In the document ready I used an alert to show the value of the fafsa status text().  If the form was the 'live' version then the text was both options concatenated together, "Independent StudentDependent Student".  If it was the 'read-only version then the text was what ever choice was chosen, either "Independent Student" or "Dependent Student".  Knowing that I went back to the form design and assigned a class to all of the fields that I wanted to show when the form hit the repository.  At the top of the document ready function I just checked to see if the text of fafsa status equaled "Independent StudentDependent Student".  If it did not, meaning this was the repository-bound version, then I showed everything in that class and was happy.

I appreciate your help.  I'm confident that I couldn't have done this without it!

1 0
replied on April 12, 2017

You're very welcome.  Even if it was round-about, I'm glad you got there in the end. laugh

0 0
replied on April 7, 2017

To answer you question - can Javascript impact what shows in the archived copy - yes, of course.  

Is that the problem in your case?  We don't have enough information.

Are you using Field Rules, CSS, or Javascript to show or hide those fields anywhere in your process?  

Do you have multiple versions of your form used at different stages in your process?

0 0
replied on April 10, 2017

Matthew, thanks for the response.  There aren't any field rules associated with those fields.  There is javascript that hides or shows the fields depending on answers to questions, but when the form is submitted they are showing.  And this is the only version of the form.

 

Thanks...

0 0
replied on April 10, 2017

The Javascript could definitely be the problem.

The structure of forms are tweaked a little for the "read-only" versions inside Forms and for the version that is sent to the repository.

Try this - inside Forms locate a completed instance of your process (i.e. from the Monitor page) and open it up so that you can view the form.  View the submitted copy of the form.  See if it has the same issue.  If it does, then it likely means there is a bit of Javascript that is behaving differently between the in-process version of the form and the read-only version of the form.

0 0
replied on April 10, 2017

So how does one go about determining the bit of code that is behaving badly?  

0 0
replied on April 10, 2017 Show version history

The most common issue I see with processing vs. read-only forms not behaving the same has to do with input fields.  If you have code that is pulling in values from input fields (   $('.fieldCSSName input).val()   ) you'd have to make some tweaks to allow it to access the same data when it's in the read only version.  So if for example, you are showing those fields based on the value of another field, it's quite possible that it is failing because the code can't access the value you are trying to get.

Another trick I use is inserting an alert command in various places throughout the code (   alert('test');    ). This is most useful when you think the issue is related to sections of the code failing to run at all (like sections within if statements or loops).

It's also very useful to use the "Inspect Element" (or other similarly named functionality) of your web browser to review the elements of your form.  This is pretty useful when comparing a form that works in one situation but not in another (like what you're doing now) to see what is different.

If the end result is just hiding and showing fields, you may want to consider using Field Rules rather than Javascript.  Of course, if there is a lot more going on in your Javascript, this may not meet your needs.

Alternately, a lot of times when setting up Forms I actually set-up an alternate "Archival" version of the form that includes different Layout, Javascript, and CSS, and use that for the repository archival.  Ultimately, this depends on what you are trying to do.

Because the forms in process use the current version of the code and not archived revisions, you can edit the Javascript on your form and return to that same submitted copy over an over again to review the changes, without having to submit new forms each time.

I'd be happy to review your Javascript if it is not too long.

0 0
replied on April 11, 2017

I'm a bit confused as to what you are referring to as the 'read-only' version of the form.  Is this the tiff that is saved in the repository?

 

0 0
replied on April 11, 2017 Show version history

That's part of it, yes.

Forms has two different ways that it displays your forms.

Forms in processing are the forms you see when it is in live processing.  This is what you see when you preview a form from the designer or when you start a new form or you are working on a form task that is assigned to you.  These are forms that can be populated with data and react to user interaction based on the Field Rules, Lookup Rules, CSS, and Javascript that you have established.

Read only forms are the version of the forms that are used when you are viewing the history of a completed form from within the Forms system.  A user cannot change anything on this form, but it can still be adjusted by Field Rules, Lookup Rules, CSS, and Javascript that you have in place.  However, there is a caveat that some of the functionality is different in this view, which can impact how your functionality (particularly the Javascript) functions.   When you access a form that has been through at least one step (so you don't see this when you are starting the form from the "Start Process" page, because that's the first step) you can view the "Action History" on the right, and any previous submittals of the form are displayed and you can click to view it, and it will be displayed as a read-only version of the form.  Anywhere that you can view the history of the form (such as from the Reports, Monitor, or Completed sections of Forms) will display completed forms as read-only.   How you display them changes a little between sections (i.e. from "Monitor" it'll be a different view than the "Action History" used when accessing a form from "Completed").  Additionally, the version of the forms that are archived to the repository as TIFF or PDF are created from this read-only version.

When the copy archived to the repository doesn't appear the same as your "in process" form, that likely means that part of your Javascript is not working in your read-only version of the form.  Testing this can be hard from that archived copy however (you'd have to archive it over and over again, testing each change you make).  It's a lot easier to test the read-only version of the form from within Forms itself - it's faster to review changes, and allows you to continue using the browser functionality (like "Inspect Element" which you wouldn't have with the TIFF or PDF that is archived to the Repository).

I'll usually open two Forms windows.  One I'll keep on the designer (specifically the CSS & Javascript page) and the other I'll keep on the Completed History, Report, or Monitor page where I have a completed copy of the form I'm editing.  Each change I make on the designer, I'll test in the other window by opening the completed form and clicking the view of the previously submitted form.

Here's screenshots of how you can access the read-only version of a completed form from the Completed page:

0 0
replied on April 11, 2017

Once again, I'd be happy to review your Javascript if it is not very long.

0 0
replied on April 11, 2017

I opened an instance of a submitted form.  Upon further inspection (js humor...weak, I know) here is what the marital status element looks like before it is submitted and after it is submitted.  I noticed that the css display property has changed from list-item to none.  Obviously, that is the culprit as to why it is not showing up but I'm not sure  1)What is changing it.  2)How to prevent it from being changed.

 

 

 

0 0
replied on April 11, 2017 Show version history

I got the joke wink

You're right, that's definitely the issue.  I'm guessing you have some Javascript that should be showing the field (changing it from "display: none" to a different display setting), but is failing to do so in the read-only version.

You mentioned that you were using Javascript to show and hide the fields.  How are you doing that?

  • .hide() and .show()
  • .css('display','none')
  • .addClass('cssClassName')
  • etc.

 

Are you willing to share part (the part that hides/shows this field) or all of your Javascript?  Ideally, I'd like to see any loops or evaluation criteria that occurs prior to, including, and just after the hide/show code.

0 0
replied on April 11, 2017

It is a bit long...but you asked for it.

 

//************************************
//*Field Equate Table
//************************************
field = {'loginLink'        : '#q16',
         'fafsaStatus'        : '#Field17',
         'signatureF'        : '#Field18',
         'signatureq'        : '#q18',
         'maritalStatusF'    : '#Field19',
         'maritalStatusq'     : '#q19',
         'instructions'     : '#Field66',
         'studentId'         : '#Field73',
         'parentNameF'       : '#Field77',
         'parentNameq'       : '#q77',
         'spouseNameF'       : '#Field83',
         'spouseNameq'       : '#q83',
         'parentEmail'        : '#Field84',
         'spouseEmail'      : '#Field85',
         'parAlsoMessg'     : '#q86',
         'spoAlsoMessg'     : '#Field87',
         'par3rdParty'      : '#Field88',
         'spo3rdParty'      : '#Field89',
         'proxyEmail'        : '#Field90',
         'relation'            : '#Field91',
         'spouseID'            : '#Field95',
         'proxyName'        : '#Field98'};
//************************************
//************************************


//********************************
// Global Document Ready Function
// Financial Resources Worksheet - Student
//********************************

$(document).ready(function() {
 
  //***Hide these fields to start

  $(field.spouseNameq).hide();
  $(field.parentNameq).hide();
  $(field.parAlsoMessg).hide();
  $(field.spoAlsoMessg).hide();
  $(field.par3rdParty).hide();
  $(field.spo3rdParty).hide();
  $(field.maritalStatusq).hide();
  $(".Submit").hide();

  var parName = document.getElementById("Field77").value;
  if (parName.trim() == "") {
      $(".shallNotPass").hide();
  }
  

  //***Remove all passed in paremeters from the address bar
  //***e.g. Token
  if ($('input[name=IsLocked]').val() == "False") {
    history.pushState({}, '', window.location.origin + window.location.pathname);
    
    //***Hide field but show on submitted form
    $('.hide').hide();
    
    //***Allow required field also be readonly
    //***To allow populated fields be required
    //***e.g. Name Lookup
    $('.readOnlyTextBox input').prop('readonly', true);
  }

  
  //*******************************************
  //***Call the schoolYears function to load the school years dropdown.
  schoolYears();
  //*******************************************


  //******************************************* 
  //***Show or hide "Click here to log in to MyOC"
  //***If there is a value in the ID field (Field73) then the user is already logged in and 
  //***the log in link can be hidden.
  $(field.studentId).on("change", function() { 
    if ($(field.studentId).val() === "") {
      $(field.loginLink).show();
    } else {
      $(field.loginLink).hide();
    }
  });
  //*******************************************


  //*******************************************
  //***The FAFSA status changed...
  $(field.fafsaStatus).on("change", function() {
    var fafsa = $(field.fafsaStatus).val();
    var parLength = document.getElementById("Field77").length;

    $(field.par3rdParty).hide();
    $(field.spo3rdParty).hide();
    $(".spouseStuff").hide();
    $(".shallNotPass").hide();

    if (fafsa == "Dependent Student") {
        $(field.maritalStatusF).val("");
        $(field.parentNameF).val("");
      //*If there are no parents then hide everything else and tell
      //*them that they need to set up third party access for their
      //*parent before they can complete this form.
      if (parLength <= 1) {
        $(".shallNotPass").hide();
        $(".Submit").hide();
        $(field.parentNameq).hide();
        $(field.spouseNameq).hide();
        $(field.parentEmail).hide();
        $(field.parAlsoMessg).hide();
        $(field.spoAlsoMessg).hide();
        $(field.par3rdParty).show();

      } else {   //There is at least one parent in the list
        $(field.spouseNameq).hide();
        $(field.parentNameq).show();
        $(field.parentNameF).show();
        $(field.parAlsoMessg).show();
        $(field.spoAlsoMessg).hide();
        $(".shallNotPass").hide();
        $(field.relation).val("Parent");
      }
    }  

    if (fafsa == "Independent Student") {
      $(field.parentName).val("");
      $(field.maritalStatusq).show();
      $(field.parentName).hide();
      $(".shallNotPass").hide();
      $(field.parAlsoMessg).hide();
      $(field.spoAlsoMessg).show();
    }


    if (fafsa === "") {
      $(".shallNotPass").hide();
      $(field.parAlsoMessg).hide();
      $(".Submit").hide();
    }
  });
  //*******************************************
  //*******************************************


  //*******************************************
  //*The parent name changed...
  $(field.parentNameF).on("change", function() {
    var parName = document.getElementById("Field77").value;
    var parLength = document.getElementById("Field77").length;

    //***When the parent name changes, select the matching email address.
    var proxPos = document.getElementById("Field77").options.selectedIndex;
    document.getElementById("Field84").selectedIndex = proxPos;
    document.getElementById("Field93").selectedIndex = proxPos;
    $(field.proxyID).val(document.getElementById("Field93").value);
    document.getElementById("Field84").readOnly = true;


    var parEmail = $(field.parentEmail).val();
    $(field.proxyEmail).val(parEmail);


    //*Hide spouse stuff that may be leftover from a previous selection
    $(field.spouseNameq).hide();
    $("#Field85").hide();
    $(".shallNotPass").hide();
    $(".Submit").hide();
    $(field.par3rdParty).hide();

    //*If there is a value in the Parent Name...
    if (parName.trim() !== "") {
      $(field.parAlsoMessg).show();
      $(".shallNotPass").show();
      $(".Submit").show();
      $(field.par3rdParty).hide();
      $(field.proxyName).val(parName);
    } else {
      //*No Parent Name...
      $(field.parAlsoMessg).hide();
      $(".shallNotPass").hide();
      $(".Submit").hide();
      $(field.proxyName).val(parName);
    }
  });

  //*******************************************
  //*******************************************

  //*******************************************
  //**The marital status changed...
  $(field.maritalStatusq).on("change", function() {
      var marStat = $(field.maritalStatusF).val();
    var fafsa = $(field.fafsaStatus).val();
    var x = $(field.spouseNameF).length;
    var spouseName = $(field.spouseNameF).val();

       if (marStat == "Married") {
      if ((spouseName.trim()) === "") {
        $(".shallNotPass").hide();
           $(field.spo3rdParty).show();
           $(".Submit").hide();
        $(field.proxyName).val(spouseName);
      } else {
        //*There is a spouse listed...
        $(field.spouseNameq).show();
        var spoEmail = $(field.spouseEmail).val();
        $(field.proxyEmail).val(spoEmail); 
        $(field.spoAlsoMessg).show();
        $(field.parAlsoMessg).hide();
        $(".shallNotPass").show();
        $(".Submit").show();
        $(field.relation).val("Spouse");
        $(field.proxyID).val($(field.spouseID).val());
        $(field.proxyName).val(spouseNameF);
      }
    } 

    if (marStat == "Single") {
      $(field.spouseNameq).hide();
      $(field.parAlsoMessg).hide();  
      $(".shallNotPass").show();
      $(".Submit").show();
      $(field.spoAlsoMessg).hide();
      $(field.relation).val("Single");
    }

    if (marStat === "") {
        $(field.parAlsoMessg).hide();  
        $(".shallNotPass").hide();
        $(".Submit").hide();
        $(field.spoAlsoMessg).hide();
    }
  });
  //*******************************************

  
 //*******************************************


  //*******************************************
  function schoolYears() {
    //currentDate = new Date($('.now input').val());
    currentDate = new Date();
    currentYear = currentDate.getFullYear();
    currentMonth = currentDate.getMonth();

    var target = $('.schoolYear select');
    target.find('option').remove();
    $('<option></option>').appendTo(target);

    var year = "";
    var twoDigitYear = "";

    if (currentMonth > 9) {
      year = currentYear + 1;
      twoDigitYear = year - 2000;
    } else {
      year = currentYear;
      twoDigitYear = year - 2000;
    }

    for (i = 0; i < 2; i++) {
      $('<option value="' + (twoDigitYear + i - 1) + "-" + (twoDigitYear + i) + '">' + (year + i - 1) + "-" + (year + i) + '</option>').appendTo(target);
    }
  }
  //*******************************************

  
}); //***End of ready function.
//*******************************************
//*******************************************

0 0
SELECTED ANSWER
replied on April 11, 2017

By the way, if you use the "code" tags  it makes it a little easier to read and gives line numbers, etc.  But that's okay, I copied all the text into an editor (Notepad++) to work with it.

I'm going to tackle the martial status field - if this helps you resolve the issue, hopefully you can extrapolate the changes to the other field(s) that are giving you trouble.  There are only two bits of code that show or hide the marital status field.

1st on line 45 the field is hidden.  This line works with either the in-process version of the form or the read-only version of the form, and this line also runs regardless of anything else going on with the form (it's one of the opening lines of code and there is no evaluating criteria to prevent this code from executing) - so it never fails to hide the field.

2nd on line 129 the field is shown.  However two bits of code could prevent this from occurring:  

  1. The code between lines 92 and 141 is only run when an event is triggered, on line 91, the code is: 
    $(field.fafsaStatus).on("change", function() {
    
  2. The code between lines 128 and 133 is only run when a value equates as true, on line 127, the code is: 
    if (fafsa == "Independent Student") {

     

Neither of these two items are going to occur on the read-only version of the form.

The change event is not going to occur, because there is no user interaction to cause the event to occur.  The easiest way around this would be to trigger a change event when the form first loads, forcing it to always run at least once (this could probably go somewhere around line 47): 

$(field.fafsaStatus).trigger("change");

The if statement is not going to evaluate as true because in the read-only version of the form, the fafsa value that is supposed to be populated on line 92 will be populated with a null value: 

var fafsa = $(field.fafsaStatus).val();

The problem we have is the .val() part of command.  In the in-process version of the form, this works great, but in the read-only version, it won't work, there isn't a value to retrieve, in this case, we need to retrieve the text.

Let's try this.  After line 92, after we've populated the fafsa variale, let's add a new variable, I'm calling it altfafsa: 

var altfafsa = $(field.fafsaStatus).text();

Then, when you evaluate the contents of the fafsa field (on line 127 and several other places), we'll evaluate both values instead of just the one: 

if (fafsa == "Independent Student" || altfafsa == "Independent Student") {

Now it should evaluate as true, because either the fafsa variable or the altfafsa variable should return the expected value.

I haven't actually built out the form to test the code changes myself, but I've dealt with this kind of problem myself several times, so I'm pretty sure this will do it.

2 0
replied on April 12, 2017

Thanks for the detailed response.  What time I've had to work on this today I haven't had success yet.  It does beg a question, though.  Why does a read-only version need to be created? 

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

Sign in to reply to this post.