I am pretty new to monday.com, and this is my first experience with GraphQL
I am using Javascript in my API to mutate my board, specifically:
My objective:
I have a board with a few summary columns and a button. Each of the items of that board has a bunch of subitems. The purpose of the button mentioned above is to trigger my javascript code that writes a number into each of the subitems.
What is given:
BoardID and item_id (as pulseId) or rather, which item I clicked the button on.
From here, I seemed to be able to get to the boardās subitems ID:
query{boards(ids:$boardID){columns(ids:"subitems"){settings_str}}}
followed by: let subID = JSON.parse(data_subs.data.boards[0].columns[0].settings_str).boardIds[0]
If thereās a better way to get to sub-board-id please let me know, but ok.
So far so good. but ā¦
My issue:
I canāt find a way to traverse the tree, that is, how to go from the given elements to loop through the subitems of a specific item, getting their IDs. Once I have the id, I know how to
for each ID I run āchange_column_value(ā¦)ā
Any recommendation is greatly appreciated.
Thanks in advance,
This is the sort of query used to get a list of subitems in the current API:
query {
items(ids: 4639429787){
id
column_values(ids: "subitems") {
value
}
}
}
The response, you will need to JSON.parse(data.items[0].column_values[0].value and then you have the array of {linkedPulseId: number} objects which you can iterate.
Hello Cody, thank you so much for such detailed examples.
This is absolutely perfect, very clear on my original question.
Is it possible to know the position of a subitem, which is it in order? Because the array returned, seems like getting it in the order of addition, not how they are listed, and if I moved the subitems with the browser UI interface, the array doesnāt not update the order.
Unfortunately, item order is not something the API returns reliably. Esp. for subitems.
Its been a long standing feature request here⦠i may be partial to having this too, and in the new API I am hoping that they will implement it (version 2024-01 I hope. 2023-10 is already pretty set in stone) I donāt think its possible there in 2023-10 though we do have the ability to get items returned ordered by a columnās values. So for example if you have them by sorted by a date, then youāre gold - but if you rely on the dragged order then nothing yet.
I just voted that feature up by one. Seemingly trivial feature to implement, and they have this item position already.
Thank you for all your detailed replies.