locked
Parameterized query works but doesn't return any values when params are set back to default RRS feed

  • Question


  • Hi, I'm editing this post to try to make my question clearer! I am using LS VS 2012 update 2.

    I have a screen based on a query which uses parameters to filter the screen. So, my screen will return a list of cities and at the top of the screen, I have a textbox which is bound to the filter parameter for the query. When I write, for example NYC on this textbox, the screen filters and it only displays entries for NYC but when I remove NYC, the screen doesn't display anything.

    I'd rather the screen displayed the original unfiltered list. Any idea where I have gone wrong here?


    • Edited by BigBee Sunday, April 13, 2014 10:22 AM
    Thursday, April 10, 2014 10:28 PM

Answers

  • I have solved it :)

    I have custom controls and discovered that it was my mistake! When my controls listened for changes, it still assigned an empty string to the control if the user clears the textbox by deleting/backspace away the text. 

    So I have added this check for empty string:

     city.change( function ()
        {
            if ( city.val() === '' )
                contentItem.value = undefined;
            else if ( contentItem.value != city.val() )
                contentItem.value = city.val();
        } );

     
    • Marked as answer by BigBee Friday, April 18, 2014 2:25 PM
    Friday, April 18, 2014 2:25 PM

All replies

  • I have profiled the query generated from Preprocess_Query and it turns out that when I remove the filter and query again, the generated query doesn't assign that parameter NULL as it was originally, it assigns it N'' instead and that's why it doesn't return anything because it's now filtering by empty string.

    @p__linq__0=N''

    The original parameter value which will work is:

    @p__linq__0=NULL
     

    I have tried to programatically set the filter value to NULL on the Preprocess_Query when parameter equals empty string but it didn't help.

    if (city != null)

    if (city.Equals(""))

    city = null;




    • Edited by BigBee Sunday, April 13, 2014 10:32 AM
    Sunday, April 13, 2014 10:31 AM
  • Hi BigBee,

    Perhaps you can make the parameter optional in your query? You can select the Is Optional checkbox for your City parameter property

    CT

    

    Tuesday, April 15, 2014 9:59 AM
  • Hi cte00,

    Thanks for your suggestion. Actually my parameters are optional already - sorry forgot to mention that on my question.

    Tuesday, April 15, 2014 7:53 PM
  • This is odd.

    From my experience, I have made a search screen with a textbox link to a string screen data item. Even if the user clears the textbox by deleting/backspace away the text, the string will "!= NULL".  

    To counter that, I have a clear button. This clear button will set all my search textboxes to "= NULL". Off-course the parameters are optional and the query is Auto Executed.

    Is there other things in your Preprocess_Query or elements in your query that could be giving your this problems? Perhaps a screenshot or copy of your Preprocess_Query. Also, is the screen query based off another query, and is that query causing this problem.

    HTH

     

    Wednesday, April 16, 2014 7:37 AM
  • I have solved it :)

    I have custom controls and discovered that it was my mistake! When my controls listened for changes, it still assigned an empty string to the control if the user clears the textbox by deleting/backspace away the text. 

    So I have added this check for empty string:

     city.change( function ()
        {
            if ( city.val() === '' )
                contentItem.value = undefined;
            else if ( contentItem.value != city.val() )
                contentItem.value = city.val();
        } );

     
    • Marked as answer by BigBee Friday, April 18, 2014 2:25 PM
    Friday, April 18, 2014 2:25 PM