Set Trello Label depending on input entry

I’d like to use the Trello Add On to create cards for each entry placed. I would like to set different labels depending on what options the user selects throughout the form, so conditional labels I guess.

From the Trello Add On you can choose a label from the feed set up, is there anyway to code this on submission of the form?

Thank you!

You can add a contitional statement to the feed itself. So you could set that conditional field to be set to a value of the field / label you want to setup. And if that condition isn’t met: don’t add it to Trello. You could add multiple feeds and make them have different conditions, so they’ll be processed exactly how you’d want them too :slight_smile:

Thanks for your reply and suggestion. We’ve got quite a lot going on and multiple labels may need to be added on to a card depending on the selection of a drop down or radio buttons and the contents of a hidden field - so I don’t think this is going to work. Thanks again!

I don’t know but maybe you can use Zapier. :thinking:

I had thought of that too - we use Zapier quite a bit, but it would also need lots of conditional logic, probably too much.

I’m a little stumped as to why it can’t be done within WP with a function?

You can use the gform_trello_card filter to set the $card['labels'] property during submission as the feed is being processed.

1 Like

Perfect, thank you so much - I’m not sure why I didn’t find that before with all my searching!

I’ve got gform_trello_card working with the colour of the label in Trello, but in some instances we have more than one label for a particular colour. I therefore want to reference the specific label by its name - I tried changing the = ‘colour’ to = ‘labelname’ - but it didn’t work;

add_filter( 'gform_trello_card_43', 'add_labels', 10, 4 );
function add_labels( $card, $feed, $entry, $form ) {
	$delivery = $_POST['input_80'];
	if ($delivery == "Express Service") {
    	$card['labels'] = 'Priority Order';
	} 
 
    return $card;
}

Do you know if this is possible?

Hello - any thoughts on the label name rather than colour to update the label?

I recommend logging the $card to see what it contains so you can see what can be changed before it is returned. These two additional logging statements will help:

add_filter( 'gform_trello_card_43', 'add_labels', 10, 4 );
function add_labels( $card, $feed, $entry, $form ) {
	// see what the $card contains
	GFCommon::log_debug( __METHOD__ . '(): the CARD is currently => ' . print_r( $card, true ) );
	$delivery = $_POST['input_80'];
	if ($delivery == "Express Service") {
    	$card['labels'] = 'Priority Order';
	}
	GFCommon::log_debug( __METHOD__ . '(): the updated CARD is => ' . print_r( $card, true ) );
    return $card;
}

Be sure that Logging is enabled already on the Forms > Settings page, and then that logging of all messages for Trello and Gravity Forms are also active on the Forms > Settings > Logging page.

Thanks for this, I’ve added the logging code into the function and it isn’t returning much to be honest, there’s no information about the label;

2019-04-28 21:40:40.056968 - DEBUG --> add_labels(): the updated CARD is => 
Array
(
[name] => 1924807
[desc] => By: Martin Lucas
On: 28/04/2019
Via: Open Order Form

https://~~~~~~.com/base/wp-admin/admin.php?page=gf_entries&view=entry&id=45&lid=24807

Images
)

Did you see any issues with my original code? Are label names actually able to be references with the Trello Addon? Or are only colour names able to be used?

Sorry to chase this again - I couldn’t tell from the log if label names are able to be referenced and applied to a card via the add-on - or if only label colours work? I can make a support request if that’s easier?