Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Xmlport to codeunit

Posted on by 265

Imagine this complicated scenario
I have an xmlport that receives through a webservice some variables. In this xmlport I want to pass the values ​​to a code unit where it will calculate some costs and based on it returns a minimum price. Where then I through xmlport return the values ​​to the same application that sent me the variables via webservice.
My SalesLine is temporary;

This is my code in xmlport

Integer - Export :: OnAfterGetRecord ()
...
SalesLine3.Quantity: = ivardec;
SalesLine3. "Container Code": = ItemContainerNO;
ltBusRel.SETRANGE ("Contact No.", ContactNo);
ltBusRel.SETRANGE ("Business Relation Code", "CLI");
IF ltBusRel.FINDFIRST THEN
 BEGIN
  ltCustomer.GET (ltBusRel. "No.");
 END;
SalesLine3. "Document Type": = SalesLine3. "Document Type" :: Order;
SalesLine3. "Sell-to Customer No": = ltCustomer. "No.";
SalesLine3. "Document No.": = 'TEMP';
SalesLine3. "No.": = ItemNo;
SalesLine3. "Location Code": = Location;
SalesLine3. "Line No.": = 1000;

- Here I call the codeunit lcPricingtool, with parameters that I get
lcPricingTool.GetPVmin (SalesLine3, CodT, ContactNo, CodPostal, CodPais, '');

--then the calculated values ​​in the CU should be passed to my variables PT where I return them


PT_CustoVasilhame: = FORMAT (SalesLine3. "Cost Container");
PT_CustoOpe: = FORMAT (SalesLine3. "Cost Operation");
CUSTOMER: = FORMAT (SalesLine3. "Supplier Cost");
PT_CustomCustomer: = FORMAT (SalesLine3. "Customer Cost");
PT_CustoStk: = FORMAT (SalesLine3. "Cost Stock");
PT_CostTransport: = FORMAT (SalesLine3. "Transport Cost");
PT_CostTransfer: = FORMAT (SalesLine3. "Transfer Cost");
PT_PMinimo: = FORMAT (SalesLine3. "PV Minimo");
PT_PAconfigured: = FORMAT (SalesLine3. "PV Advised");
PT_CustoUnit: = FORMAT (SalesLine3. "Unit Cost");

And here is the code unit and where CU fails

GetPVmin (VAR SalesLine: Record "Sales Line"; ShipAgent: Code [20]; Contact: Code [20]; ShipPostCode: Code [20]; Country: Code [10]; EndEnv: Code [20]): Decimal

SalesLine.SETFILTER (Type, '<> 0');

Container: = 0;
IF SalesLine.FINDSET THEN //<--It fails here with (Encomenda,TEMP,1000) 

BEGIN

IF (SalesLine. "Document Type" <> SalesLine. "Document Type" :: Order) THEN
   EXIT;
...


What am i doing wrong here? Any thoughts ? 

Thanks for the help!

*This post is locked for comments

  • Rikarddo Profile Picture
    Rikarddo 265 on at
    RE: Xmlport to codeunit

    Yes it is a temp Sales Line. With SalesLine.Insert; it worked

  • Rikarddo Profile Picture
    Rikarddo 265 on at
    RE: Xmlport to codeunit

    SalesLine3.INSERT; // was missing that!

    Thanks it worked!!

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Xmlport to codeunit

    What error are you getting ? The Sales Line you are passing to your codeunit is a temporary record ?

  • Verified answer
    RobertasR Profile Picture
    RobertasR 5,002 on at
    RE: Xmlport to codeunit

    Hi,

    before calling the function you have assigned values to SalesLine3 but did not insert it. So FINDSET (in the function) on this table will not see the line. Could that be the problem?

    Robertas

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans