My Products
Help
kashyap
PARTNER

How to setup customer number series?

by kashyap

We need to use the customerNo field but its not auto generated while creating customer using graphql.

Do we have any setup to configure number series in UI?  OR we can pass in "suggest" field but its deprecated.

 

mutation createCustomer($companyNo: Int = 123456){
  useCompany(no: $companyNo) {
    results: associate_create(
      values: {
        name: "Demo", 
        phone: "41234567", 
        emailAddress: "abc@xyz.com", 
        addressLine1: "Torsgate 26", 
        postCode: "1205", 
        postalArea: "Oslo"
      }
    ) {
      items {
        companyNo
        associateNo
        customerNo
        name
        addressLine1
        postCode
        postalArea
        countryNo
        emailAddress
        phone
        customerPriceGroup1
        changedDateAsDate
        changedTimeAsTime
      }
    }
  }
}

 

1 REPLY 1

by Øyvind Årseth

Hi @kashyap 

If you have customer series activated, you can do it like this: 

mutation CreateCustomer ($cid: Int) {
    useCompany(no: $cid){
        # create the associate with desired input
        associate_create(values:[
      {
        name:"Erik Larsen", 
        addressLine1: "Testveien 1"
        postCode: "3270"
        # set the interval for the desired series (if any) 
        customerNo_suggest_interval: {
            from: 20000,
            to: 30000}
      },
      {
        name :"Frida Olsen",
        addressLine1: " Testveien 2"
        postCode: "0106"
        customerNo_suggest_interval: {
            from: 20000,
            to: 30000}
      }])      
        {
            affectedRows
            items {
                customerNo
                name
                addressLine1
                postCode
                postalArea
            }
        }       
    }
}

Without customer series, you can use the new method for suggesting values, documented 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"
            paymentTermsForCustomer: 15
        })      
        {
            affectedRows
            items {
                customerNo
                name
                addressLine1
                postCode
                postalArea
            }
        }       
    }
}