on 08-08-2013 10:57 PM
Using SUP 2.2.
I have an MBO with a parameter defaulted value is <NULL>. So if this parameter is left alone, it would bring all the data back without any specific filter.
However, the parameter, as you might guess is coming from a drop down list which has static values. The MBO works well when the selected value from the list has a specific value. But I do have an option in the drop down with "All", which I need to some how set the drop down list with <NULL>. I've tried setting the field with empty quotation marks, with null and even <NULL>. But no data is returned. I am positive that the query does work and should have returned data, that I am very sure off.
So my question is, how can I set this drop down box with null value so that the MBO will work? Thanks.
Native app or hybrid app? If native, which platform(s)? If hybrid, have you added any custom code to deal with the null value scenario for select/choice/combobox controls?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David, thanks for the reply.
This is Hybrid. I have tried a few things.
1. The choice box is loaded with values from the "Static" options. So this one item, I've set the "Value" field to "<NULL>", even just "NULL". I'm not able to just leave it blank unfortunately.
2. When item one didn't work, In the customBeforeSubmit method I added a logic to manually set the the key of the choice box to empty string:
form.formkey_Outage_Status.value = "";
even tried
form.formkey_Outage_Status.value = null; <== which I don't think would work at all
Thanks again for the reply.
EditBox controls can be setup to automatically accept null values, Choice controls need custom code. Your custom code is dealing with the UI, but not with the data. I haven't tried this myself, but I believe that if you set the sup_allows_null attribute to true for the Choice control's select HTML element and then call setKeyValueNull or setControlValueNull where appropriate, that should map the UI to the data correctly for null values. You could also manipulate the data directly, of course.
ahhh...got it. okay I will give this a try. FYI, in the designer, I did set the value from the "Static" to just empty double "" and that seems to work. But the this particular option defaults as the first option in the choice box. And once you select another option, I can't select this option again. Interesting results. Thanks.
So that almost worked. Here's what I did:
1. edited hybridapp.html and in the select object, I added the sup_static_options="true"; looks something like this:
<select class="right" id="formkey_Outage_Status" sup_num_of_decimals="0" sup_html_type="text" sup_static_options="true">
NOTE: made sure that when generating the hybrid app to uncheck "Update generated code".
2. In the customBeforeSubmit, assuming you've determined the option that requires null value to be passed, syntax is this:
setControlValueNull(form.formkey_Outage_Status);
However, the message I got this time is "Key object found that does not allow null value"....something to that effect.
I'm wondering if the choice box allows the sup_static_option attribute.
Okay, here's what I got so far:
select element:
<select class="right" id="formkey_Outage_Status" sup_num_of_decimals="0" sup_html_type="text" sup_static_options="true" sup_allows_null="true">
<option value="CRTD">Created</option>
<option value="WKCP">Completed</option>
<option value="FRWD">Forwarded</option>
<option value="NOND">Non Dispatch</option>
<option value="ALL">All Statuses</option>
</select><span id="Start_formkey_Outage_Status_help" class="help"></span>
NOTE: I did also remove the sup_static_options like and I also did put sup_allows_null line in the option tag for "All Statuses" to make sure that I am not missing anything. However, I have the same result.
In the before submit function:
if(screenKey === "Start" && actionName === "Get_Outages_Count") {
var form = document.forms[screenKey + "Form"];
if( form ) {
if( form.formkey_Outage_Status.value === "ALL" ) {
setKeyValueNull(formkey_Outage_Status);
}
}//form
}//screenkey start and get outages count
which I know gets triggered with a quick showAlertDialog. I have tried but setKeyValueNull and setControlValueNull.
But interestingly, I get a "element id is not found" message.
I wonder if I'm still missing something. Thanks in advance for any input.
J
For the record, debugging in Chrome is going to get you further than coding blindly, posting your failure to the forum and hoping I can guess what went wrong.
I couldn't find anywhere in our code where we spit out an error message with that text.
setKeyValueNull takes in a string parameter. You appear to be passing in a non-existent variable reference, which will presumably evaluate to be undefined at runtime. Try surrounding it with quotes, that should work better.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.