Request Form Global Variable

infonote
Member Posts: 233
Hi,
How can I assign a global variable to a request form so I can then use the value in the variable in a setfilter?
In the request form of a report, I have added a textbox in which the user enter a value.
The value is then used for filtering.
Thanks in advance,
How can I assign a global variable to a request form so I can then use the value in the variable in a setfilter?
In the request form of a report, I have added a textbox in which the user enter a value.
The value is then used for filtering.
Thanks in advance,
Blog: http://www.kaizenlog.com
0
Comments
-
make a global variable (MYGLOBALVAR). Then give your textbox (or other control from toolbox) the property [SourceExpr] -> MYGLOBALVAR.
In your DataItem in trigger DataItem - OnPreDataItem(), you can use your global variable as filtercriteria. For example:.... DataItem.setfilter(FieldToFilter,MYGLOBALVAR); ....
RegardsDo you make it right, it works too!0 -
It is simply straight forward
1) Declare a global var
2) Make it source expression of the textBox in request form.
3) Use this var to filter anywhere in the report.
RecVar.setrange(RecVarField,yourGlobalVariable); OR
...........setfilter....................................................OR
anyway you want the value in the global variable. It is available to report's all dataItems and corresponding triggers
I hope it helps. O:)Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Hi,
i have the same problem, but i'm a beginner, so can you explain this a little bit? I have a form and there you can select a date. when i print the record (the code to print this record is in the table in the PrintRecord trigger), i want to make a selection before i print that depends on this date. so do i have to declare a global variable in the table or in the form??? how can i access one of this variable from the other place?0 -
You call from the "Print" Button on your form (is this a form based on a table or with oout a SourceTable ?) the "PRINTRecord" function. Is this a self made function or the standardfunction for example in table 112). If it is your own, you can add a parameter. If it is the standardfunction, you can create a new one in the table with a parameter and set there your global Parameter.
But first: is this a form based on a table (f.ex. 112) or without a SourceTable ?
RegardsDo you make it right, it works too!0 -
my form is based on a table. Thats the reason why the code to print the report is in the PrintRecord-Trigger of the table...0
-
which table? Sales Invoice Header?
So, i think your source behind the Button looks like this (example use SalesInvHeader):CurrForm.SETSELECTIONFILTER(SalesInvHeader); SalesInvHeader.PrintRecords(TRUE); //or false
The Code in PrintRecords() looks like this (it's standard)WITH SalesInvHeader DO BEGIN COPY(Rec); FIND('-'); ...... ...... ReportSelection.SETFILTER("Report ID",'<>0'); ReportSelection.FIND('-'); REPEAT REPORT.RUNMODAL(ReportSelection."Report ID",ShowRequestForm,FALSE,SalesInvHeader); UNTIL ReportSelection.NEXT = 0; END;
So you see, there is a copy function on a new Instance of the (here) SalesInvHeader. These Copy() function copies also all filters of the current REC (where yout form is based). So if you set a filter before your PrintRecord() command likeSalesInvHeader.setrange("Posting Date",060108D); //or datevariable SalesInvHeader.PrintRecords(true); //or false SalesInvHeader.setrange("Posting Date");
The report will print the Recs with this "Posting Date". But if no rec exist with your posting Date, a error pops up in function PrintRecords() (find('-'))
Also you can create a new function in your table like SetPrintParameters(Parameters) and these parameters you use as a global Variable in the PrintRecords() function. But also here: If no recs exist, the find('-') brings an error://new function SetPrintParameters in table SetPrintParameters(Para1,Para2,Parax) GlobVar1 := Para1; GlobVar2 := Para2; GlobVarX := ParaX; .......... .......... //the modified PrintRecords function look now like this WITH SalesInvHeader DO BEGIN COPY(Rec); //new code +++++ setfilter(SomeField1,GlobalVar1); setfilter(SomeField2,GlobalVar2); //new code -------- FIND('-'); ...... ...... ReportSelection.SETFILTER("Report ID",'<>0'); ReportSelection.FIND('-'); REPEAT REPORT.RUNMODAL(ReportSelection."Report ID",ShowRequestForm,FALSE,SalesInvHeader); UNTIL ReportSelection.NEXT = 0; END; //The Code behind your Print Button ....... ....... SalesInvHeader.SetPrintParameters(Para1,Para2,Parax); SalesInvHeader.PrintRecords(TRUE);
For more help, it's helpfully to see a codesnippes or the for self (picture)
RegardsDo you make it right, it works too!0 -
Hey Grak,
that was the most helpful post i read. I did it with a new function on the table and used the global varaibles. So it works... Thank you.
Happy new year
Nico0 -
Please and happy new year (frohes neues jahr)Do you make it right, it works too!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions