Filtered list Link from report

BeliasBelias Member Posts: 2,998
edited 2010-11-15 in NAV Tips & Tricks
hi, i think this is not possible, but someone of you maybe found a workaround...
basically, i have to run something similar to a drilldown from a report of mine: i know how to run hyperlinks from a report, and i'm abusing it since i started to design reports for the 3 tier...the problem is that now, for the first time, i should run a page (the sales lines page), filtered for some fields.
as i said, i know to use recref with getposition in order to get the bookmark of the interested record, but here i have to show 3-4 records based on some filters...have you got an idea?

P.S.: i can use a singleinstance codeunit as a last resource: you know, set some parameters in the codeunit during the onprereport, check those parameters when running the page and filter the page consequently.
but here the problem is: when clear the parameters in order to make the user able to run the page normally?i guess i have to create a new page just for it...which is bad...

I hope i explained clearly, thanks in advance
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Have you played around with GETVIEW/SETVIEW ?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • BeliasBelias Member Posts: 2,998
    yes, it was my first try, but it doesn't work: and this does make sense, because the "bookmark" parameter refers to one record only, but the getview/setview doesn't change the "focus", but just sets filter...
    anyway, yesterday night i've got an idea...i'll post it here as soon as it works :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    BAM!Down in the basket!BAM!Down in the basket! (Peter Griffin)

    the workaround is easy and not so ugly: just create a report for the only purpose of running a page in the onpredataitem trigger. the report must be processingonly and the "usereqform" property must be false: here's a sample.
    OBJECT Report 77777 Page runner
    {
      OBJECT-PROPERTIES
      {
        Date=15/11/10;
        Time=10.01.37;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        UseReqForm=No;
        ProcessingOnly=Yes;
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table18;
            OnPreDataItem=BEGIN
                            IF GETFILTERS <> '' THEN BEGIN
                              PAGE.RUN(0,Customer);
                              CurrReport.QUIT;
                            END ELSE
                              CurrReport.BREAK;
                          END;
    
            OnAfterGetRecord=BEGIN
                               IF GETFILTERS = '' THEN
                                 CurrReport.BREAK;
                             END;
    
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      REQUESTPAGE
      {
        PROPERTIES
        {
        }
        CONTROLS
        {
        }
      }
      CODE
      {
    
        BEGIN
        END.
      }
      RDLDATA
      {
      }
    }
    
    

    from your RTC, you can then run this link, and append your favourite filters, for example (in my procedure i'll always add the %22 escape, just to be sure...
    dynamicsnav:////runreport?report=77777&filter=Customer.%22Name%22:A*
    
    the good thing is that you can use the same report to manage multiple page launching...just add your favourite dataitems and manage their execution with getfilters, for example...take a look to the sample for more info
    Cool huh? 8)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    I'm now thinking about a method to make the link creation less "bloody", and i thought about a function that gets 2 parameters: table name and filterstring.
    Ideally, i call this function like this
    myfunction(mytable.TABLENAME,mytable.GETFILTERS)
    
    but now i have to find a way to transform the filterstring from (for example)
    No.: A, Name: Anb*
    to
    &filter=Customer.%22No.%22:A&filter=Customer.%22Name%22:Anb*
    i know how to manipulate strings, but while i'm thinking about the routine, i'll post it here, in case someone wants to take the challenge :mrgreen:

    here's the function...

    FNTAppendFilter(pTXTTableName : Text[50];pTXTFilterValue : Text[1024])
    TXTFilters := '&filter=%22' + pTXTTableName + '%22.' + '%22';
    
    FOR i := 1 TO STRLEN(pTXTFilterValue) DO BEGIN
      CASE pTXTFilterValue[i] OF
        ',': BEGIN
          TXTFilters += DELCHR(lTXTValue,'<>',' ') + '&filter=%22' + pTXTTableName + '%22.' + '%22';
          lTXTValue := '';
        END;
        ':': BEGIN
          TXTFilters += DELCHR(lTXTValue,'<>',' ') + '%22' + FORMAT(pTXTFilterValue[i]);
          lTXTValue := '';
        END;
        ELSE BEGIN
          lTXTValue += FORMAT(pTXTFilterValue[i]);
        END;
      END;
    END;
    TXTFilters += DELCHR(lTXTValue,'<>',' '); //this is the last part, between the last ":" and the end of the string
    

    ATTENTION!!THIS CODE WORKS ONLY IF THE CAPTION OF THE FIELD IS THE SAME AS THE NAME OF THE FIELD. TO PARTIALLY SOLVE THE ISSUE, GO TO
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=44707
    (sorry for the cross posting)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.