Calling a Dataport with Filter.

Hi guys.

I am calling a data port which will export the data to the text file. The data port is based on item table.

file_to_export := ‘c:\text.txt’;
DataportObject.FILENAME(file_to_export);
DataportObject.RUN;

I want to put the filter to export the data for a particular item code. That the user selected. Like i put the button on item card form “EXPORT DATA” i will call this data port and pass the current item code number from item card from.

Create a function that sets the filters for you. Then do DataportObject.YourFilterFunction before running the dataport.

create a record variable for Item table. Apply filter on it. Then run the dataport like this.

Dataport.run(dataport number, record variable)

Thanks Matt for the reply. I have checked but still its not working fine.

Code for the function in Data Port.

Item.SETRANGE(“No.”,’%1’,var1);

Code in code unit.

val:=‘9789957086855’;
DataportObject.func1(val);
DataportObject.RUNMODAL();
MESSAGE(‘finish’);

But still it is exporting all the records can you please tell me where i am doing wrong. Thanks

BTW, this is not the syntax of SETRANGE

OnPush-trigger

CLEAR(ItemExp);
CurrForm.SETSELECTIONFILTER(Rec);
ItemExp.SETTABLEVIEW(Rec);
ItemExp.FILENAME('C:\test1.txt');
ItemExp.RUNMODAL;

Set use Request Form to No and Import to No in Dataport properties.

Thanks it is working with Item Form now.

What if i dont want to use rec i want to add a variable in global as ‘itemcode’

then user writes the item code in that field and then it will import. the form is not connected to any datasource.

Thanks it is working with Item Form now.

What if i dont want to use rec i want to add a variable in global as ‘itemcode’

then user writes the item code in that field and then it will import. the form is not connected to any datasource.