My Products
Help

Subaccount gets ignored when using PO endpoint

by Eirik Morken - Proplan AS

Greeting 😁

I am currently trying to use the /controller/api/v1/purchaseorder/{purchaseOrderNumber} endpoint to add lines to a PO. When I try to add a specific value to the sub-account on the line it seems to ignore whatever value exist in the PUT for subaccount and simply use the default from the inventoryitem, or if no inventoryitem, the default overall.


The subaccount exists in both GL203000 and CS203000, and I am perfectly able to change it and set it manually in the UI. 

The following code works for all fields except subAccount:

{"lines": [
{"operation":"Insert",
"lineNumber": {
"value": 2
},
"inventory":{"value":"100"},
"sub": [
{
"segmentId": 1,
"segmentValue":"320"
},
{
"segmentId": 2,
"segmentValue":"03"
},
{
"segmentId": 3,
"segmentValue":"LN501273"
},
{
"segmentId": 4,
"segmentValue":"03"
}
],
"lineDescription": {
"value": "test4"
},
"uom": {
"value": "STK"
},
"project": {
"value": "X"
}
}
],
"hold": {
"value": true
},
"date": {
"value": "2021-05-28T09:17:54.307Z"
}
}

Any assistance will be greatly appreciated 😀

9 REPLIES 9
Yıldırım
VISMA

by Yıldırım (Updated ‎17-09-2021 16:02 by Yıldırım VISMA )

Hello Eirik 🙂

 

In the JSON you've shared

"sub": [

 

"subaccount" should be used as per the following,

"subaccount": [
                {
                    "segmentId": 1,
                    "segmentValue": "60"
                },
                {
                    "segmentId": 2,
                    "segmentValue": "000000001"
                },
                {
                    "segmentId": 3,
                    "segmentValue": "006000"
                },
                {
                    "segmentId": 4,
                    "segmentValue": "0000"
                }
],

And even with the change to "subaccount" the result stays the same, it still does nothing.

Yıldırım
VISMA

Hello Eirik,

 

currently, this is configured as "Sub", so please disregard my reply above.  We're able to set the Subaccount values by using 

      "sub": [
                {
                    "segmentId": "1",
                    "segmentValue": "11"
                },
                {
                    "segmentId": "2",
                    "segmentValue": "777"
                },
                {
                    "segmentId": "3",
                    "segmentValue": "88"
                }
            ]

Financials output:

2021-09-22 14_10_53-Window.png

 

1) What is your Segment Keys configuration for the "Subaccount" ? 

e.g. Validation can be "disabled" and Lookup mode can be set as "By segment: All available segment values"

segment.png

 

2)Otherwise, please make sure the desired subaccount / segment values have been registered in the "Subaccounts" list (ScreenId=GL203000) and they're active. 

sub.png

My inputs are still getting ignored even though all the settings seems OK. 

Could you post a copy of your complete PUT code so that I can test your code directly and only change the subaccount values to match my needs to verify whether or not it is a issue with my code.

Yıldırım
VISMA

by Yıldırım (Updated ‎22-09-2021 15:49 by Yıldırım VISMA )

Here you can see the PUT Payload.  Please make sure "lineNumber" corresponds with the PO_Line that you'd like to update. 

 

PUT > https://integration.visma.net/API/controller/api/v1/purchaseorder/xxxx

{
    "lines": [
        {
            "operation": "Update",
            "lineNumber": {
                "value": 1
            },
            "lineDescription": {
                "value": "Sub PUT test line"
            },
            "sub": [
                {
                    "segmentId": "1",
                    "segmentValue": "10"
                },
                {
                    "segmentId": "2",
                    "segmentValue": "700"
                },
                {
                    "segmentId": "3",
                    "segmentValue": "80"
                }
            ]
        }
    ]
}

 

put.png

Accepted solution
Eirik Morken - Proplan AS
CHAMPION *

I discovered the problem. If you try to set project as "X" (or any other value that is a project) as well as setting the subaccount the PUT will set the subaccount to the system default value. (This is also the case in the GUI, as the subaccounts get reset when you change the project on the line. The problem is that there is no way of ordering the setting of project value first in the code. I tried to put it both the project change before and after, but the subaccount got set to default both times.

I guess the temporary solution (until/if a fix will be implemented) will be to always PUT the subaccount after touching the project values. 😁

Yıldırım
VISMA

Hello, this is correct, steps are followed as in the UI. Subaccount should be updated separately if the project has been modified. We'll check if there is any possibility of changing the logic in the API independent of UI.

Then it seems you have a mistake in the Swagger documetnation on the PUT and POST of PO:
/controller/api/v1/purchaseorder/{purchaseOrderNumber}
/controller/api/v1/purchaseorder

by Magnus Johnsen (Updated ‎20-09-2021 10:56 by Magnus Johnsen VISMA )

Hi,

We can confirm there seems to have been a change in the endpoint and the documentation.

We are looking in to this and will get back to you shortly.

 

We have reported this to the development team and will inform you as soon as we get confirmation that has been picked up.