Adding to the Dataport Request Form

Right, I’m trying to add a field to the Request Form on a dataport, but when I run the form, the Import/Export fields and Fieldname fields have dissappeared. I need the field for a filter value I can’t get through a DataItem. This is in 2.60, by the way.

That’s how it works, I’m afraid. You have to add those fields to the requestform manually. Search for “Dataport RequestForm” and you’ll see this issue has been covered abundantly.

Hi! To enter the Filename you could create a textbox with ID 1 (then you should receive the FileExplorer-Feature!), SourceExpression a TextVariable “VarFilename” and some code in OnAssist of this TextBox: CurrDataport.FILENAME := VarFilename; All other Controls have to be added manually … Regards, Jörg

Thanks Joerg - since posting someone told me about the ControlID 1 trick and luckily it was only for exporting so I could handle that with the Import property anyway.

Can’t believe you didn’t know that dude… Oh hang… I actually can believe you didn’t know that!! [:D] Aaah… Isn’t life just one big contradiction…

I can honestly say in 3.5 years of developing in C/AL I’ve never had to change the request form on a Dataport before! Didn’t I used to get you or Alex to do the dataports?

Hehe - Dataports?, Me? - No, I’ve got people to do those…[8D]

If you need to add the import/export radio buttons as well the Control ID must be 2.

Yes Kristian we were ‘clearly’ your bitches… You believe this as much as you like…

How does it work with the import/export radio buttons? Because when I put some radio buttons on the form and let that change the value of currdataport.Import := False, I still get the import file dialog.

I don’t quite understand - why do you put buttons on the form if you don’t intend to use them? - The dataport still needs a file name (for export).

You’re right, I didn’t make myself very clear. What I want is a dataport which is used to convert data from an old database into navision. I have to put some fields on the requestform to fill in some missing data. And I also want to use this dataport to import and to export the data, so i can modify the data in excel as well as in navision.

I’m sorry (I may be a bit dense), but could you clarify your problem? What you want to achieve seems rather straightforward. If it’s a problem with radiobuttons take a look at report 16 for instance - it’ll show you how they’re set up. In the OnPreDataport trigger you can control the import/export behaviour of the dataport with something like this: CurrDataport.IMPORT(MyOption=MyOption::Import);

Jan - I see what you mean now! - and I was a bit dense [:I][:I] You get the Import File Dialog even if the direction is set to Export. I don’t know if there’s a trick for this… it’s only of cosmetic importance, though, isn’t it?. I’ll fiddle a bit and see if I can find a solution…

The problem is that it doesn’t go through the OnPreDataport trigger. For example If the default is import and you change it to export, then you can change the value with CurrDataport.IMPORT := FALSE. But if you press on the assistbutton for the filename, then it still opens an import filedialog. code:----------- OnPreDataport=BEGIN IF Import = Import::Yes THEN CurrDataport.IMPORT := TRUE ELSE CurrDataport.IMPORT := FALSE; END; { 1 ;TextBox ;3630 ;2860 ;3410 ;440 ;AssistEdit=Ja; CaptionML=ENU=File Name; SourceExpr=VarFilename; OnAssistEdit=BEGIN CurrDataport.FILENAME := VarFilename; END;} { 1000000017;OptionButton;3630;3410;3740;440; CptionML=ENU=Import; SourceExpr=Import; OptionValue=Yes } { 1000000008;OptionButton;3630;3960;3740;440; CaptionML=ENU=Export; SourceExpr=Import; OptionValue=No } VAR Import : option : ‘Yes,No’; VarFilename : Text[250];

No, it’s not only cosmetic, because if you want to export to a new file, and it opens the importdialog then you get the message that it can’t find the file.

I don’t think it can be solved this way. A solution, though, would be to use CU 412 “Common Dialog Management”. In the OnAssistEdit trigger of the filename control put code like this (MyAction is set to 0 or 1 in accordance with the Direction Radiobuttons)- and remember the Control-ID should NOT be 1: OnAssistEdit() Filename := CommonDialog.OpenFile( // Window title 'Jan Jansen File Dialog', // Default file name '', // Default filetype 0, // Filter string '', // Action 0=Open (Import), 1=Save(Export) MyAction); CurrDataport.FILENAME := Filename;