TrueFalse checkbox/button cannot set attribute

Hello,

The attribute I want to read and set from a custom form is "isManager". This is a Boolean attribute that can be TRUE, FALSE or does not exist for a user object.

The version of IDM is 4.7.3 Advanced Edition.

If I set a pure "string" field with text it works fine, the form get the current value in the field and I can change it to FALSE or TRUE by typing the text.

But this is not convenient and I want to use a true/false radio button or checkbox.

The problem is that the true/false checkbox work only if there is no attribute defined:

1) If attribute "isManager" is not defined for the user , I can set it to "TRUE" 

2) if attribute "isManager" is TRUE or FALSE, the form display the current value, but no option available to change it (like if the attribute is read-only ?)

I tried changing the control from Boolean to String, or changing the value .toString() and no chance, it looks like a bug ?

Does anyone already tried that ?

Thanks a lot.

Sylvain 

  • Think that is because it expects true/false, not TRUE/FALSE.

     

    Found this old answer to when I had the same question ten years ago:

     

    Try something like this or try with reformatting to lowercase:


    try
    {
        var bool= (IDVault.get( null, employee ,"new_user","isManager");
        alert( bool);

        switch ( bool)
        {
            case "true":
            case true:
                 field.select( [ "true" ] );
                 break;
            default:
                 field.select( [ "false" ] );
                 break;
        }
    }
    catch ( e )
    {
        alert( e );
    }

  • Ok, I will try to change the value to True/False.
    Btw, iManager set it as TRUE/FALSE.
    Thx
    Sylvain
  • Yes, this is really irritating. It's case sensitive and the case is diffrent when writing/reading etc.

  • Hi,
    I did some tries and unfortunately, this doesn't help.
    I will make more test on a different environment and see how it works.

    Thanks

    Sylvain

  • Ok,
    I have not done this in recent editions do it might have changed but I suspect it is still the same.
    Hope it will work out for you.
  • I have created a library of functions (I put them in an inline global script) so once I figure out how to work around these wacky behaviors I have the solutions at my fingertips. The "field" parameter passes the current field object into the function, so you just pass "field" into it, and feed how you want to set it into "value" as a boolean.

    Another trick I use is that in the global form onload event I add these lines:

    • Form = form;
    • IDV = IDVault;

    So I don't need to pass those objects into each one of my global scripts

    Here's some code you can borrow...

    =========================

    function cbSet(field,value)
    //Applies to checkbox field to check / clear based on value.
    {

    if (undef(value))
    {
    value = false
    }
    else
    {
    value = value.toString().toLowerCase() == "true"
    }


    try
    {
    if (value)
    {
    Form.select(field.getName())
    }
    else
    {
    Form.select(field.getName(), [ "false" ] )
    }
    }
    catch (e)
    {}
    return value;
    }

    /* error checking - tests to see if a variable is undefined */
    function undef(v)
    {
    return (typeof(v) == "undefined") || (null == v) || (v.toString() == "");
    }

  • Hi,

    Thanks, looks interesting, but don't really understand how to use it.

    1) I Put these 2 lines 

    • Form = form;
    • IDV = IDVault;

    in a global onload event in my form 

    2) Add 2 inline scripts (undef & cbSet) in my form

    Could you please give a short sample how to use it in the field (Boolean, true/false check box).

    Thanks a lot.

    Sylvain

     

     

  • I trie that in the ONLOAD of the isManager field:

    var val = field.getValue()
    var newval= cbSet('isManager',val)

     

    But the form still return the checkbox "checked" when value is "FALSE" .

    Any idea ?

    Thx

    Sylvain