My Products
Help
Scruha
CONTRIBUTOR **

The ability to set No for customers, orders

by Scruha

Does it exist the ability to set the customerNo using  sociate_create API? I see that this field is possible as an input parameter but I get: field value can only be allocated automatically.

The same issue with setting the orderNo using order_create API.

8 REPLIES 8
Scruha
CONTRIBUTOR **

by Scruha

How to enable the ability to set customerNo or orderNo? I can't find this setting.

Accepted solution
Øyvind Årseth
VISMA

by Øyvind Årseth

Hi @Scruha 
You can query the current settings with the API like this: 

query CompanyInformationParams ($cid: Int) {
    useCompany(no: $cid){
       companyInformation {
               items{
                   onlyAutomaticAssignment
                   onlyAutomaticAssignmentFlags
               }
           }
     }
}


You should also be able to edit the value, as shown below. The value in the example should fit your needs in terms of being able to create specific order, associate and customer numbers. NB! Keep in mind that the current parameter value may be there for a reason, changing parameter values should always be cleared with the customer before changes are made. If you don't know the consequences, always consult the customer's partner before making changes. 

mutation CompanyInformationParams ($cid: Int) {
    useCompany(no: $cid){
       companyInformation_update(
           value: {onlyAutomaticAssignment: 7}) {
               affectedRows
               items{
                   onlyAutomaticAssignment
                   onlyAutomaticAssignmentFlags
               }
           }
     }
}

The described field is also available in the UI, in the Company information table. It is not visible by default in the standard layouts, so you have to add it. Ctrl+U, search for "+" in the available columns, and add it to the selected columns in the layout. 

by Øyvind Årseth

Hi @Scruha Yes, it is. I suggest you take a look at the API documentation, here

mutation CreateCustomer ($cid: Int) {
    useCompany(no: $cid){
        # create the associate with desired input
        associate_create(values:
        {
            customerNo: null
            name:"Erik Larsen", 
            addressLine1: "Testveien 1"
            postCode: "3270"
        })      
        {
            affectedRows
            items {
                customerNo
                name
                addressLine1
                postCode
                postalArea
            }
        }       
    }
}
Scruha
CONTRIBUTOR **

by Scruha (Updated ‎19-09-2023 10:35 by Scruha )

Example of an order creation:

mutation UseCompany {
    useCompany(no: 123456) {
        order_create(values: { orderNo: 10639, customerNo: 10639 }) {
            items {
                orderNo
            }
        }
    }
}

I always get: A record with the same primary key already exists.

It doesn't matter what orderNo is passed and that this order with this orderNo does not exist (sounds like an error on Visma's side).

Scruha
CONTRIBUTOR **

by Scruha

Yes, here is the question I need to set customerNo not on the Visma side. 

Also, I need to set orderNo using order_create API. 

But Visma doesn't provide this possibility, although based on the API it should be possible.

As an example making:

mutation UseCompany {
    useCompany(no: 132456) {
        associate_create(values: { name: "Some name", customerNo: 12600 }) {
            items {
                associateNo
                name
            }
        }
    }
}

I get:

Error: Field value can only be allocated automatically, in accordance to choice in Company data..

by Øyvind Årseth

@Scruha Most probably because there is a parameter in Company data preventing you from entering a value, it only allows suggesting one, either with "+" in the UI, or by the API. The parameter is named "Next on + only" in the UI, and should have a value corresponding to your needs. It can also be in play with the order number, so please check it out. 

Scruha
CONTRIBUTOR **

by Scruha

The same error through the UI. Could you provide details on where I can set up this ability?

Scruha
CONTRIBUTOR **

by Scruha (Updated ‎19-09-2023 10:34 by Scruha )

Missclick: remove this reply