Markedonly records and Filtergroup

smkolsoftsmkolsoft Member Posts: 53
Dear All

I am displaying some markedonly records in a Form.
I want to prevent user from clicking the ShowALL buton.
Strangely i found that Filtergroup is not working for Markedonly records.

Pls advce me how to tackle this problem.

Thanks

Comments

  • krikikriki Member, Moderator Posts: 9,110
    If you only need to show some records without that the user needs to change them, I would throw those records in a temptable and run the form with the temptable:
    Some example (recTheTable is a record on the real table ; tmpTheTable is a temptable):
    recTheTable.FINDSET;
    REPEAT
      IF Show the record THEN BEGIn
        tmpTheTable := recTheTable;
        tmpTheTable.INSERT(FALSE);
      END;
    UNTIL recTheTable.NEXT = 0;
    
    FORM.RUNMODAL(0,tmpTheTable);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • smkolsoftsmkolsoft Member Posts: 53
    Thanks kriki for your reply.
    But as you have already said that this is for viewing only.....
    We actually want user to edit the records also.

    Is there any solution for it ?


    Thanks
  • BeliasBelias Member Posts: 2,998
    after filling the temporary form (kriki method), the user can modify the records (which are temporary).
    You can create a function to flush your modified temptable to the real table. You can achieve this calling the function in the oncloseform (and/or under a button).
    the only thing you have to do is to deny the permission to insert records to the user (or modify only the records that actually exists in the db, ignoring the others)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,110
    Belias wrote:
    after filling the temporary form (kriki method), the user can modify the records (which are temporary).
    You can create a function to flush your modified temptable to the real table. You can achieve this calling the function in the oncloseform (and/or under a button).
    the only thing you have to do is to deny the permission to insert records to the user (or modify only the records that actually exists in the db, ignoring the others)
    This is the correct way. It takes some more programming, but if they may not see other records. Or you have to find a filter that can be used.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • KTA8KTA8 Member Posts: 397
    kriki wrote:
    If you only need to show some records without that the user needs to change them, I would throw those records in a temptable and run the form with the temptable:
    Some example (recTheTable is a record on the real table ; tmpTheTable is a temptable):
    recTheTable.FINDSET;
    REPEAT
      IF Show the record THEN BEGIn
        tmpTheTable := recTheTable;
        tmpTheTable.INSERT(FALSE);
      END;
    UNTIL recTheTable.NEXT = 0;
    
    FORM.RUNMODAL(0,tmpTheTable);
    

    I try this code but it doesn't work. First findset doesn't exists in records and if a comment that, the system displays an error that the first variable current exists
  • BeliasBelias Member Posts: 2,998
    are there records in recTheTable table?
    P.S.: recTheTable MUST NOT be temporary
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • helmhelm Member Posts: 46
    If FINDSET doesn't exist it's because your version of Navision is to old. Use FIND('-') instead
  • BeliasBelias Member Posts: 2,998
    helm wrote:
    If FINDSET doesn't exist it's because your version of Navision is to old. Use FIND('-') instead
    eheh...i didn't thought that way...he said he doesn't have records :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KTA8KTA8 Member Posts: 397
    Belias wrote:
    are there records in recTheTable table?
    P.S.: recTheTable MUST NOT be temporary

    Yes, it is a record over item table. I don't know how to create a temporary record.
  • KTA8KTA8 Member Posts: 397
    Now with FIND I can compile but the error continues, how can I create the temporary?
  • BeliasBelias Member Posts: 2,998
    global variables, focus your record variable, view, properties, temporary = yes

    P.S.: you should study before programming...(assuming that you're doing this for a customer and not for personal training)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KTA8KTA8 Member Posts: 397
    Belias wrote:
    global variables, focus your record variable, view, properties, temporary = yes

    P.S.: you should study before programming...(assuming that you're doing this for a customer and not for personal training)

    Until today I don't need to use this type of variable and if markonly doesn't have this problem I will continue.

    And runmodal too, I have a question about it, I guess that 0 means that the system opens the default form for the record, in my case Item. But I need to open other and I change the number to the ID form but the system creates another object continuously. I don't know where to place the code to avoid that.

    P.S.: It's for a customer. I didn't make an official Navision course, I don't need it for my job and I don't have time to do it. When I had a little time I try to learn something but nowadays the courses are e-learning mode. In that type of course I need a lot of time to learn something. I'm assuming that you're talking about specific Navision programming not general programming.
  • BeliasBelias Member Posts: 2,998
    yes, i mean Navision programming for sure...but take it easy...i only suggested you to study nav programming in order to avoid errors...for example if you forgot a "temporary" property you can do a really big damage...inserting real records and so on...anyway, back to topic:
    what do you mean with
    but the system creates another object continuously
    ?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KTA8KTA8 Member Posts: 397
    When i call runmodal the system inits another object and despite of that the system does again my code and calls again another object.

    It's like this: run object -> run code (runmodal) -> run new object (like first one) -> run code -> (again and again)...
    It's happens when I use runmodal with the ID of my form not with 0. With 0 works fine but opens form 31 not my form
  • BeliasBelias Member Posts: 2,998
    let's say your form is no. 55555: do you do this in the onopenform of the form 55555?
    recTheTable.FINDSET;
    REPEAT
      IF Show the record THEN BEGIn
        tmpTheTable := recTheTable;
        tmpTheTable.INSERT(FALSE);
      END;
    UNTIL recTheTable.NEXT = 0;
    
    FORM.RUNMODAL(55555,tmpTheTable);
    
    then, it's straightforward that your form will be called over and over...open -> runcode, rumodal -> open -> runcode.....

    the code written by kriki is supposed to NOT be used in the onopenform, but for example in a codeunit.
    In order to run this code in the onopenform you must be in version 5.00 (or 5.01, i don't remember), you'll find the property sourcetabletemporary for the form.
    Search mibuso for "sourcetabletemporary", you should find threads about how to use it... :wink:

    *EDIT: #-o you don't have FINDSET, you can't be in 5.0 :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KTA8KTA8 Member Posts: 397
    I read the problem was in a form, I always thinking in that way.

    Yes, I'm working with a 4 version, can't I use sourcetabletemporary?
  • krikikriki Member, Moderator Posts: 9,110
    KTA8 wrote:
    I read the problem was in a form, I always thinking in that way.

    Yes, I'm working with a 4 version, can't I use sourcetabletemporary?
    Nop, doesn't exist yet. Exists from 5.0.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • KTA8KTA8 Member Posts: 397
    Can I use another solution?
  • BeliasBelias Member Posts: 2,998
    I already wrote it before! Use the same code, but run it from somewhere else: a codeunit for example
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • reijermolenaarreijermolenaar Member Posts: 256
    The prevent your user to show all the records you can also put the filter back on in the OnAfterGetRecord trigger.
    Form - OnAfterGetRecord()
    MARKEDONLY(TRUE);
    
    Reijer Molenaar
    Object Manager
  • KTA8KTA8 Member Posts: 397
    Belias wrote:
    I already wrote it before! Use the same code, but run it from somewhere else: a codeunit for example
    I don't think so my customer likes using two objects for the same purpose but it is a solution
  • KTA8KTA8 Member Posts: 397
    The prevent your user to show all the records you can also put the filter back on in the OnAfterGetRecord trigger.
    Form - OnAfterGetRecord()
    MARKEDONLY(TRUE);
    
    I like it, easier and elegant
  • BeliasBelias Member Posts: 2,998
    KTA8 wrote:
    The prevent your user to show all the records you can also put the filter back on in the OnAfterGetRecord trigger.
    Form - OnAfterGetRecord()
    MARKEDONLY(TRUE);
    
    I like it, easier and elegant
    and self-killing if you are on SQL :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • reijermolenaarreijermolenaar Member Posts: 256
    I agree, it is much better to write some code in the OnFindRecord and OnNextRecord trigger.
    Form - OnFindRecord(Which : Text[1024]) : Boolean
    tmpTheTable := Rec;
    tmpTheTable.SETVIEW(GETVIEW);
    IF tmpTheTable.FIND(Which) THEN BEGIN
      Rec := tmpTheTable;
      EXIT(TRUE);
    END;
    
    Form - OnNextRecord(Steps : Integer) : Integer
    tmpTheTable := Rec;
    tmpTheTable.SETVIEW(GETVIEW);
    CurrentSteps := tmpTheTable.NEXT(Steps);
    IF CurrentSteps <> 0 THEN BEGIN
      Rec := tmpTheTable;
      EXIT(CurrentSteps);
    END;
    
    Reijer Molenaar
    Object Manager
  • paulvgpaulvg Member Posts: 3
    Just put markedonly (true) in the onaftergetcurrentrecord
Sign In or Register to comment.