Options

Opening a form with filters

khalilchahinkhalilchahin Member Posts: 25
edited 2014-08-07 in NAV Three Tier
Hello Group,

When the user tries to open the "Bank Rec.Worksheet" form she gets an error message :
Blocked must be No in Bank Account No.='bank no***'.

What code can I add to the open form trigger so when the user opens that form it will go directly to the first unblocked bank?

The user doesn't want to go back to the bank Card form and unblock that bank. they want the "Bank Rec.Worksheet" form to take them directly to the first available unblocked bank instead.

Any help on solving this is really appreciated?

Thanks in advanced.

Comments

  • Options
    khalilchahinkhalilchahin Member Posts: 25
    Hello Group,

    I need help please on the same question.
    what I am trying to do is to modify the form so that if it detects that the bank account is blocked then find the first Bank Account record which is not blocked and change to that record, so no error message is even displayed.

    Thanks for your help.

    Khalil
  • Options
    StLiStLi Member Posts: 83
    you replied to your own question :P

    anyway: i didn't analyze the specific form but there are generally three ways to reach your goal:

    1. you can open an existing form with pre-filtered data By instanciating a record of its source table first and then opening the form with the FORM.RUN function example:
    // Cust is Datatype Record 18
    Cust.reset;
    Cust.Setfilter(Name, '@*John*');  // this is removable by the Customer once the form is open
    Cust.filtergroup(2);
    Cust.Setrange(Blocked, Cust.Blocked::" "); // this is a filter the User can't remove 
    Cust.Filtergroup(0);
    FORM.RUN(FORM::"Customer List", Cust);
    
    This is usefull if you might encounter other situations where the Form is also used, but you need the unfiltered data there. (I prefer this one)

    2. You can filter the "Rec" in the OnOpen - Trigger of the form
    Setfilter(Name, '@*john*');
    filtergroup(2);
    SetrangE(Blocked, Blocked::" ");
    filtergroup(0);
    // a "findset/findfirst" might be necessary here
    

    3. you can just use the property "SourceTableView":
    SORTING(No.) WHERE(Blocked=CONST(" "),Name=FILTER(@*john*))

    if your filter is dependant on related Data, there is always the option of using the "mark" & "markedonly" functionality but that doesn't work with filtergroups.
    if Cust.findset then
      repeat
        if (strpos('JOHN', uppercase(Name)) > 0) AND (Blocked = Blocked::" ") then
          Cust.Mark(true);
      until cust.next = 0
    Cust.Markedonly(truE);
    
  • Options
    khalilchahinkhalilchahin Member Posts: 25
    Thanks very much for your reply. it was really helpful.

    solution number 3 worked for me.

    appreciate your help.

    Khalil
  • Options
    khalilchahinkhalilchahin Member Posts: 25
    Thanks very much for your reply. it was really helpful.

    solution number 3 worked for me.

    appreciate your help.

    Khalil
Sign In or Register to comment.