Capture Checklist percentage complete as a custom field for Butler
Asked by Mike Moran:

Is there a way that I can capture the percentage complete (currently 29% as shown below) within a custom field which can then be displayed on the card front and used in Butler reports? The value would need to dynamically update as checklist items were ticked off.

![Annotation 2020-08-21 111758.jfif](https://community.atlassian.com/t5/image/serverpage/image-id/107418i4AF23F5C18639926/image-dimensions/394x137?v=v2 "Annotation 2020-08-21 111758.jfif")

I have 164 cards, each with a milestone checklist and I have been asked to report the percentage complete for each Card.


Answers:
author: Iain Dooley
body: [@Mike Moran](/t5/user/viewprofilepage/user-id/4058594) this Trellinator function would do it:

<https://gist.github.com/iaindooley/884bd51ca75f3278b41d39c7ca1bf40b>

You can read more about Trellinator here:

<https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Introducing-Trellinator-Automate-Trello-with-Google-Apps-Script/ba-p/925271>

comments: author: milynnus
body: [@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112) I read in the gist that your have new Notification.... does it mean that this function behaves like a webhook and it gets triggered and the update the CF ? So far, my new Butler add on can be embedded in Butler rules and commands but cannot sit in the shadow waiting for some event to be triggered.


author: Iain Dooley
body: [@milynnus](/t5/user/viewprofilepage/user-id/3947182) yep Trellinator adds a webhook to the member object itself and when you first initialise it, to every board the Trellinator user is a member of. Then, whenever the member is removed from or added to a board, the webhooks are updated. Whenever a notification is received, any function installed for that board (you can install a function for one board, a group of boards, or globally) is given the opportunity to deal with the notification.


author: milynnus
body: [@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112) Thanks for sharing. I know that for webhook you need to associate with a token which is member specific. Is that what you meant by "add webhook to member object" ? I also know that there is a callback URL for webhook, is this the endpoint and where the function sits? In your case, where is this endpoint 'hosted' ?  
I am trying to imagine how I can do it, perhaps like https:123455.wayscript.io/?user=something\&func=abc .... can start to see the complexity. Your answers to above will be very helpful. Thanks in advance. Learning from the guru.


author: Iain Dooley
body: [@milynnus](/t5/user/viewprofilepage/user-id/3947182)
> I know that for webhook you need to associate with a token which is member specific. Is that what you meant by "add webhook to member object"?

You can register a webhook on any model: a card, a list, a board, a member. When anything in that model changes, you will receive a notification. I use a member webhook on the Trellinator user itself in order to detect when the user is added to or removed from a board, and I use board webhooks for everything else. When the user is added as a member to a board, a webhook is registered for that board, when the user is removed from a board, the webhook is removed also.
> I also know that there is a callback URL for webhook, is this the endpoint and where the function sits? In your case, where is this endpoint 'hosted'?

Ultimately, the endpoint is just the published web app URL of the Google Apps Script project that is attached to the Trellinator spreadsheet. However, because Trello overwhelms Apps Script, I have a "buffer" that I let people use for free which sits in the middle, accepts all notifications and forwards them on. This buffer is open source, though, so people can set up their own if they'd prefer. See "A Note about Privacy" here <https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Introducing-Trellinator-Automate-Trello-with-Google-Apps-Script/ba-p/925271>
>
> I am trying to imagine how I can do it, perhaps like https:123455.wayscript.io/?user=something\&func=abc .... can start to see the complexity. Your answers to above will be very helpful. Thanks in advance. Learning from the guru.

All the stuff that handles the "framework" side of things (rather than the API libraries) is in this repo:

<https://github.com/iaindooley/trellinator>

The webhook registration begins here:

<https://github.com/iaindooley/trellinator/blob/master/Accessible.js#L8>

You can download that repo to see how the webhook registration and notification handling works although it's specific to running under Apps Script so I'm not sure how useful it will be in doing the same thing under wayscript.


author: milynnus
body: [@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112) Thank you.

I managed create a webhook using idModel = member_id and it triggered the endpoint as specified. I converted the the raw data from json to a Struct which has model and action as the top most keys. This is vey similar to the trigger outputs that I get from using Wayscript triggers.

The process that allows me to execute Superhero Power module from Butler can now be applied to the action and the associated variables from the dictionary.

Next I have to figure out how to record the subscription for the equivalent of your webhook functions. Currently thinking of using card links from the registry to the code repository. It does mean all the applicable modules for that action type will be triggered.

py-trello and Wayscript certainly helped a lot to get me here.

Now I have to add the webhook registration for all users of Superhero Power so that they can use it from a Butler Http Request and also from the webhook.

Thanks again for your help. They key insight has been the use of member as the idModel for the Webhook and then register other webhook idModels depending on the function / module.

[@Mike Moran](/t5/user/viewprofilepage/user-id/4058594) sorry again for hijacking your post. This forum does not have the equivalent of a chat channel.


author: Mike Moran
body: [@milynnus](/t5/user/viewprofilepage/user-id/3947182) no problem, all good!


author: milynnus
body: Thanks [@Mike Moran](/t5/user/viewprofilepage/user-id/4058594)

[@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112) I completed it. Tested with the POC calculation. Design is able handle idModel for board, list, card and member on 4 separate endpoints by using query parameters. Great learning. More testing to handle exceptions. Thanks for programming tip.


author: milynnus
body: [@Mike Moran](/t5/user/viewprofilepage/user-id/4058594) I lost my longer version of this reply so here's the gist of it.

(1) the % are not stored on the card object. I am not aware of any way to intercept Trello as it computes and updates the countCheckItem such that you can keep it in a CF

(2) there are 4 actions for Webhooks fr items e.g. updateCheckItemStateOnCard. You probably have to use this route if you want to do it yourself

(3) I read the Board Export now handles checklist. You might want to export your checklist and work with spreadsheets for your reporting. I have not tried it .