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
Did you try replacing spaces, if existing, with "%20" expression?
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.