Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

updating card front badges with card custom field data

Matt Chambers December 1, 2023

Dear Sir/Madam,

 

I'm trying to update a card badge with custom field data. one field with the badge text, and the other for the color. My code isn't working and I was wondering if you could help, please?

The client.js file i'm using has a 'card-badges' function which i need to poll roughly once an hour. 5 secs is for debugging as is the dyunamic number. this is the code:

 

'card-badges': function(t, options) {
// IDs for custom fields
const STATUS_CUSTOM_FIELD_ID = '65056bd886be3b322d48606c';
const COLOR_CUSTOM_FIELD_ID = '655a1720b25d44ce1e297949';

return Promise.all([

t.get('card', 'shared', STATUS_CUSTOM_FIELD_ID, 'Status: N/A'),
t.get('card', 'shared', COLOR_CUSTOM_FIELD_ID, 'blue'),
]).then(function(results) {
// debug: console.log('Card Badges Results:', results);
console.log('Card Badges Results:', results); // Debug: Results from custom fields
// results[0] is the value from STATUS_CUSTOM_FIELD_ID
// results[1] is the value from COLOR_CUSTOM_FIELD_ID

return [{
dynamic: function() {
// Construct the badge object
return {
text: "Dynamic " + (Math.random() * 100).toFixed(0).toString(), // Text from the first custom field
color: results[1], // Color from the second custom field
refresh: 5 // Refresh the badge every 10 seconds
// icon: optional icon URL
};
}
}];
}).catch(function(error) {
console.error('Card Badges Error:', error); // Debug: Error in fetch or processing
});
},
####################
this is a function from the plugin which does work
Example logic to update statusBadge
function updateStatusBadge(t) {
const FEDEX_CUSTOM_FIELD_ID = '65056bd886be3b322d48606c';
const SHIPPING_REF_CUSTOM_FIELD_ID = '655a1720b25d44ce1e297949';

Promise.all([
t.get('card', 'shared', FEDEX_CUSTOM_FIELD_ID, 'No Tracking Data'),
t.get('card', 'shared', SHIPPING_REF_CUSTOM_FIELD_ID, 'grey')
]).then(function(results) {
// Update statusBadge with new values
t.set('card', 'shared', 'statusBadge', { text: results[0], color: results[1] });
});
}
I'm starting to pull my hair out. Please help if you can!
Many thanks,
Matt

1 answer

0 votes
Oliver S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 3, 2023

Hi Matt, hope you're doing well! :)

Sounds like a super frustrating problem.

Given this is a question more geared towards Trello development, I'd definitely recommend reposting over in our Trello Developer Community forums: https://community.developer.atlassian.com/c/trello/42

You'll be more likely to get some eyes on it there, and an audience better placed to assist.

Hope this helps! (and happy for any devs to chime in here in the meantime if they see this in the meantime).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events