Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to pass a record from codeunit to XMLPORT in NAV 2017

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I need to pass a record from codeunit which calls my XMLPORT.

In my codeunit, I am trying

XMLPORT.RUN (XMLPORTNO, TRUE, FALSE, recordToBePassed); //code runs without error and does call the XMLPORT

Now I don't know if the record is being passed to XMLPORT? if it is then how I can use it in XMLPORT?

Thanks,

*This post is locked for comments

  • Suggested answer
    Tina Menezes Profile Picture
    Tina Menezes 2,576 on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Hi,

    You can define a variable in C/AL globals in your XML port with Datatype 'Record' and select the record no. Now when the call comes to the XML port function from the codeunit, within the function assign the local parameter record variable of the function to the global record type variable defined in the XML port something like below:

    //In XML port 

    Declare global variable in XML port as below:

    Capture13.JPG

    XML port function declaration--say your record is table 3 Payment terms

    SETRECORDFUNCTION(LocalRecordParameter : Record "Payment Terms")
    GlobalRecordVariable:=LocalRecordParameter;

    Capture13.JPG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Thanks! Its working but now I have another question if you can please answer.

    This is the scenario.

    In an action on a page, I am calling a function in a codeunit which runs my XMLPORT. So my record is being passed from PAGE -> CODEUNIT -> XMLPORT.

    Code in my codeunit to call XMLPORT :

    XMLPORT.SETRECORDFUNCTION(RECORD);

    XMLPORT.RUN;

    Now on Request Page of my XMLPORT I want to show some information based the the passed record from codeunit. But the record only passed to XMLPORT after OnInitXMLport() trigger.

    So next trouble is how can I use passed record from codeunit in OnInitXMLport() trigger of my XMLPORT.

  • Verified answer
    GermanNavNETdev Profile Picture
    GermanNavNETdev 45 on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    3. In your XMLPORT create a global Record  and use THIS record as source property inside your xmlport.

    create an SetRecordXX(YourRecord - DataType Record) function inside your xmlport. Set inside the SetRecordXX function:

    Global Record Var:= YourRecord;

    -> now your xmlport knows the records

    4. no -> XMLPORT.RUN starts the process -> set all vars before .RUN

    Regards,

    Dominik Oswald

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Thanks for helping out! But still need more clarifications.

    Here is what I understood and the questions:

    1. Created a global function in my XMLPORT.
    2. Declared codeunit as global variable in XMLPORT.
    3. Called the function defined in the XML port passing the current record as a parameter
    //How can I call the the global function of XMLPORT from the codeunit
    //and how can I pass the current record to this function, in fact I want to pass record of a custom table
    4. Now if you have to do any further processing in your XML port you can write code for it in the newly defined function.
    //Would calling the function of XMLPORT will also run the XMLPORT or not?

    Thnaks,

  • Verified answer
    Tina Menezes Profile Picture
    Tina Menezes 2,576 on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Hi,

    You can create a function in your XML port with a parameter of the record and set the local function parameter to 'No'. Now declare the codeunit as a global variable and call the function defined in the XML port passing the current record as a parameter. Now if you have to do any further processing in your XML port you can write code for it in the newly defined function.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,749 on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Yes if you pass the record it will use those filter which you have applied on the codeunit and will use those on your xmlport to import/export.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    I have a codeunit where I have a recordset for Item Table. It is called grecItem. 

    This recordset has following data.

    No                      Description

    Item001              Milk

    Item002              Cookies

    Now I want to pass recordset greItem to XMLPORT from codeunit.

    In my codeunit, I have following line to call my XMLPORT.

    XMLPORT.RUN (50006, TRUE, FALSE, grecItem); 

    //Questions

    Is grecItem passed to XMLPORT(50006) or not?

    If it is then How can I use it in my XMLPORT?

    Note: XMLPORT is not based on item table, it just needs some information from greItem recrodset.

    Many Thanks!!

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,749 on at
    RE: How to pass a record from codeunit to XMLPORT in NAV 2017

    Sorry but your query is not clear to me, what are trying to achieve ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,861 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,540 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans