Options

Error when calling a DotNet component

MHavemannMHavemann Member Posts: 10
edited 2014-07-18 in NAV Three Tier
I need to send some invoice lines to a webervice.

I used this good post on Gunnars Blog to create a proxy.

And it works a charm - but only for two of the companies in the database. When I run it for the third company I get a: "Object reference not set to an instance of an object" error.

the code looks like this
UpdateCRMwithInvoiceLine(DocType : 'Invoice,CreditNote';DocNumber : Code[20];LineNo : Integer)

MembershipSetup.GET;
MembershipSetup.TESTFIELD("Update Invoice CRM URL");
UpdateInvoiceService := UpdateInvoiceService.OpretOpdaterFakturalinje;
UpdateInvoiceService.Url := MembershipSetup."Update Invoice CRM URL";
LineIDSpecified := LineNo <> 0;
ServiceAnswer := UpdateInvoiceService.OpretOpdaterFaktura(DocNumber,LineNo,LineIDSpecified,COMPANYNAME);
UpdateCRMLog(DocType,DocNumber,LineNo,ServiceAnswer,'OpretOpdaterFakturaLinje')

It fails in the second to last line. I have tried to insert constants in the parameters to the call, so that the only variable is the company that is selected when I run the code - same error.

I am a bit baffled - anybody that have any ideas to what can be the problem?

PS - It is on a 2013 R2.

Comments

  • Options
    geordiegeordie Member Posts: 655
    Does the company name include some special characters?
    Did you try replacing spaces, if existing, with "%20" expression?
  • Options
    MHavemannMHavemann Member Posts: 10
    Yes it does. But so do the Company where it works fine. And it also works with Cronus, so spaces should not be a problem (Cronus Denmark A/S).
    geordie wrote:
    Does the company name include some special characters?
    Did you try replacing spaces, if existing, with "%20" expression?
  • Options
    nav_studentnav_student Member Posts: 175
    http://msdn.microsoft.com/en-us/library/gg502473.aspx

    See this:
    To call members in a .NET Framework type from C/AL code
    ...
    3.In your C/AL code, add the following code to call the constructor that creates a new instance of the type. If you are calling a static method, then a constructor is not required, and you can skip this step.
Sign In or Register to comment.