onozaty / redmine-view-customize-scripts

Code examples for "Redmine View Customize Plugin"
https://github.com/onozaty/redmine-view-customize
111 stars 26 forks source link

How I can receive a custom list field value before submit issue? #120

Closed jlsblasco closed 1 year ago

jlsblasco commented 1 year ago

Hi @onozaty

I have a problem that I don't know how to resolve. I need to send a alert when select a wrong option in a custom list field (number 139) Include video with the problem When I create a new issue and select a value of the list, the value received in the variable is blank. When I edit the issue the value receive its the value saved in the database. If I select other value of the list and submit the issue, the value received its the before value not the selected value.

For the tracker the value received its the selected not the saved before, but I don't know the procedure for take the selected value in a custom field list.

The code:

$(function() { $('#issue-form input[type="submit"]') .on('click', function(event) {

  const tipoPeticion = $('#issue_tracker_id').val();
  const medida = $('.cf_139 .value').text();
  alert('Tracker:   ' + tipoPeticion + '  Custom field Medida Plan Digitalizacion : ' +  medida);
}); // de function(event)

}); // de function()

Any help?

Thank you in advance for you support.

https://github.com/onozaty/redmine-view-customize-scripts/assets/50949839/7fe7bee0-7feb-4260-80ea-8033d6b70890

onozaty commented 1 year ago

With this code, it would be something that retrieves what is displayed on the Issue screen.

$('.cf_139 .value').text();

To get the current selection, you would need to write the following. The code to get the label of the select box.

$('#issue_custom_field_values_139 > option:selected').text();

The following is a reference.

Thanks.

jlsblasco commented 1 year ago

You are my hero. Thank you so much for salve my life one more time. Regards