How to copy custom field value (checkbox) to a linked card with butler?

J. vd W. March 24, 2022

Hi all,

 

At this moment, when I add an item to a checklist, it finds the {checklistitemname} on the board and links the card together.

 

The checklistitemname card has a customfield "Bio" checked or unchecked standard.

When the checklistitemname card is linked to the triggercard, I want it to copy the customfield value of "Bio".

 

Use-case:

 

I have a card "TRIGGER" and a card "ITEM".

ITEM has a custom field "Bio" checked.

TRIGGER has a custom field "Bio" unchecked (standard) and has a checklist. To this checklist, ITEM is added. TRIGGER and ITEM are now added to the Trello attachments and linked to each other.

Now, because ITEM has "Bio" checked, I also want TRIGGER to check the custom field "Bio".

 

Is this possible?

Thanks in advance!

1 answer

1 accepted

1 vote
Answer accepted
milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2022

@J. vd W. 

I think you are the same person that posted it Reddit. I am going to build a specific end point that handles this use case.

lookup a card titled "ITEM" in list "Lookup", and post to url "https://jviwoq.deta.dev/update_checkbox?api_key=14a...............21d7&token=be9f...................a6cb4" with payload "{"card_id" : "{triggercardidlong}", "alt_card_id" : "{foundcardidlong}", "cf_name" : "CF_Checkbox"}"

The endpoing with redoc :

https://jviwoq.deta.dev/redoc#operation/update_checkbox_update_checkbox_post

The documentation on github :

https://github.com/xu2xulim/Superhero/blob/master/Superhero%20on%20deta/Micros/Custom%20Fields.md#update_checkbox

 

J. vd W. March 25, 2022

Hi Milynnus,

 

Thanks for the effort!

 

This is the rule I'm using:

when an item starting with "{checklistitemname}" is added to a checklist, lookup a card titled "{checklistitemname}", and post to url "https://jviwoq.deta.dev/update_checkbox?api_key=14a...............21d7&token=be9f...................a6cb4" with payload "{\"card_id\" : \"{triggercardidlong}\", \"alt_card_id\" : \"{foundcardidlong}\", \"Bio\" : \"Bio_Checkbox\"}

The {checklistitemname} card has Custom field "Bio" checked.
When I add {checklistitemname} to card "TRIGGER" it doesn't check the "Bio" checkbox on card TRIGGER.

It gives the following error in my butler warning box:

 

There was an error requesting the URL https://jviwoq.deta.dev/update_checkbox?api_key=14a...............21d7&token=be9f...................a6cb4:

422 {"detail":[{"loc":["body","cf_name"],"msg":"field required","type":"value_error.missing"}]}

 

Any ideas?

Thanks in advance.

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2022

@J. vd W. 

Couple of observations :

  1. Looking at the log you were trying to use GET instead of POST
  2. you have to use your own api key and token
  3. You should use "cf_name" : "Bio_Checkbox" as part of payload 

I have update my code to support the case where the alt_card (target) and the corresponding CF is not on the same board.

Thanks for trying.

Like J. vd W. likes this
J. vd W. March 25, 2022

Hi @milynnus ,

 

1. I'm unsure what that means. I've definitely used the "POST to ..." option in the automation butler.

2. Woops, I've done that now.

3. I've changed the code, I hope it's okay now:

 

when an item starting with "{checklistitemname}" is added to a checklist, lookup a card titled "{checklistitemname}", and post to url "https://jviwoq.deta.dev/update_checkbox?api_key=a20xxxxxxxxxxxxxxxxxxxxxxx225fc&token=21fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2b" with payload "{\"card_id\" : \"{triggercardidlong}\", \"alt_card_id\" : \"{foundcardidlong}\", \"cf_name\" : \"Bio_Checkbox\"}"

 

Is this how it should be? It's currently still not ticking the checkbox, giving me this error:

"400 {"result":"The custom field(s) is not a checkbox or custom field not found"} "

 

So I changed the code to:

 

when an item starting with "{checklistitemname}" is added to a checklist, lookup a card titled "{checklistitemname}", and post to url "https://jviwoq.deta.dev/update_checkbox?api_key=a20xxxxxxxxxxxxxxxxxxxxxxx225fc&token=21fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2b" with payload "{\"card_id\" : \"{triggercardidlong}\", \"alt_card_id\" : \"{foundcardidlong}\", \"cf_name\" : \"Bio\"}"

This gives the result:

"result":"OK"}

 

But it still doesn't tick the box.

 

Any ideas?

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2022

@J. vd W. 

Congrats 🎉 you have got further. 
The first error is when you supplied a cf that is not of type = checkbox or there is no checkbox CF matching the name.

 
The end point takes the checkbox status from the first card and update the cf of the second (alt_card_id). Since I cannot see your board, I can be definitive. 

Like J. vd W. likes this
J. vd W. March 25, 2022

Hi @milynnus ,

Thanks haha! With your help ofcourse.

I'll try to explain it a little more in-depth, so I've made a test case:

pic1.png

I have two cards, as shown above: Trigger and Item.

 

"Item" is a one-time input, this is the product. It's either bio or not, so this is checked only once and that's permanent.

"Trigger" is the customer order, so each time a customer places an order, the employee creates a new card.

 

Then, the product (Item) gets linked to the customer order (Trigger), this is done by adding "Item" to a checklist in card "Trigger". It links the cards.

The moment "Item" is added to a checklist in card "Trigger", I want it to check if "Item" has custom field "Bio" checked, yes/no. And I want it to copy this value to "Trigger".

 

Any other suggestions? I think perhaps the triggercardidlong/foundcardidlong aren't correct, though I'm unsure because I truly have no experience in this.

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2022

@J. vd W. 

if I understand you correctly, 

your card_id will be {foundcardidlong} and your alt_card_id is {triggercardidlong}. 

J. vd W. March 25, 2022

@milynnus 

Yep, that's it! Thank you so much. :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events