My Products
Help

Bitflag columns

by Marius Bancila

We have added better support for working with columns that represent bitflags.

See https://docs.business.visma.net/docs/schema/bitflags for more!

7 REPLIES 7
Florian Haase
PARTNER

by Florian Haase

Did you set this adding / removing of bit-values on a feature-list for future versions? 

We also see that this is needed.

by Marius Bancila

The fix is in production. Please try it again and let us know if your problem is solved.

by Marius Bancila

I do get an error, but something else:

{
  "errors": [
    {
      "message": "Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.",
      "path": [
        "useCompany",
        "associate_update"
      ],
      "extensions": {
        "details": "GraphQL.ExecutionError: Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'."
      }
    }
  ],
  "data": {
    "useCompany": {
      "associate_update": null
    }
  },
  "extensions": {
    "vbnxt-trace-id": "0000000000000000aed2f5535fa82f2f"
  }
}

Works if I put the value in the query. 

The variable should work too. We will fix this.

Thank you for testing and verifying it. 

by David Tandberg-Johansen

Hi @Marius Bancila 

 

I found a scenario i would like to get verified by you is correct that fails

I'm testing in GraphiQL on your domain.

I havent yet testet as a request

 

We have a mutation like this

mutation UpdateObjectWithEnumValues($no: Int, $value: Associate_Input!) {
  useCompany(no: $no) {
    associate_update(filter: {customerNo: {_eq: 10000}}, value: $value) {
      affectedRows
      items {
        customerNo
        group7
        documentDeliveryMethod1
        documentDeliveryMethod1Flags
        documentDeliveryMethod2
        documentDeliveryMethod2Flags
      }
    }
  }
}

 

And in the variable section we set the value 

{
  "no": 3757816,
  "value": {
    "group7": 2,
    "documentDeliveryMethod2Flags": [
      "EdiMediaTypePrint",
      "EdiPostageTypeSecondClassMail",
      "PurchaseOrdersSentByAutoInvoice"
    ]
  }
}

 

When we run this in GraphQL we get this results

{
  "errors": [
    {
      "message": "Failed to execute 'text' on 'Response': body stream already read",
      "stack": "TypeError: Failed to execute 'text' on 'Response': body stream already read\n    at https://docs.business.visma.net/graphiql/static/js/main.50d3c8a2.js:2:981812"
    }
  ]
}

 

 On the documentation site for bitflags (https://docs.business.visma.net/docs/schema/bitflags) all the examples has the value on the object. Is it not possible to send it in the variable section?

 

When adding the info to the variable section, we get suggestion from GraphiQL after adding a bitflagfield, it suggest the values and ads quotation marks as shown over

 

I have tested to fill out values in the associate_update field, and it works

by David Tandberg-Johansen (Updated ‎10-10-2023 12:51 by David Tandberg-Johansen )

Hi @Marius Bancila 

 

Regarding the Bitflag columns, is there any way possible to update a row and just add a flag?

 

For example:

We want to update a Customer, and set the documentDeliveryMethod1 with flag InvoicesSentByAutoInvoice. There are already set other flags on the Customer, we just want to add the InvoicesSentByAutoInvoice flag.

 

Is there any way to just add InvoicesSentByAutoInvoice flag in a mutation, or do we have to get all the flags for the customer first and add the existing flagg to the update?

 

We tried the mutation below, and it clears all other flags, and sets just the InvoicesSentByAutoInvoice

 

 

mutation UpdateCustomerBitFlag($no: Int, $custNo: Int) {
  useCompany(no: $no) {
    associate_update(
      filter: {customerNo: {_eq: $custNo}}
      value: {documentDeliveryMethod1Flags: [InvoicesSentByAutoInvoice]}
    ) {
      affectedRows
      items {
        customerNo
        documentDeliveryMethod1
        documentDeliveryMethod1Flags
      }
    }
  }
}

 

 

There is no append/remove operation, only set. You need to read the existing value, add/remove what you want and then perform an update.