Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Page Web Service

(0) ShareShare
ReportReport
Posted on by 615

Hello friends,

I try to write my first Page Web Service ,Now I am facing two issues ,

1)      How can Insert the value(Update) ?

2)      How can get Max value of Document_No?

My aim is insert General Journal Entry.I follow the link msdn.microsoft.com/.../dd355316.aspx

Web Service    :=    ObjectID =>20 =>GeneralJournalEntries=>WebPageService

C# CodeSnippet below

Gen_Ledger_Entry_Service    Service = new  Gen_Ledger_Entry_Service();

Service.UseDefaultCredentials = true;

Service.Url   =  “http://localhost:7047/DynamicsNAV/WS/Page/Gen_Ledger_Entry

Gen_Ledger_Entry  GenEN=new Gen_Ledger_Entry();

GenEN.Document_Type=0;

GenEN.Document_No =”4344”   and so on

how can mapp service with GenEN

*This post is locked for comments

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,116 on at
    RE: Page Web Service

    If you have set the correct permissions and use the service appropriately, security will not be a major concern. Handling a data using a page is easy comparing to handling it with a codeunit. (my own view point - might get differ for person to person.)

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Page Web Service

    hi,

    publishing a page as web service is no good idea because of security implications.

    another point is that you only get the functions that the page is delivering. in that case the page delivers no insert/update/delete functions, only a read function.

    better solution:

    write a codeunit with only the needed functions and then publish it as web service.

    .net part:

    -- NavProxy is the service reference, WSGenLedgEntry is the nav webservice

    NavProxy.WSGenLedgEntry client = new NavProxy.WSGenLedgEntry();

    client.UseDefaultCredentials = true;

    var count = client.Count();

    client.Insert(count + 1, DateTime.Today, "Start", 0, "Opening Ledger Entry", 1000);

    c/al part:

    Insert(entryNo : Integer;PostingDate : Date;DocNo : Code[20];DocType : Integer;Desc : Text;Amount : Decimal)

    glEntry.INIT;

    glEntry."Entry No." := entryNo;

    glEntry."Posting Date" := PostingDate;

    glEntry."Document Type" := DocType;

    glEntry."Document No." := DocNo;

    glEntry.Description := Desc;

    glEntry.Amount := Amount;

    glEntry.INSERT;

    Count() : Integer

    EXIT(glEntry.COUNT);

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,116 on at
    RE: Page Web Service

    You do not have to specify the Service URL in the code. If you have added Add Service Reference that will point it to your service.

    01. First add the service to your project.

    02 Create instance of service

    03 Create instance

    Within the scope of the created instance you can access the customer data. Do any modification or updates you like and pass the instance to service to update NAV.

    You are in the correct path. If you need i can provide you a sample code.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans