PowerBuilder: Checkbox in DataWindow - checkbox

I have a checkbox in the DataWindow, It can be checked and unchecked. The default value in the db is 0. When it's checked, the db value is updated to 1 and on uncheck, the value is updated to 0 again.
However, I want to update the database only if it has value 0. If it is already 1, then I don't want the user to be able to change it back to 0. So please tell me how can I do that?
Here is the code from my DataWindow for the checkbox column:
column=(type=decimal(0) update=yes updatewhereclause=yes name=ok dbname="table.ok" values="1/0" )

You could protect the checkbox to prevent unchecking it : in the general / protect field of your checkbox :
if(ok = 1, 1, 0)
Once the checkbox has been checked, it becomes protected (you still have to update the data to the base).
On the next retrieve, you can see that the checkbox is already protected.
You might have to use a similar expression for the Pointer to show that the field is blocked, for example with the NoPointer! cursor.

try using:
if( upper(ok) = 'OFF', 1, 0)
or the other way around:
if(upper(ok) = 'ON', 1, 0)
depending on how you set the on/off values in the properties of the check box.
Note I'm using PowerBuilder 2017

Related

Oracle Apex checkbox

I have a page within my app with a Checkbox option.
The idea is basically to allow the user to select/unselect it if the change needs to be applied for every Sales Rep.
Something like this:
If checkbox is clicked = Change would be applied to all territories owned by the Rep
If checkbox is not clicked = Change would only be applied to the selected territory
I can't seem to get the checkbox clicked option to work.
I'm using an instr function to get a value out of it but it doesn't work:
select instr(':' ||:P11_CHECK_FOR_ALL|| ':', 'Request') into v_number_terr from dual;
if v_number_terr >0
(P11_CHECK_FOR_ALL is my checkbox Item / 'Request' is a word that's part of its label)
my checkbox pic
I'm trying to capture (in a process) whether the option is checked or not.
Could someone give me a hand please?
Thanks!
In apex a checkbox behaves just like a select list (with multiple selects possible). There is a display value and a return value. If nothing is selected, the page item value will be null. If one or more value are selected, the page item will contain a colon separated list of selected return values.
To handle the select list in a page process, the easiest is to split up the colon separated list in individual values using APEX_STRING.SPLIT
Example (untested):
DECLARE
l_check_for_all apex_t_varchar2;
BEGIN
l_check_for_all := apex_string.split(:P11_CHECK_FOR_ALL,':');
-- loop through the values. If nothing is selected then the COUNT will be 0 and nothing will be executed.
FOR i IN 1 .. l_check_for_all.COUNT LOOP
// do your pl/sql magic. You can reference the current item with l_check_for_all(i)
END LOOP;
END;

How to restrict Number Field default value set to '0' in extjs

I am using Extjs 3.4, I have a grid where I use editor function and form of NumberField type.
Here is my scenario, when the user starts editing a number field and immediately clears it and navigating to next page makes the field value set to '0' with dirty flag set which i dont want.
So, please help me out in having the control over the cell edited and also get the value i updated in the cells.
Thanks in advance,
RK
In ExtJs, when we defined a int field in the model.Its default value is taken as 0.We need to take help of useNull property in field with value as true:
{
name: <fieldName>,
type: 'int',
useNull: true
},

How to access to a Combo box value in Item Line on NetSuite?

In NETSUITE
is there any way to access to a value inside of a combo-box at the item line level?
I need to access to a value after inserting an item but all functions get me null value.
I have tried
nlapiGetCurrentLineItemValue
and
nlapiGetFieldValue
Both functions are getting me null values.
Thanks,
Pablo.
In general (for user event and client script) below code should work
nlapiGetLineItemValue(LINE_ITEM_TYPE, YOUR_FIELD_ID, LINE_NUMBER);
eg on SO to get the line item Id:
nlapiGetLineItemValue('item', 'item', 1);
PS: Syntax is independent of data type or field type
If you mean combo box as a mulitselect, and if you're trying to access via User Event Script, use:
nlapiGetLineItemValues(type, fldname, linenum);
Note the 's' in nlapiGetLineItemValues
If its just a standard field, nlapiGetLineItemValue(type, fldname, linenum) should work.
Which call to use depends on what event you are capturing.
For instance if you are trying to access the value in a post sourcing, field changed or line validate event of a client script you would use nlapiGetCurrentLineItemValue('item', 'fieldname');

Angularjs: default value when current option not in domain of select

I have cascading select where the value in the first decided what should be the option of others.
When I change the value of the first select so that the currently selected value in one other is no more a possible choice, I get a null (empty) choice. In place, I want to get a default, not null, value (of course, I don't want to reset to a default value is the choice is still legit).
I looked to (rather) similar question like Why does AngularJS include an empty option in select? but is does not seem to work, perhaps because my options are not predefined but generated on change.
I set-up a jsfiddle with the actual code: http://jsfiddle.net/sXu9a/
choose 2 hours or greater on the first select
chosse 1 in the second select (start hour)
choose back less than 1 hour in the first select
=> the second select display a empty option, and the "startHour" model still contains the last selected value (which is no more a valid choice). I really want to update the ng-model for that option to be reseted to 0.
In fact, I would like to be able to encode the condition: "if current model value for selected option is not in the set of possible value, reassign to model a default value (0)". So I tried a "onChange" like that:
$scope.onChangeInterval = function() {
if(jQuery.inArray($scope.agentSchedule.startHour, $scope.startHours() ) ) {
$scope.agentSchedule.startHour = $scope.startHours()[0];
}
}
But that does not seem to work.
Any idea about that ?
So, it happens that the "onChange" solution DOES work, as long as you don't make typos in the variable of your name. So with the following code (onChange is called on the first select):
$scope.onChangeInterval = function() {
if(jQuery.inArray($scope.agentSchedule.startHour, $scope.hours() ) ) {
$scope.agentSchedule.startHour = $scope.hours()[0];
}
}
Sorry for the noise!

Silverlight tri-state checkbox databinding to object property calculating value

So I have this little problem making this to work:
I have silverlight client app that has custom usercontrol with tri-state checkbox with two-way binding
After user changes checkbox value, function underlying the property translates the value to integer:
-1 nothing
0 false
1 true
After user saves data from dialog box, all data(complex object) is being serializes and sent over to webservice and stored in SQL db.
When client requests saved data back from webservice, it get back that object OK
When I try to bind that returned deserialized object(EA) back to checkbox like this:
With cC
Dim b As New Binding("AllowedTo.Create")
b.Source = EA
b.Mode = BindingMode.TwoWay
.SetBinding(CheckBox.IsCheckedProperty, b)
End With
it only works ok if the values are true or false, but if value is nothing, as the checkbox is tri-state, it should turn to that third state - undefined - with minus sign [-], but it dosent.
It just stays at false state - empty with no check, like it would be false.
What could be the problem?
Sorry for my english, its not my mother language
Don't use an integer for this, use a Nullable Bool (Bool?). Two way binding works well, it converts:
Checked == true
Unchecked == false
Indeterminate == null
Serialization isn't a problem with nullable bools, in fact you don't even have to check if the SQL field value is NULL, since it will be a valid state, and using a bool field in the SQL database will even reduce it's size a bit ;)
If your database is set, and you can't change it, write a converter to convert your integer to a nullable bool for the binding, shouldn't take more then 2 minutes.
Since such a technique is really native to the checkbox, I would recommend creating a custom control to handle the 3 different states for that boolean value.

Resources