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

Question

Question

Javascript not working in inbox approval process.

asked on August 11, 2015

I am using javascript to change the color of field values based on a field's input from a lookup. When the form gets to the approval process the color doesn't carry through. 

Javascript from starting form

$(document).ready(function () {
 $('.MyTable').on('change','.stipDate input', function() {
    if ($(this).val() != ''){
        $(this).closest("tr").addClass("RedBackground");
      $('.hours input').attr('readonly', true);
      $('.hours span.cf-required').remove();
            $('.hours input').removeClass('required').removeAttr('required');

      //alert('Please remove Red lines');
    }else{
        $(this).closest("tr").removeClass("RedBackground");
      $('.stipDate input').attr('readonly', true);
      $('.hours label').append('<span class="cf-required">*</span>');
            $('.hours input').attr('required', 'True');

    }
});

});

Javascript from 2nd form used in approval process:

$(document).ready(function () {
  $('MyTable').trigger('change', '.stipDate');
 $('.MyTable').on('change','.stipDate input', function() {
    if ($(this).val() != ''){
        $(this).closest("tr").addClass("RedBackground");
      $('.hours input').attr('readonly', true);
      $('.hours span.cf-required').remove();
            $('.hours input').removeClass('required').removeAttr('required');
    }else{
        $(this).closest("tr").removeClass("RedBackground");
      $('.stipDate input').attr('readonly', true);
      $('.hours label').append('<span class="cf-required">*</span>');
            $('.hours input').attr('required', 'True');

    }
});

});

what am I missing?

0 0

Answer

SELECTED ANSWER
replied on August 11, 2015

Use this JavaScript in your approval form

$(document).ready(function () {

 $(this).find('.stipDate input').each(function () {
    if ($(this).val() != ''){
        $(this).closest("tr").addClass("RedBackground");
      $('.hours input').attr('readonly', true);
      $('.hours span.cf-required').remove();
            $('.hours input').removeClass('required').removeAttr('required');
    }else{
        $(this).closest("tr").removeClass("RedBackground");
      $('.stipDate input').attr('readonly', true);
      $('.hours label').append('<span class="cf-required">*</span>');
            $('.hours input').attr('required', 'True');

    }
});

});

The idea is that the date is already filled in from the starting form so in the approval form, you would just be checking the existing values.

0 0
replied on August 11, 2015

Actually what I am running into now is the lookup on that form completes after the Javascript has already run. All of the fields are read only, but it is not marking the values red if the .stipDate field is empty. It marks them all red because they are all empty until the lookup completes. 

0 0
replied on August 11, 2015

To clarify, the submission form contains a table where users are inputting some values into fields to then do a lookup which returns the stipDate value? If a date is returned, then the entire row turns red?

And the approval form is based off of a copy of this form, but you want the row background color to remain?

0 0
replied on August 11, 2015

Here's a generic example process.

Lookup:

Submission Form Design:

Submission:

Approval Form Design:

Approval:

Does a basic process like that work for you?

0 0

Replies

replied on August 11, 2015

Perfect, thank you Alexander!

replied on August 12, 2015

Yes that works perfectly. I am able to adjust it and use it throughout the process. Thank you!

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

Sign in to reply to this post.