Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#787708
I tried this example in PM 3.0 but when I go to preview, the text box in my grid didn't change to disabled at all. So am I missing something or is this a bug?

Here's what I added to my form's javascript:
Code: Select all
$("#checkbox0000000001").setOnchange( function(newVal, oldVal) {  
    if (newVal = '"["1"]"') {
        $("#text0000000021").getControl().attr('disabled', true);
    } 
} );
checkbox0000000001 is the checkbox in my grid and text0000000021 is the textbox in the same grid.
#787766
Thank you. I am still curious if/when setOnChange is/was implemented. Because even when I try to make a textbox become disabled when a checkbox is checked and both are outside of the grid, it's still not working for me. But maybe my code is wrong too. Here is what I have to try to make a text box disabled when a checkbox is checked (again both are outside of any grids):
Code: Select all
function enableDisableText(newVal, oldVal) {
  if( newVal === '["1"]' ) {
        $("#storysource20").getControl().attr('disabled', true);
    } else {
        $("#storysource20").getControl().attr('disabled', false);  
    }
}
$('#checkboxVar001').setOnchange(enableDisableText);
This doesn't seem to work on my install (3.0)
#787776
Which version of PM are you using? PM 3.0.1.7 has a bug which prevents setOnchange() from working with checkboxes.

In PM 3.1 and later, you need to do this:
Code: Select all
function enableDisableText(newVal, oldVal) {
  if( newVal == "1" ) {
        $("#storysource20").getControl().attr('disabled', true);
    } else {
        $("#storysource20").getControl().attr('disabled', false); 
    }
}
$('#checkboxVar001').setOnchange(enableDisableText);
I just discovered this change. I will add code examples on the wiki.
#787943
Ok, you are brilliant and I'm an idiot.

testing your example helped me find the issue.

When yours worked and mind didn't, I knew something was interfering on my end.

I ended up realizing that I had added some javascript in a panel that was interfering with setOnChange so I removed it and now it works!

Thanks so much for your help and patience.

you rock!
#787961
How could this be modified so it will be set Onload and not setOnchange?
Code: Select all
function enableDisableText() {
  if( $('#storyapproved001').getValue() == '"1"' ) {
        $("#storysouce1").getControl().attr('disabled', true);
    } else {
        $("#storysouce1").getControl().attr('disabled', false);
    }
}
$('#storyapproved001').getValue(enableDisableText);
or something more like this?
Code: Select all
$('#storyapproved001').getValue(function () {
  if( $('#storyapproved001').getValue() == 1 ) {
        $("#storysouce1").getControl().attr('disabled', true);
    } else {
        $("#storysouce1").getControl().attr('disabled', false);
    }
} );
#788021
Thank you again.

Unfortunately, it's still not working.

I tested it on your sample dynaform too (attached) with no luck.
(2.52 KiB) Downloaded 193 times
I also tried using these to load it:
Code: Select all
$( window ).on( "load", enableDisableText );
$( "document" ).ready( enableDisableText );
$().ready( enableDisableText );
and just for fun these:
Code: Select all
$( "img" ).ready( enableDisableText )
$(document).on( "ready", enableDisableText )
I also tried changing this line:
Code: Select all
  if( $('#storyapproved001').getValue() == '"1"' ) {
with these alternatives:
Code: Select all
  if( $("#storyapproved001").getValue() == '["1"]' ) {
  if( $('#storyapproved001').getValue() == '"["1"]"' ) {
  and a few others
The strange part is that it works fine with the onchange but not on loading the form.
#788035
The problem is that getValue() returns '1' or '0', whereas setOnchange() sees the value as '"1"' or '"0"'.
If you use this code it will work:
Code: Select all
function enableDisableText() {
  if( $('#disableCountry').getValue() == '1' ) {
        $("#country").getControl().attr('disabled', true);
    } else {
        $("#country").getControl().attr('disabled', false);
    }
}
enableDisableText();  
I have documented all this craziness:
http://wiki.processmaker.com/3.1/Checkb ... checkboxes
#817929
nycmwr3 wrote:Is there any way this can be done using a php trigger instead of javascript before a dynaform loads ? I am trying to disable fields using a php trigger and I am not sure how to go about this . I couldn't find any examples on the processmaker wiki either.
Let's say that you want to enable a field whose ID is "selectCountry" if the "exportAbroad" checkbox is marked or disable it if it isn't marked.

Add the following trigger to your process:
Code: Select all
@@enableSelectCountry = "yes"; //enabled by default

//if exportAbroad is not marked, then disable the "selectCountry" field in the next form:
if (is_array(@=exportAbroad) and @=exportAbroad[0] == '0') {
    @@enableSelectCountry = "no";
}
Set this trigger to execute before the DynaForm.

In the DynaForm, add a hidden field associated with the "enableSelectCountry" variable.
Then, add the following JavaScript code to the DynaForm:
Code: Select all
$("#enableSelectCountry").getValue()  == "no") {
   $("#selectCountry").getControl().attr("disabled", true);
}
#817975
thank you very much for the example . The javascript in the above example is not loading. The dynaform just displays the spinning wheel when I load it.

Another question: How do I disable fields with triggers without having an enable disable checkbox ? For Example : When the first user fills in the selectCountry textbox with some value and sends it for approval to the second user , the selectCountry checkbox is automatically disabled when the second user loads the dynaform.
#817978
When you have an error in the JavaScript, press F12 in your web browser to open the browser's debugger and go to the "Console" tab to see the error.
I have created a sample process to show you how to disable a field in the second task. See the trigger executed before the form in the second task and the JavaScript code.
(35.66 KiB) Downloaded 112 times
I found that dropdowns in Firefox need to be disabled this way:
Code: Select all
$("#dropdownID").getControl().prop("disabled", true);
For some reason the attr() function doesn't work.

Maybe try increasing your thread stack size? Seems[…]

I use PM 3.4. Android push works while IOS push do[…]

[quote=ziadeh post_id=823031 time=1550759948 user_[…]

I have to support reports in processmaker 3.4. A s[…]