Hi!Does anybody know how can I manage to run a dataport inside a codeunit without having to fill the form?For example,if I want to use a specific dataport inside a LOOP statement?
You need to call the dataport without request form (second param in DATAPORT.RUNMODAL) and add some function into dataport, which will set the FileName to apropriate value...
You need something like this in OnPreDataport trigger:
I do not know stupid questions, I know only stupid answers... :-)
Of course you can pass values in same way as into report etc. Define the dataport as variable, create some function in the dataport, call this function from the CU and pass the value, then call RUNMODAL on this dataport variable.
Or there is another way: define it as variable, this variable has property FILENAME - set it for the file name. Then run the dataport (DataPortVar is var of type Dataport and subtype your dataport you want to run):
Hi again!
When I try the first way I get the message:"Dataport 0 does not exist".
When I try the second way I have to fill the form.
Do you have any idea what can I possibly be doing wrong???
Comments
You need something like this in OnPreDataport trigger:
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
(If this question is too stupid,SORRY I am a beginner!!!
Of course you can pass values in same way as into report etc. Define the dataport as variable, create some function in the dataport, call this function from the CU and pass the value, then call RUNMODAL on this dataport variable.
Or there is another way: define it as variable, this variable has property FILENAME - set it for the file name. Then run the dataport (DataPortVar is var of type Dataport and subtype your dataport you want to run):
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
When I try the first way I get the message:"Dataport 0 does not exist".
When I try the second way I have to fill the form.
Do you have any idea what can I possibly be doing wrong???
You didn't define which dataport you want to run... :-)
In second case, you need to disable Request Form (UseReqForm property on Dataport).
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.