Options

Using C/AL to extract page information

compwizardcompwizard Member Posts: 17
edited 2011-02-25 in NAV Three Tier
Hi Guys,

Just a quick question, I wish to use an action (controlled by the press of a button) to extract information from a page then run a file.

I wish to extract the contents of the <No.> field on a page and write this information to an external text file. Is this possible? Does anyone have an example chunk of C/AL code that might do the job? It doesn't have to be pretty

<Action71> - OnAction()

_____________________________________________________

CODE TO EXTRACT THE CONTENTS OF THE<NO.> FIELD

CODE TO RUN AN EXTERNAL EXECUTABLE

_____________________________________________________

Many thanks as always

Comments

  • Options
    kinekine Member Posts: 12,562
    Have you tried something already?
    Have you some experince in NAV development?

    If yes, I expect that you know how to work with variables/records/fields. If you want to run some external app, depends if you are using 2009 R2 or not. You can use the Automation for that or DotNet libraries.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    krikikriki Member, Moderator Posts: 9,090
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    compwizardcompwizard Member Posts: 17
    I have zero experience in C/AL but know many other languages so I under stand the principles, it's just knowing `where to go` within the classic client, it doesn't seem as intuitive as anything I've used before and there's only so many examples you can read when non of them I've found are appropriate to what I'm doing!

    Very simply:

    CLEAR(MyFile);
    MyFile.TEXTMODE(TRUE);
    MyFile.WRITEMODE(TRUE);
    MyFile.CREATE('c:\temp\nav.txt');
    MyFile.WRITE('testing 123');
    MyFile.CLOSE();

    This CODEUNIT is underneath a button on my Purchase Invoice Page which works fine, this example writes the text file which contains testing 123.

    Instead of testing 123, what would be the correct syntax to extract THIS field to the text file so it contains 1006 /or whatever number is in that field. I need to use this CODEUNIT throughout which must always output the number in the No. field.

    Life saver whoever can tell me, I'm stumped!
  • Options
    kinekine Member Posts: 12,562
    You cannot do it without passing the record or the value from page to the codeunit when calling the function/codeunit. It means, you cannot just trigger the codeunit, you need to run it over the record or call it from code with passing the appropriate values. Take it in this way:

    Page is a class, actual instance of the page is object, codeunit is another class, when calling it it is some instance of this class. You cannot read the value from the page withint the codeunit if the codeunit have no clue how to access the page, you can only push the values from page into the codeunit, you cannot pull them from within the codeunit...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    compwizardcompwizard Member Posts: 17
    That's fine but how would I run it over the record / know where to find it so the codeunit can then run and extract the value? I don't mind creating a CODEUNIT for each page (I'll only need a few pages, Purchase Invoices / Sales Orders and Posted Purchase Invoices) I'm trying to find out how to achieve it and the steps I need to take one by one. ](*,)
  • Options
    kinekine Member Posts: 12,562
    One thing, do not think about the page as you are used to (it seems for me). The page itself when calling your function, must decide which value you need. If you do not need anything else, just create function in the codeunit, with one parameter. You can call it from the Action trigger and pass the value you want from the page. Try to study some standard code under the actions to see, how they are working.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.