Args between form and report

Hello! I am learning x++ and I do not know to use the class args. I have two dates in a form that do not take the data from any datasource, and want to use this dates in a report, in the method fech(), I want to make while select where… between these two dates. how simply can be done that?. Thanks.

One solution is this: In the calling object you state args.parm(strfmt('%1;%2',fromDate,tillDate)); And in the called object you state: if (element.args() && element.args().parm()) { fromDate = str2date(substr(element.args().parm(),1,strscan(element.args().parm(),';',1,255)),123); tillDate = str2date(substr(element.args().parm(),strscan(element.args().parm(),';',1,255) + 1, 255),123); } NB In this case I use semicolon as separator.

There is another solution I like more. You pass the caller into the report args.caller(element); (for example, if called from a form); You create 2 methods in the form: getToDate(), getFromDate() and simply return the dates in them like so: ToDate getToDate() { return FormControlToDate.dateValue(); } where FormControlToDate is the control in the form you select date to from. Then in the report you get the caller into a variable classdeclaration() Object callerForm; init() callerForm = element.args().caller(); and in the fetch method while select Table where Table.TransDate <= callerForm.getToDate() && Table.TransDate >= callerForm.getFromDate() but, of course, using this method you might also want to check if the caller is right and if the form has methods toDate and FromDate That’s just another option for you to consider.

the second form to do it I like more, in the end instead of using a method “get” had thought about using to container, but this idea is worth to me. Thanks Ivan Kashperuk!!

quote:

There is another solution I like more. You pass the caller into the report args.caller(element); (for example, if called from a form); You create 2 methods in the form: getToDate(), getFromDate() and simply return the dates in them like so: ToDate getToDate() { return FormControlToDate.dateValue(); } where FormControlToDate is the control in the form you select date to from. Then in the report you get the caller into a variable classdeclaration() Object callerForm; init() callerForm = element.args().caller(); and in the fetch method while select Table where Table.TransDate <= callerForm.getToDate() && Table.TransDate >= callerForm.getFromDate() but, of course, using this method you might also want to check if the caller is right and if the form has methods toDate and FromDate That’s just another option for you to consider.
Originally posted by kashperuk - 2005 Sep 15 : 14:03:34

Hello again! how do I pass the caller into the report? args.caller(element); (called from a form);??? I don´t get of the object the methods getToDate(), getFromDate() and nevertheless I have implemented them in the form. since I do in the select addition fields of several tables? in the from only lets to me put a table (select field1,field2,…from only tabla1) I feel to make so many questions but I have begun to learn x++, I am a little lost, the manual is very bad and near me there is nobody programs x++ Thanks to all those that help me of this forum!.

thanks, already I have fixed it partially.

Hi julmugal ! can u explain how u fix it…i am need of further explaination.

HI, julmungal Sorry, didn’t see your private messages. (haven’t used this before, so didn’t even know they came. :))

quote:

thanks, already I have fixed it partially

Partially? Do you have any futher questions? Will be glad to help Vanya

hello, I see much people motivated with axapta! Once with himself the methods get of form by means of menuitem (menuitembuttom) and caller() in report, I now have in method fetch of report is the following thing: public boolean fetch() { date datefrom,dateuntil; boolean ret; ; dateUntil=callerForm.passdates2(); dateFrom=callerForm.passdates1(); while select InventJournalTrans2 index keyIdx ORDER BY Transdate where InventJournalTrans2.TransDate >= dateFrom && InventJournalTrans2.TransDate <=dateUntil join InventDim2 where InventDim2.InventDimID==InventJournalTrans2.InventDimID //this join does not work to me,“incompatibility of types”: join Dimensions2 where Dimensions2.Dimensioncode==InventjournalTrans2.Dimension[2] this.send (InventJournalTrans2); return true; } things that I believe that the people must know whom they love to help to me: Inventjournaltrans.dimension: it is an Array of three dimensions of type string Dimensions.dimensioncode: it is an Array of three dimensions of type int so that: dimension.dimensioncode==1==index of 2 of Inventjournaltrans.dimension (dimension[2]) since there is a incompatiblidad of types that I do not know to solve I have thought the following thing: to make a method that gives back display in the table inventjournaltrans to obterner the field that desire of dimensions (vendAccount) from here and by means of something similar to menuitem of form to put it in report, although in this case I do not know since that becomes. Somebody gives an idea me of like doing that? thanks!

perhaps I have not explained well! dimension.dimensioncode: string with values 0,1,2 (only those). if dimension.dimensioncode==0 it corresponds with index 1 of invenjornartrans.dimension (dimension[1]). if dimension.dimensioncode==1 it corresponds with index 2 of invenjornartrans.dimension (dimension[2]). and so with the other… then invenjornartrans.dimension=dimension.dimensioncode; they are related but I do not know to do join. good single he was that. Greetings!.

Well, didn’t quite understand your problem, but will give it a shot: Dimensions.DimensionCode is a BaseEnum field, not a string, of EDT DimensionCode(BE - SysDimension) - it has 3 values - 0,1,2 Dimensions.Num is the field that actually stores the value of the dimension of one of the types depending on the value in the DimensionCode field. and InventJournalTrans.Dimension is a field of EDT Dimension - it is not specifically linked to the Dimensions table. But it is done through the EDT array elements. To see this you would look at the Dimension ExtendedDataType. It has 3 array elements, each linked to the dimensions Table with a different value of DimensionsCode. Don’t know if that’s what you were looking for. if not, let me know, will try to help.

if it is as well as you say, although in axapta values 0,1,2 of dimensions.dimensioncode do not appear thus to me but that it appears to me (activity, species, variety) although means the same (of there is my error). Then as you would relate the tables Inventjournaltrans and dimensions? How I make to send to send() of 1 report several datasources? Thanks Ivan, I feel it to have explained badly although I see that you know what I want to do.

well, relating these tables will be complicated, I guess. in a report, you would have to add 3 datasources of each type, specifying a different DimensionCode for each one. But that’s a really bad solution. If I wanted to output values from the Dimensions table according to the value of InventJournalTrans.Dimension, I would write display methods. For example, if I wanted to show the name of the Dimension instead of the code, I would write a display method that would return the name and would put it into the body along with the rest of the fields from InventJournalTrans. And besides this use, I don’t see a reason for linking these two tables

concluded topic [:O]. Thanks Ivan!

HI julmungal This is no small job for a beginner :slight_smile: Well… 1. In the form make 2 “parm” methodes, each returning one of the variables. 2. In your report declare a varible of you form. 3. In Init methode in your report assign varible from (2) = element.args().caller(); 4. Now you can get your values from the form in the form of : x = formvariable.parmmethode(); Hope it’s usefull Yours Wilco