My Products
Help

Error creating supplierInvoice. Object reference not set to an instance of an object.

by Eirik Morken - Proplan AS

Greetings 😁 I am using the following endpoint: /controller/api/v1/supplierInvoice

I am attempting to create a Supplierinvoice but am receiving an error message with code 500 that I am unable to interpret. It states: "Error creating supplierInvoice. Object reference not set to an instance of an object."

Are you able to see what is missing/wrong in the following code?

 

 

{
	"date": {
		"value": "2021-05-18T07:01:44.979Z"
	},
	"description": {
		"value": "Fra SAP Ref: 9037155759"
	},
	"documentType": {
		"value": "INV"
	},
	"dueDate": {
		"value": "2021-05-18T07:01:44.979Z"
	},
	"hold": {
		"value": true
	},
	"invoiceLines": [
		{
			"accountNumber": {
				"value": "1440"
			},
			"lineNumber": {
				"value": 1
			},
			"operation": "Insert",
			"projectId": {
				"value": "X"
			},
			"quantity": {
				"value": 1
			},
			"subaccount": [
				{
					"segmentId": 1
				}
			],
			"transactionDescription": {
				"value": "Fra SAP"
			},
			"unitCostInCurrency": {
				"value": "3090.00"
			},
			"vatCodeId": {
				"value": "1"
			}
		}
	],
	"overrideNumberSeries": {
		"value": true
	},
	"referenceNumber": {
		"value": "9037155759"
	},
	"supplierNumber": {
		"value": "WXA"
	},
	"supplierReference": {
		"value": "test00100034"
	}
}

 

 

9 REPLIES 9

by Eirik Morken - Proplan AS

The solution was to remove validation for the subaccount segment 😁

Yıldırım
VISMA

Thanks for the confirmation 🙂

by Eirik Morken - Proplan AS

I have now fixed this issue with the code, but now a different problem arises. I get the error code 400, message: "

Error: An error occurred during processing of the field Subaccount: Error: Avdeling of Subaccount do not exist."

 Although the code (with small alterations for suppliernumber and segmentvalue) works just fine when used on another client. I have no problem creating invoices in the UI. The subaccount also exists, here is a part from the /controller/api/v1/subaccount endpoint:

 

[
  {
    "subaccountNumber": "00",
    "subaccountId": 107712,
    "description": "Ingen",
    "lastModifiedDateTime": "2021-05-12T13:54:35.327",
    "active": true,
    "segments": [
      {
        "segmentId": 1,
        "segmentDescription": "Avdeling",
        "segmentValue": "00",
        "segmentValueDescription": "Ingen"
      }
    ],
    "metadata": {
      "totalCount": 5,
      "maxPageSize": 1000
    }
  },
  {
    "subaccountNumber": "01",
    "subaccountId": 107713,
    "description": "Elkjøp",
    "lastModifiedDateTime": "2021-05-12T13:54:35.327",
    "active": true,
    "segments": [
      {
        "segmentId": 1,
        "segmentDescription": "Avdeling",
        "segmentValue": "01",
        "segmentValueDescription": "Elkjøp"
      }
    ],
    "metadata": {
      "totalCount": 5,
      "maxPageSize": 1000
    }
  },
 

Here is the updated code used in the supplierinvoice endpoint:

 

 

{
	"documentType": {
		"value": "Invoice"
	},
	"referenceNumber": {
		"value": "1000001"
	},
	"hold": {
		"value": true
	},
	"date": {
		"value": "2021-05-19T10:29:27.857Z"
	},
	"supplierReference": {
		"value": "WXA"
	},
	"description": {
		"value": "Test123"
	},
	"supplierNumber": {
		"value": "WXA"
	},
	"invoiceLines": [
		{
			"operation": "Insert",
			"lineNumber": {
				"value": 1
			},
			"subaccount": [
				{
					"segmentId": 1,
					"segmentValue": "00"
				}
			],
			"transactionDescription": {
				"value": "test"
			},
			"quantity": {
				"value": 1
			},
			"unitCostInCurrency": {
				"value": 100
			},
			"accountNumber": {
				"value": "3000"
			},
			"vatCodeId": {
				"value": "1"
			},
			"projectId": {
				"value": "X"
			}
		}
	],
	"paySelected": {
		"value": true
	},
	"overrideNumberSeries": {
		"value": true
	}
}

 

 

 

Yıldırım
VISMA

Could you make sure that subaccount:segment/value combination has been registered and available at the lookup table in Financials UI ? 

1) Check Subaccounts - ScreenID=GL203000
sub.png

2)Check Subaccount Segment/Value via lookUp table in the Supplier Invoice
-Select Subaccount Segment by clicking > Press F3 to check available values for this segment.
sub2.png

Thanks.

Hi,

Apart from the values being available in the segment keys subaccount window(ScreenId=CS202000&DimensionID=SUBACCOUNT):

2021-05-19 14_10_11-Segment values.png2021-05-19 14_05_36-Segment keys.png

Please also make sure that the subaccount is setup in ScreenId=GL203000:

2021-05-19 14_03_57-Subaccounts.png

All these fields are OK.
Still not working 😊

 

Accepted solution
Yıldırım
VISMA

by Yıldırım (Updated ‎20-05-2021 10:44 by Yıldırım VISMA )

Hello Eirik, 
we've emailed you about the further instructions for diagnosing the issue. 

Edit:
uncheck "Validation" in the segment and try the operation again.validation.png

by Magnus Johnsen

As Florian mentioned, please include the value of your subaccount as such:

2021-05-19 08_47_55-Visma.net Integrations Documentation.png

Also, the document type should be "Invoice":

2021-05-19 08_47_22-Visma.net Integrations Documentation.png

 

Please correct this and let us know if you are still having issues.

 

Thank you.

Florian Haase
PARTNER

by Florian Haase

Hi,

 

I think you try to post subaccount segment without a value...

 

Florian