Solutions for Tag Update via API

  • 2 February 2022
  • 3 replies
  • 311 views
Solutions for Tag Update via API
Userlevel 7
Badge +15

I identified 3 ways to update tags through GraphiQL. You should use the most appropriate format for your process.

 

Scenario A) Updating a single tag.

 

Solution 1: This is the simplest scenario and should only be used if your Pipe has only one label field.

 

mutation{    updateCardField(input: {                   
card_id: XXXXXXXX
field_id:"label_1"         
new_value:"XXXXXXXX" })
{ clientMutationId success } }

In this format, as the update is from a field to a label, there is no problem.

 

Scenario B) Updating multiple labels in different fields.

 

For this scenario, there are several solutions, as simply updating the label fields does not guarantee that the card labels are properly updated / synchronized with the Card labels.

 

Solution 2: Update more than one tag field, each field with a tag.

mutation{   
m1:
updateCardField(input:{
card_id:XXXXXXXX
field_id:"label_1",new_value:"XXXXXXXX" } )
{ card { id } }

m2:
updateCardField(input:{
card_id:XXXXXXXX
field_id:"label_2",new_value:"XXXXXXXX" } )
{ card { id } }

}

In this scenario, you can update multiple fields in sequence. Each with its proper label.

In the first update, Pipe will recognize the tags and will synchronize them with the Card, however, if a second update is made (Tag Replacement), only the first mutation will be recognized/synchronized. The other fields will be updated, but the labels will not appear on the Card.

 

Solution 3: Update multiple labels in a single field.

This solution is similar to the first one. The difference is that instead of informing only the ID of a label, you will inform all the IDs in array format.

 

mutation{   
updateCardField(input:{
card_id:XXXXXXXX
field_id:"label_1"
new_value:["XXXXXXXX","XXXXXXXX","XXXXXXXX"] })
{ clientMutationId success } }

 

I hope these tips can be helpful.

 

Do you use any different solution?

 


3 replies

Userlevel 7
Badge +15

Nice @genietim!

Your solution is very interesting too. It is for when there are no specific tag fields.

I normally leave all tags as fields as well. So I can use them in report and dashboard filters.

 

Userlevel 7
Badge +12

Yes, I use a different solution! Awesome how many there are.

I use the following (does not use a field):

mutation {
updateCard(input: { card_id: "xxxx", labelIds: ["xyxy", "zazaza"] }) {
clientMutationId
}
}

 

Userlevel 7
Badge +8

Awesome, Lucas. Thanks for sharing it with our Community! 

Reply