Issue in MULTIPLE FILTERS - WEB SERVICE

Ravi_ThakkarRavi_Thakkar Member Posts: 392
edited 2010-08-25 in NAV Three Tier
Hello All,

By using WEB SERVICE filter concept, I know how to filter data by applying filters one at a time. I tried same to apply multiple filters. But, unable to do.

Please, help me regarding.
Thanks in Adv.
Ravi_Thakkar
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
«1

Comments

  • kinekine Member Posts: 12,562
    You are passing array of filters to the webservice, what is the problem to fill more filters into this array? ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Thanks for the reply.
    I will go through it and will let you know.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello Kine,
    kine wrote:
    You are passing array of filters to the webservice, what is the problem to fill more filters into this array? ;-)
    I tried using array to provide multiple filters at a time.
    While binding the result of READMULTIPLE to GRIDVIEW control dataset, It will only allow to pass only one element of array as a parameter of READMULTIPLE method. Code is as follows.
    Sales_Order_Filter[] filter = new Sales_Order_Filter[2];
    filter[0].Field = Sales_Order_Fields.No;
    filter[0].Criteria = "<10000";
    filter[1].Field = Sales_Order_Fields.Sell_to_Customer_No;
    filter[1].Criteria = "<10000";
    GridView1.DataSource = WS.salesorder_serv.ReadMultiple(new Sales_Order_Filter[] { filter[0] }, null, 0);
    
    How to assign whole array in this service method?
    Can you help me in this??????

    Thanks in Adv.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • kinekine Member Posts: 12,562
    GridView1.DataSource = WS.salesorder_serv.ReadMultiple(filter);

    is not enough?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    For my purpose, I have used 42 PAGE Web Service.
    And then also, READMULTIPLE syntax is as in attachment. That is not allowing one parameter to this method.

    Please, suggest.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • kinekine Member Posts: 12,562
    Yes, because you need to pass the bookmark (or null if you do not have one yet) and max. count of record the webservice will return. You cannot do "unlimited" records, because it can overhelm the system...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello Kine,
    kine wrote:
    Yes, because you need to pass the bookmark (or null if you do not have one yet) and max. count of record the webservice will return. You cannot do "unlimited" records, because it can overhelm the system...
    Actually, In read multiple method, I should be able to pass Filter variable as a parameter instead of Filter[0]. but it is not allowing me Filter. Only allowing one element of array at a time.

    Please suggest.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • kinekine Member Posts: 12,562
    This is what work for me:
    NAV2009_Customer.Customer_Filter[] filters = {new NAV2009_Customer.Customer_Filter(),new NAV2009_Customer.Customer_Filter()};
    filters[0].Field = NAV2009_Customer.Customer_Fields.City;
    filters[0].Criteria = "P*";
    filters[1].Field = NAV2009_Customer.Customer_Fields.Name;
    filters[1].Criteria = "P*";
    customers = service.ReadMultiple(filters, "", 1000);
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello Kine,
    Thank you very much.
    kine wrote:
    This is what work for me:
    NAV2009_Customer.Customer_Filter[] filters = {new NAV2009_Customer.Customer_Filter(),new NAV2009_Customer.Customer_Filter()};
    filters[0].Field = NAV2009_Customer.Customer_Fields.City;
    filters[0].Criteria = "P*";
    filters[1].Field = NAV2009_Customer.Customer_Fields.Name;
    filters[1].Criteria = "P*";
    customers = service.ReadMultiple(filters, "", 1000);
    Your suggested code worked nicely for me also.
    Really a nice help. =D> =D> =D> =D>
    Thanks for your instant and kind support.
    I really appreciate.

    Thanks again.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • kinekine Member Posts: 12,562
    You are welcome... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Can we filter the records by using the field having Integer datatype?
    If yes then How?
    I tried for it,
    KeyList_Filter KLF = new KeyList_Filter();
    KLF.Field = KeyList_Fields.TableNo;
    KLF.Criteria = "36";
    GridView1.DataSource = KLS.ReadMultiple(new KeyList_Filter[] { KLF }, null, 100);
    
    Here, TableNo field is of Integer part. As a result it is not binding any data in Grid.
    If I am using "<36" (Records having TableNo less than 36) or ">36" (Records having TableNo greater than 36) then filter works correctly.
    So If I want all records having TableNo 36 then what to do?
    Please, suggest.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    did you try

    "=36"
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello Freddy,

    Yes, I have already tried for that. But of no use.
    Any suggestion?
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello All,
    Following is my code.
    ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter ApplicationApprovalEntries_Filter = new ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter();
                        ApplicationApprovalEntries_Filter.Field = ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Fields.Sequence_No;
                        ApplicationApprovalEntries_Filter.Criteria = "*";
                        gvApplicationApprovalEntries.DataSource = navref.ApplicationApprovalEntries_serv.ReadMultiple(new ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter[] { ApplicationApprovalEntries_Filter }, null, 0);
                        gvApplicationApprovalEntries.DataBind();
    

    As I discussed previously,

    I am getting this error in above code
    "You cannot enter '*' in Integer."

    That means it's not allow to insert this code
    ApplicationApprovalEntries_Filter.Criteria = "*";....
    
    So, please help me in above.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Can anybody help?
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    What is the intension of this filter:

    ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter ApplicationApprovalEntries_Filter = new ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter();
    ApplicationApprovalEntries_Filter.Field = ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Fields.Sequence_No;
    ApplicationApprovalEntries_Filter.Criteria = "*";
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Intension is to display all the Records with any SEQUENCE NO value.
    Here, SEQUENCE NO is the Integer type of field.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    Then remove the filter - no filter means take all.
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello Freddy,
    freddy.dk wrote:
    Then remove the filter - no filter means take all.
    I tried for
    navref.ApplicationApprovalEntries_serv.ReadMultiple(null, null, 0);
    
    instead of
    navref.ApplicationApprovalEntries_serv.ReadMultiple(new ApplicationApprovalEntries_ref.ApplicationApprovalEntries_Filter[] { ApplicationApprovalEntries_Filter }, null, 0);
    
    It is working fine. :):)
    Thanks a lot.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    How to apply DateFilters through Filter Criteria in .NET part?

    I have one field in Table "Date"

    From web user will enter "Satrting Date" and "Ending Date".
    I want to filter the "Date" field data in the Range of "Starting Date" and "Ending Date".

    How to do that?
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Oh I tried for
    StartingDate..EndingDate
    and it wored for me. :)
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Hello All,

    I am having problem with filtering of OPTION type field.
    I have one field "Type" having options " ,Open, Closed"
    Now, I want to filter data having "Type" value "".

    I tried using,
    Posted_Filter.Field = Posted_ref.Posted_Fields.Type;
    Posted_Filter.Criteria = "";
    gvPosted.DataSource = navref.Posted_serv.ReadMultiple(Posted_Filter, null, 0);
    gvPosted.DataBind();
    
    IN NAV it is filtering the data. But, on web not.

    What could be the solution?
    or may be I am wrong.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • derrickderrick Member Posts: 86
    Try " ", space in between double quote.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    I also tried for the same.
    But, not worked.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • derrickderrick Member Posts: 86
    Sorry, is "''", single quote within the double quote.

    Actually it supposes working by apply in Type._blank_.ToString(), Type.Open.ToString(), and Type.Closed.ToString() for your case, but it seems doesn't works for _blank_. Anyway, "''" will do for now.
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Thanks for the reply.
    I did try for it.
    But got the Exception as,

    "The filter ''' is invalid. An apostrophe (') is missing in the filter in the Payment Status field in the Purch. Inv. Header table."
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • derrickderrick Member Posts: 86
    edited 2009-09-29
    You missed out a single quote, more details,
    "''", 2 single quotes ('') within 1 double quote ("").
    => Like this, " ' ' ", trim the space, get it?
  • derrickderrick Member Posts: 86
    "''"
  • Ravi_ThakkarRavi_Thakkar Member Posts: 392
    Thanks a lot for reply.
    I also tried for it.
    Dint work.
    Ravi_Thakkar
    Ahmedabad, Gujarat, India
    E Mail : ravi.thakkar@hotmail.com
  • derrickderrick Member Posts: 86
    You're welcome.

    It works for me, you could probably narrow down your problem, put something like below without binding it to GridView,
    Posted_Filter.Field = Posted_ref.Posted_Fields.Type;
    Posted_Filter.Criteria = "''";
    
    //Declare a dynamic array 
    Posted[] posted;
    posted = navref.Posted_serv.ReadMultiple(Posted_Filter, null, 0);  //Make a break point here (F9)
    

    Check your VS "Locals" to see if the records of "posted" are what you intended. Hope this helps.
Sign In or Register to comment.