My Products
Help
Johan_TW
CONTRIBUTOR *

Subaccount SegmentValueNotFound

by Johan_TW

We are running in to an issue when trying to create a segment / Sales order, see details and steps below: 

 

I've found that "subaccount" value we send (00-TWxxxxxx), even if it was previously stored and even able to be received from Visma, won't be accepted for further SO creation request

But later (randomly), after few attempts SO will be created.

 

 

1) example of received segment from Visma

 

{"segmentId":2,"valueId":"TW88735","description":"TW88735","active":true,"timeStamp":"AAAAAAbbGcA=","lastModified":"2023-12-08T13:02:36.97"} 

 

 

2) example of further error upon SO creation while usage of above segment

 

{"details":[{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[0].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[1].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[2].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[3].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[4].subaccount"}}],"errors":{"DomainValidation":["The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2"]},"title":"One or more validation errors occurred.","status":400,"detail":"Refer to the errors property for additional details","instance":"/api/v3/SalesOrders"} 

 

 
8 REPLIES 8
Yıldırım
VISMA

by Yıldırım

Hello, what is your POST Payload ? 

Johan_TW
CONTRIBUTOR *

by Johan_TW (Updated ‎12-12-2023 13:36 by Johan_TW )

 

1.) Create segment:
https://integration.visma.net/API/controller/api/v1/dimension/SUBACCOUNT/2

 

{
  "segmentValues": [
    {
      "operation": "Insert",
      "value": "TW88752",
      "description": {
        "value": "TW88752"
      },
      "active": {
        "value": true
      }
    }
  ]
}

 

Response has HTTP 200, and empty body.

Subaccount has been created:

Johan_TW_0-1702384578796.png

 

 

2.) request for SO
https://salesorder.visma.net/api/v3/SalesOrders

 

{
  "type": "SO",
  "status": "Open",
  "orderId": "SO88752",
  "requestOn": "2023-12-12T12:51:51.000000Z",
  "customer": {
    "id": "237433",
    "order": "TW88752",
    "refNo": "Test reference"
  },
  "print": {
    "descriptionOnInvoice": true,
    "noteOnInternalDocuments": true,
    "noteOnExternalDocuments": true
  },
  "orderLines": [
    {
      "inventoryId": "TEXT",
      "description": "Order: TW88752 \nFrom: Amsterdam, NL (2023-12-12)\nTo: Berlin, DE (2023-12-12)\nReference: Test reference",
      "quantity": 1,
      "unitCost": 0,
      "unitPrice": 0,
      "requestDate": "2023-12-12T12:51:51.000000Z",
      "subaccount": {
        "1": "00",
        "2": "TW88752"
      }
    },
    {
      "inventoryId": "ROAD",
      "description": "Transport by road\nVehicle: Model1\nChassis number: 9ZPB76\n",
      "quantity": 1,
      "unitCost": 0,
      "unitPrice": 0,
      "requestDate": "2023-12-12T12:51:51.000000Z",
      "subaccount": {
        "1": "00",
        "2": "TW88752"
      }
    },
    {
      "inventoryId": "TOWING",
      "description": "Towing surcharge",
      "quantity": 1,
      "unitCost": 0,
      "unitPrice": 0,
      "requestDate": "2023-12-12T12:51:51.000000Z",
      "subaccount": {
        "1": "00",
        "2": "TW88752"
      }
    },
    {
      "inventoryId": "TOWING",
      "description": "Non rollable surcharge",
      "quantity": 1,
      "unitCost": 0,
      "unitPrice": 0,
      "requestDate": "2023-12-12T12:51:51.000000Z",
      "subaccount": {
        "1": "00",
        "2": "TW88752"
      }
    },
    {
      "inventoryId": "ROAD",
      "description": "Transport by road\nVehicle: Model2\nChassis number: TEST456\n",
      "quantity": 1,
      "unitCost": 0,
      "unitPrice": 0,
      "requestDate": "2023-12-12T12:51:51.000000Z",
      "subaccount": {
        "1": "00",
        "2": "TW88752"
      }
    }
  ]
}

 


Response:

 

{
  "details": [
    {
      "code": "1202-SegmentValueNotFound",
      "message": "The value 'TW88752' is not valid for SegmentId 2",
      "parameters": {
        "property": "orderLines[0].subaccount"
      }
    },
    {
      "code": "1202-SegmentValueNotFound",
      "message": "The value 'TW88752' is not valid for SegmentId 2",
      "parameters": {
        "property": "orderLines[1].subaccount"
      }
    },
    {
      "code": "1202-SegmentValueNotFound",
      "message": "The value 'TW88752' is not valid for SegmentId 2",
      "parameters": {
        "property": "orderLines[2].subaccount"
      }
    },
    {
      "code": "1202-SegmentValueNotFound",
      "message": "The value 'TW88752' is not valid for SegmentId 2",
      "parameters": {
        "property": "orderLines[3].subaccount"
      }
    },
    {
      "code": "1202-SegmentValueNotFound",
      "message": "The value 'TW88752' is not valid for SegmentId 2",
      "parameters": {
        "property": "orderLines[4].subaccount"
      }
    }
  ],
  "errors": {
    "DomainValidation": [
      "The value 'TW88752' is not valid for SegmentId 2",
      "The value 'TW88752' is not valid for SegmentId 2",
      "The value 'TW88752' is not valid for SegmentId 2",
      "The value 'TW88752' is not valid for SegmentId 2",
      "The value 'TW88752' is not valid for SegmentId 2"
    ]
  },
  "title": "One or more validation errors occurred.",
  "status": 400,
  "detail": "Refer to the errors property for additional details",
  "instance": "/api/v3/SalesOrders"
}

 



 

Yıldırım
VISMA

by Yıldırım

You can try 

 "1": "00-TW88752"


or review your Segment Setup via Segment Keys (ScreenId=CS202000&DimensionID=SUBACCOUNT)
segment_keys.jpg

then Segment Value of the selected Segment. 
Segment values.jpg

 

Johan_TW
CONTRIBUTOR *

by Johan_TW (Updated ‎13-12-2023 11:46 by Johan_TW )

Unfortunately the proposal does not work :
The value '00-TW88757' is not valid for SegmentId 1, A value for SegmentId '2' is not supplied.

As for second one : settings at the screenshot are equal to what we have - see my screenshot.

Johan_TW_0-1702463985995.png

If we manually add the segment in Visma GUI and use this in the API request it is working well.

 

Also the segment that has been created by the API, is accepted by a purchase order and the client invoice.



Yıldırım
VISMA

by Yıldırım

Do you see the value in the Segment:2 via the Segment Keys > Segment Values by clicking its ID ? 

Johan_TW
CONTRIBUTOR *

by Johan_TW

Yes, we see it there.

Yıldırım
VISMA

by Yıldırım

Hello Johan, could you please test the same request again today and inform us ? We suspect that this is related to the cache, which should be aligned approximately 1 hour after segment/value changes. 

Yıldırım
VISMA

by Yıldırım

Thanks for the information Johan, we've informed the team regarding this, and it'll be reviewed. We'll inform you accordingly ince the case clarified.