My Products
Help
AllanEgebjerg
CONTRIBUTOR ***

Updating orderlines on order in one api call

by AllanEgebjerg

As part of an integration from WMS to Visma Business NXT, we want to update orderlines when they have finished picking, so we can set FinishNow, grouped by useByDate and/or serial. 

So what we are looking for is a way to update all orderlines in one api call, wither in one mutation or by batch mutations. 

Batch mutations does not seem to work as intented. It seems like only one mutation is performed, and looks random witch one of the mutations that is performed. 

 

How do we approach this issue? 

7 REPLIES 7
AllanEgebjerg
CONTRIBUTOR ***

by AllanEgebjerg

Okay, then it will be that way. 
Thank you so much for your answer. 

omelhus
PARTNER

by omelhus

I’m on holiday and on my phone, so bear with me here.

 

Generate a query like this. That’s what I do on https://lett.as. I update the order, create, update and delete lines in one single query. Create order requires two queries.


mutation Many($cid: Int!, $filter1: FilterExpression_OrderLine, $update1: OrderLine_Input, $filter2: FilterExpression_OrderLine, $update2: OrderLine_Input){

 

update1: orderLine_update(filter: $filter1, value: $update1) {

affectedRows

}

update2: orderLine_update(filter: $filter2, value: $update2) {

affectedRows

}

 

}

AllanEgebjerg
CONTRIBUTOR ***

by AllanEgebjerg

Thank you so much for taking time in your holiday to help 🙂 

Looks like I can get this to work. 


I was hoping that it would be possible to input an array of orderlines in the variables and then somehow pass this array to orderLine_update, including 'filter' and 'value'.

But it doesn't look like orderLine_update can take an array as input?

Accepted solution
omelhus
PARTNER

by omelhus

Not a problem 😎

 

Update does not take an array like create does. This is the way until Visma enable batching.

by Marius Bancila

We have added support for batching requests. See documentation: https://docs.business.visma.net/docs/features/batches

omelhus
PARTNER

by omelhus

Inline the mutations and send the updates as parameters. Works like a charm for me.

AllanEgebjerg
CONTRIBUTOR ***

by AllanEgebjerg

Thanks. 

 

Could you post an example for that? 
Updating one orderline is not a problem, using variable, but when we have a variable number or orderlines that should be updated.