Highlighted
Outstanding Contributor.
Outstanding Contributor.
348 views

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 

Labels (1)
0 Likes
8 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: TrueFalse checkbox/button cannot set attribute

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 );
}

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: TrueFalse checkbox/button cannot set attribute

Ok, I will try to change the value to True/False.
Btw, iManager set it as TRUE/FALSE.
Thx
Sylvain
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: TrueFalse checkbox/button cannot set attribute

Yes, this is really irritating. It's case sensitive and the case is diffrent when writing/reading etc.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: TrueFalse checkbox/button cannot set attribute

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

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: TrueFalse checkbox/button cannot set attribute

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.
0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: TrueFalse checkbox/button cannot set attribute

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() == "");
}

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: TrueFalse checkbox/button cannot set attribute

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

 

 

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: TrueFalse checkbox/button cannot set attribute

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

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.