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

Question

Question

Losing Variable Values at "Rejection"

asked on June 6, 2017

I have two forms, Initiator and Doc Control. The initiator can check a box if the record they are submitting needs to be HIPAA safeguarded. This information populates just fine when sent to Doc Control. The issue is when the form is rejected back to Initiator, the choice made originally disappears. Here's my info!

 

 

The initiator can check/uncheck at his/her leisure. If HIPAA is checked by initiator, that field will be "read only" for Doc Control, however, Doc Control can check the box if required.

When rejected back to Initiator, all values disappear.

Initiator code:

$(document).ready(function(){
  $('.tag').hide();

//HIPAA Safeguards change event handler
  $('.hipaa input').on('change', function(){
	var check1 = $('.hipaa input').prop('checked');
    if (check1 == true)
    { 
     $('.tag input').val("HIPAA");
    }
    else
    {
     $('.tag input').val("");
    }
  });

});  //close document.ready

Doc Control code:

$(document).ready(function(){
  $('.tag').hide();

//HIPAA Safeguards change event handler
  $('.hipaa input').on('change', function(){
	var check1 = $('.hipaa input').prop('checked');
    if (check1 == true)
    { 
      $('.tag input').val("HIPAA");
      $("#Field181-0").prop("disabled", true);
    }
    else
    {
      $('.tag input').val("");
    }
  });
  $(".hipaa input:checked").each(function(){  
    $(this).trigger('change');
  });

});  //close document.ready

The business process is pretty simple:

Any ideas?

0 0

Replies

replied on June 6, 2017

Figured it out! For the HIPAA field, I had set a value of Yes. Once I removed that value from both fields, the code worked perfectly!

replied on June 8, 2017

Thought this issue was fixed. It's not. Any assistance would be greatly appreciated!

0 0
replied on June 8, 2017 Show version history

My first thought is that after you set the value programmatically, you should trigger the change event for the field you altered to make sure it sticks.

$('.tag input').val("HIPAA").change();

My second thought is that I have had problems with read only fields not wanting to save values input programmatically. When working with read only fields I usually:

  • remove the read-only attribute
  • set the value
  • trigger the change event
  • set it back to read-only

 

Setting it to disabled instead of read-only on the Doc Control form might be causing issues, but I'm not 100% sure of that.

I use something like this to change the read-only state, with the first input being the element and the second input being a true/false.

function yourFunction(){
    //remove read-only
    setReadOnly($('your field'),false);
    
    //set value
    //trigger change event

    //make read-only again
    setReadOnly($('your field'),true);
}

function setReadOnly(e,x){
    if(x){
        // Set input element to read-only
        e.attr({'readonly': 'readonly', 'backend-readonly': 'True'});
    } else {
        // Remove readonly from input element
        e.removeAttr('readonly backend-readonly');
    }
}

If that doesn't make a difference, I would add a line of code to each form to pop up a JavaScript alert with the current value of the fields when the form loads and/or when the field's change event is triggered. That way you can narrow down where in the process the value is getting lost.

If the value is passed back to the initiator form correctly, it is possible something in the code is changing it back to default (in my experience the change events for form fields tend to fire right after the form first loads).

0 0
replied on June 13, 2017

Thanks for the feedback. Just got back from a few days vacation. For now, I removed the feature. If Doc Control needs that field changed, they'll have to reject back to initiator. However, now that you've provided some ideas, just might try them. Thanks. Will let you know how it goes.

0 0
replied on June 13, 2017 Show version history

I adjusted my code and added ".change()" and thought it worked! The experts tested and it didn't work. I'll read through you other suggestions.

0 0
replied on June 13, 2017

I ran a couple quick tests, and it looks like Forms will not store values for "disabled" fields. I posted some code in your other question that should give you a general idea of how to quickly re-enable the field right before the form submits, but that seems to be the root cause.

No matter what I tried, if the field was disabled upon submission, it would lose the data on the next form. I found this a bit strange because I haven't had that issue with "read-only" inputs, but I guess checkboxes and radio buttons present a new challenge.

0 0
replied on June 13, 2017

Thanks! Will give it a try!

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

Sign in to reply to this post.