RequestOptionsForm - using one field to set a filter...

jversusjjversusj Member Posts: 489
Hi all,

I am not a developer, so my license file does not allow me in to all areas of Navision. I do have access to the C/AL behind the RequestOptionsForm in reports/dataports.

I need to allow the user to pass some parameters through the request form to table filters that are being set in the code behind the dataitems.

I want the user to be able to choose an Item Category Code from the request form. Upon choosing the ICC, the form enables a lookup to the Product Group Codes. I have this functioning, but when I click the lookup on the PGC, it takes me to an unfiltered list of all PGC, not just those Product Groups for the Item Category Code previously selected.

In essence, i want this request form to work similarly to the way it does on the item card - define an ICC and then the PGC list is filtered to only those records related to that ICC.

I went through Code Coverage to see how the item card works, but it is using the Item record and some validation to get the job done. I cannot do that on this request form, because i am not working with an item record. So far, I have attempted to place SETFILTER logic in various triggers on the report form, and none seem to accomplish anything. I always end up with the unfiltered list of all Product Group Codes.

I was able to put in an OnValidate error if the the user picks an invalid PGC for the ICC they selected, but that is bulky and not user friendly.

Any ideas? Thanks in advance!!
kind of fell into this...

Comments

  • krikikriki Member, Moderator Posts: 9,118
    You need the lookup by programming:
    recPGC.RESET;
    recPGC.SETRANGE("Item Category Code",codICC); // "codICC" is the global used for the ICC
    recPGC."Item Category Code" := codICC;
    recPGC.Code := codPGC; // last 2 are for positioning on last used record
    IF FORM.RUNMODAL(0,recPGC) THEN BEGIn
      codPGC := recPGC.Code;
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • jversusjjversusj Member Posts: 489
    edited 2006-05-18
    kriki wrote:
    You need the lookup by programming:
    recPGC.RESET;
    recPGC.SETRANGE("Item Category Code",codICC); // "codICC" is the global used for the ICC
    recPGC."Item Category Code" := codICC;
    recPGC.Code := codPGC; // last 2 are for positioning on last used record
    IF FORM.RUNMODAL(0,recPGC) THEN BEGIn
      codPGC := recPGC.Code;
    END;
    

    thanks kriki! to, perhaps, further demonstrate my ignorance, what trigger would i want to put this code in? OnValidate of the ICC control on the request options form?

    as a side note, the C/side help offers nothing on the requestoptionsform. Are there any resources out there that discuss how to use the requestoptionsform (ie proper syntax, functions that are available besides EDITABLE)?
    kind of fell into this...
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I think he means putting it in the onlookup trigger of the control on the requestform.
  • jversusjjversusj Member Posts: 489
    thanks! i ended up putting the code into a function that is being called to update the request form when other controls are changed.
          "Product Group".RESET;
          "Product Group".SETRANGE("Item Category Code",InItemCat);
          "Product Group"."Item Category Code" := InItemCat;
          "Product Group".Code := InProductGroup;
          IF FORM.RUNMODAL(5731,"Product Group") = ACTION::LookupOK THEN BEGIN
             InProductGroup := "Product Group".Code;
          END;
    

    this gets the job done, although i had to do a bunch of extra work with other controls to get it in place and have it make sense to users.

    I guess i will attempt to redevelop when i get a chance, but this time put kriki's inspired code into the onlookup of the PGC control.

    edit: i relocated the code to the onlookup and found that i actually prefer the user experience when i had the code in a function. before, the Onaftervalidate of the ICC control would call the function, and the user would immediately be prompted to define the PGC without clicking a lookup arrow. when i move the code, the user simply has to click on the lookup arrow of the PGC control to make their selection. both work, but the first is more proactive in getting the users response.
    kind of fell into this...
Sign In or Register to comment.