Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

Posted on by Microsoft Employee

Hi, I am currently experimenting with NAV 2017 and Visual Studio and was wondering how to execute a codeunit web service built in NAV 2017 from Visual Studio 2015 to post an item journal. Some example code would be greatly appreciated. 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    Hi Silva, I have set up a user on the Role tailored Client of NAV 2017, but I receive this error when logging in.

    The web page at <webserviceurl> might be temporarily down or it may have moved permanently to a new web address.

  • CharithSilva Profile Picture
    CharithSilva 330 on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    That means your web service setup or authentication setup is wrong. You need to correct that before you do anything.

    The place you need to look at is the dynamics nav administration/setup.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    Unfortunatly the login does not work, though the xml properties of the service is displayed when I type 'localhost' in the web url. The xml only contains 'ServiceName' and 'ServiceName_Port'.

  • CharithSilva Profile Picture
    CharithSilva 330 on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    Ok Try pasting the web service url on the web browser and you should see xml properties and methods (It will ask you user and password). If that works the way you are adding service reference is wrong. try above first and if it works i will guide you how to add service reference (bit different its called web reference)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    Hi Silva, I have followed the code you have posted but the service does not show on the program when I am trying to create the service object. Just to let you know the codeunit I am trying to implement is 241 'Itm Journal Post'.

  • CharithSilva Profile Picture
    CharithSilva 330 on at
    RE: Running a NAV Post Journal CodeUnit Service from Visual Studio 2015

    Hi,

    first create the web service and publish the code unit in web services

    Then in VS create the service reference

    then use it as the service as example below(Below is a sales order creation  in VB.net)

    Dim service As New PostSalesOrder_Service

    service.Url = webservicepageurl & "PostSalesOrder"

    service.UseDefaultCredentials = True

    Dim newOrder As New PostSalesOrder

    service.Create(newOrder)

    newOrder.Sell_to_Customer_Name = txtTCno.Text

    newOrder.Posting_Date = DateTime.Now()

    -----at the end

    service.Update(newOrder)

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans