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

Question

Question

Field values not set after resuming from Save as draft option

asked on July 13, 2017

Hi All,

I'm having an issue where a form does not sets the values in the target fields after a user resumes a form task from a "Save as Draft" option.

Steps involved:

User selects a contract id from the lookup list of values and populates Delivery Partner IRB and ContractURL lookup fields.

I've used the below Javascripts to set the values for Radio button "Delivery Partner Is IRB "and Html field "Finalised Business Case" on change.

$(document).ready(function(){
    $('.proposallinklookup input').on('change',function(){
      
      $('.proposallink input').val($(this).val());
        var url = $(this).val();
        $('.proposallink input').trigger('change');
      
      var link = '<b>Finalised Business Case</b></p><p style="color:blue;"><a href="' + url +' "target="_blank">Click to open finalised Business Case</a>';

      document.getElementById('mylink').innerHTML = link;
      
    });
});

$(document).ready(function () {
  
  $('.lookupIRB input').change( function() {
  $('.radioIRB input').val([$('.lookupIRB input').val()]);
  $('.radioIRB input').change();
});
});

This works perfectly fine if a user submits forms without choosing the option "Save as Draft".

But when a user resumes a task after selecting "Save as Draft" option, form does not update the target fields.

Could someone please help me to resolve this?

Thanks in advance

0 0

Answer

SELECTED ANSWER
replied on July 13, 2017 Show version history

1. For radio button, actually there is another hidden input in radio button and your script changes that value, so the value is not correctly set. Use this instead:

$('.radioIRB input:visible').val([$('.lookupIRB input').val()]);

2. For changing HTML, since there is no change event on form load, you have to force it to show up. Try add this:

$(document).ready(function(){
  if ($('.proposallinklookup input').val())
  {
    var url = $('.proposallinklookup input').val();
    var link = '<b>Finalised Business Case</b></p><p style="color:blue;"><a href="' + url +' "target="_blank">Click to open finalised Business Case</a>';
    document.getElementById('mylink').innerHTML = link;
  }
});

 

0 0
replied on July 13, 2017

Thanks Rui for your help, it works.

0 0

Replies

You are not allowed to reply in this post.
replied on July 13, 2017

It might be that when you revisit the page during the "Draft" state, the onChange event does not trigger, so the radio button is not ticked or something.

For debugging purposes try removing the code below while in the "Draft" state and see if that brings the value back to the radio button.

  $('.lookupIRB input').change( function() {
  $('.radioIRB input').val([$('.lookupIRB input').val()]);
  $('.radioIRB input').change();
});

 

replied on July 13, 2017

Thanks Raul for your response.

I've tried removing the code but same result.

 

 

 

You are not allowed to follow up in this post.

Sign in to reply to this post.