cancel
Showing results for 
Search instead for 
Did you mean: 

Set Edit box value with null value

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

david_brandow
Contributor
0 Kudos

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?

Former Member
0 Kudos

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.

david_brandow
Contributor
0 Kudos

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.

Former Member
0 Kudos

This may work.  But "sup_allows_null attribute to true for the Choice control's select HTML element and then call setKeyValueNull or setControlValueNull" I don't see any option to set the sup_allows_null anywhere in the properties for the choice control.  Can you elaborate?  Thanks.

david_brandow
Contributor
0 Kudos

Its an attribute of the HTML element itself, you won't see it in the Designer. Try setting up an EditBox which allows null in the designer and look at the generated HTML for an example of what it is looking for.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

david_brandow
Contributor
0 Kudos

You need to add the sup_allows_null attribute to that HTML element, either directly in the HTML or dynamically/programmatically.

Former Member
0 Kudos

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

david_brandow
Contributor
0 Kudos

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.

Former Member
0 Kudos

  thanks David.  I've enclosed the key param in quotes already, that was just a typo above.  In regards to running the hybridapp.html in Chrome, it works up until when it connects through the MBO.  I'll keep chugging away,  I'm sure there's something minor that I am missing.  Thanks.

J