C# app which works with Codeunit Web service

casio11casio11 Member Posts: 12
Hi,

I have C# app which have to use function from Codeunit which have to modify some fields.
Here is a code from app..

ijgs80nj0dgf.png

Here is function from Codeunit..
0ejvg13jc0l5.png

I test app, and it works when, return some value in label or textbox, but when should to modify fields in nav doesnt work.

Help :)

Answers

  • EvREvR Member Posts: 178
    edited 2016-10-26
    Can you be a little more specific than 'it doesn't work'?
    Opened the NAV debugger to see what happens?
  • casio11casio11 Member Posts: 12
    alvehco3ouoi.png

    This is the error in Event Viewer
  • Wisa123Wisa123 Member Posts: 308
    Had this error last week. Don't ask me why but don't use UseDefaultCredentials. Using System.net.NetworkCredential got rid of the error for me.
    Austrian NAV/BC Dev
  • casio11casio11 Member Posts: 12
    Wisa123,
    Can you show me how you resolve this problem ?
  • Wisa123Wisa123 Member Posts: 308
    using System.Net;

    NetworkCredential cr = new NetworkCredential("userName", "password", "domain");
    wst.Credential = cr;

    Use those 2 lines instead of the UseDefaultCredential. Didn't try it now but it should work.
    Austrian NAV/BC Dev
  • casio11casio11 Member Posts: 12
    Wisa123,

    Dont work again :/. When i add return parametar in my Codeunit function,
    GetLocation(LotNo,loc) return Test:text, Test:= LotNo+Loc, and edit my C# app label.text=GetLocation(Lot,Lok), program works, app return value, but didnt want to modify field in NAV.
    Only want to return value
  • taigtaig Member Posts: 6
    Hi,

    Rather than having the function return a Text, modify it so the functions returns nothing, but has a seperate VAR parameter of TEXT, then in your c# code, you pass a seperate string as a ref.

    So the c# code would look like, i have boxed the 2 changes, just make sure you change the NAV side function and update your web reference


    rahcgoo8xiux.png



    Try that.

    Regards
    Roland
Sign In or Register to comment.