Is there a way to change (using C/AL code) the LookupFormID for the Item table when doing a lookup on Item No. from the Item List report? I have a need to use one form under one condition, and another form under another condition.
Hmm - I’m not quite sure what you mean! But you can do some manual code on the OnLookup trigger on the field. Let’s pretend, that you on the User Setup table have a Boolian field “Limited Item List”. Item No. - OnLookUp if not UserSetup.get(USERID) then UserSetup.“Limited Item List” := TRUE; Item.“No.” := “Item No.”; // Ensures that the lookup will “be standing” on the current Item. if UserSetup.“Limited Item List” then OK := FORM.RUNMODAL(“Limited Item List”,Item) = LOOKUPOP else OK := FORM.RUNMODAL(“Limited Item List”,Item); if OK then “Item No.”.Validate(Item.“No.”) - Hope that can be used! //Henrik Helgesen -: KISS::Keep it Simple, Stupid :-
When you say that I could do some manual code on the Onlookup trigger on the field, in what object are you referring to?
Could be “Sales Line”, could be “Item Journal Line”, Could be… And that’s the problem - You will need to do that the places you (via properties) use the lookupid… //Henrik Helgesen -: KISS::Keep it Simple, Stupid :-
Henrik If the onlookup rules need to apply to all forms then its best to put the code in the table isn’t it?
When placing code in the OnLookup trigger, remember that you disable the default lookup. Therefore, if you are adding code to say SalesLine No. field, then your code must provide lookup for all Types.
Thanks all for the tips – all good!!
Unfortunately, we can’t use these techniques in my situation. In my specific example, running the Item List Report and selecting the lookup on Item.No, we need a different form to come up depending on the user. Adding a lookup to the Item.“No.” table/field isn’t kosher (ie. non-standard Navision)! Doing this would add a lookup everywhere in the system where an Item.“No.” is entered (ie. on the Item Card, Item List, etc!
Paul - I see your problem. Only way, is to have the most limited list as the default, and then do the hokey stuff to enable a “extended” version by code. Annother approach, thoug, could be the following: On the Item List form, create a function: HideColums; the function would have the following code: if not UserSetup.get(USERID) then UserSetup.“Limited Item List” := TRUE; if not UserSetup.“Limited Item List” then exit; CurrForm.“Description 2”.Visible(false); CurrForm.“Unit Cost”.Visible(false); … . The Function needs to be called from the following triggers: OnOpenForm OnAfterGetCurrentRecord - To keep hiding if the user selects View - Show Column. //Henrik Helgesen -: KISS::Keep it Simple, Stupid :-
Thanks Henrik, I thought of this as well, and have done this before. Unfortunately, my current requirement is much more. In addition to hiding/showing fields, I also require tabs and menu button items to be hidden/shown, differing field arrangements, and form size differences, depending on the user. In summary, I require a display of a smaller, more limited form of another form that contains fields, tabs, and buttons. Accomplishing this by hiding and showing fields, tabs, and overlapping buttons, makes for a very messy and confusing form in design mode to work with. However, this would appear to be my only solution, unless an OnLookUpFormID table trigger or C/AL command is added. Paul
I guess you do not want to have different form for different Users: You may have to set a type on each of the item no. which determines which should be seen by any of the users. Then on lookup a it may be possible to apply a view filter to the table so that only a set of the items is available to different categories of users. Adewale A. Abiola
You can use a pretty universal code that allows for a dynamic form no. as such: CASE YourOption OF A: MyFormNo := 0; B: MyFormNo := FORM::“Item List #25”; C: MyFormNo := FORM::“Item List #37”; ELSE MyFormNo := 0; END; FORM.RUNMODAL(MyForm,ItemRec); Just a thought… Alex
I would agree with AlexZ here: You say that it is dependent on the user ? So this means that you can add a field to the usersetup (UserItemLookupID : integer) then UserSetup.GET(USERID); FORM.RUNMODAL(UserSetup.UserItemLookupID[,rec][,field]); and if its a boolean get then case UserSetup.GET(USERID) of ->true : FORM.RUNMODAL(FormA[,rec][,field]); ->false : FORM.RUNMODAL(FormB[,rec][,field]); end;