How to copy custom field value (checkbox) to a linked card with butler?
Asked by J. vd W.:

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!


Answers:
author: milynnus
body: [@J. vd W.](/t5/user/viewprofilepage/user-id/4802391)

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](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>

comments: author: J. vd W.
body: 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](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](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.


author: milynnus
body: [@J. vd W.](/t5/user/viewprofilepage/user-id/4802391)

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.


author: J. vd W.
body: Hi [@milynnus](/t5/user/viewprofilepage/user-id/3947182) ,

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](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](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?


author: milynnus
body: [@J. vd W.](/t5/user/viewprofilepage/user-id/4802391)

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.

<br />

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.


author: J. vd W.
body: Hi [@milynnus](/t5/user/viewprofilepage/user-id/3947182) ,

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](https://community.atlassian.com/t5/image/serverpage/image-id/189950i3DA3A79481EFD25E/image-size/large?v=v2&px=999 "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.


author: milynnus
body: [@J. vd W.](/t5/user/viewprofilepage/user-id/4802391)

if I understand you correctly,

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


author: J. vd W.
body: [@milynnus](/t5/user/viewprofilepage/user-id/3947182)

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