Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Upchain Forum
Welcome to the Upchain Forum. Share your knowledge, ask questions, and explore popular Upchain topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API BOM Reordering

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
imckenzieY7CGY
291 Views, 2 Replies

API BOM Reordering

Is it possible to use the API to reorder an item's BOM, and if so, can you provide an example? Say we have a BOM which is currently sequenced like this, and we want to automatically reorder the sort numbers so the sequence matches the natural order of some attribute "Attr" (suppose this was the Item Type):

  • Parent Item
    • Child1, Attr:"C"
    • Child2, Attr:"D"
    • Child3, Attr:"B"
    • Child4, Attr:"A"

And I want to use the API to end up with this:

  • Parent Item
    • Child4, Attr:"A"
    • Child3, Attr:"B"
    • Child1, Attr:"C"
    • Child2, Attr:"D"

How would I do that? 

 

So far I've found the endpoint that appears to be used to change the sort numbers: /api/bom/v2/items/children/{partPartId}/actions/reorder

 

So I think my app idea would need to first get the BOM with current sort numbers and attributes specified, figure out the new sort order based on 'Attr', and then make a call to the reorder endpoint for each child item (there's no way to do this in bulk, is there?). 

 

Would this be the endpoint to use for getting the current sort numbers and attributes or is there a more appropriate one: /api/bom/v2/project/{projectId}/extended-items/{parentPartVersionId}

Labels (1)
  • API
2 REPLIES 2
Message 2 of 3

Hi @imckenzieY7CGY , you are right that these 2 endpoints are used for reordering.

 

1) Call /api/bom/v2/project/{projectId}/extended-items/{parentPartVersionId} to get current eBom data. It returns a lot of data, but for re-ordering purposes, you are most interested in 2 fields, "partPartId" and "sortNumber", since you'll need to use them in re-order endpoint

 

2) Call /api/bom/v2/items/children/{partPartId}/actions/reorder to reorder a single item in ebom. Below is an example of my call for reordering, where I have 3 children items and I want to move one child (partPartId 13264546) to first place:

sanjinvuckovicA22VM_1-1697185769849.png

  • Parameter "partPartId" is eBom relationship ID of the part we want to move (re-order). You have that value from calling first endpoint
  • Parameters "destinationIndex" and "sortOrder" are used to determine where to move item (just a note, destinationIndex is not the same as sortNumber).
    • To move item to first place, use destinationIndex 0 and sortOrder ASCENDING.
    • To move item to second place, use destinationIndex 1 and sortOrder ASCENDING.
    • To move item to last place, use destinationIndex 0 and sortOrder DESCENING.
    • ....
  • In request body, you need to send partPartId and sortNumber (from first endpoint) of how data is currently sorted. So, it's mostly a copy-paste of data from first endpoint, find all partPartId's and their sortNumbers and put them in request as shown on image.
  • Response of the endpoint call will be partPartIds and new sortNumbers for your assembly.
    • If you need to reorder another item in assembly, you'll need to make another call to endpoint, with data of another item. But note that after first call was made, existing sortNumbers have changed, so when you call it again, make sure to update request body with latest values for sortNumbers (you can copy response from previous call, as it contains latest values)

I hope this will help you to call reordering endpoint. It there will be additional questions, I'd be glad to answer them.

 



Sanjin Vuckovic
Software Development Engineer
Message 3 of 3

That works! Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report