Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Moving first "x" cards from a specific list using trellinator

Hi, I am new to trellinator framework. I am trying to add a functionaity to my board.

I want a user different than trellinator to post a comment. This comment will be a number that we can call "x".

This comment will trigger a function that will copy the first "x" cards from list "A" to list "B".

So the use case will be...

1. User A post a comment with number "2".

2. The first "2" cards from list "A" will be copy to list "B"

 

Here I have some code I have been able to build.

function copyOnComment(notification)
{
var notif = new Notification(notification);
var A = new Trellinator().board("Board A").findOrCreateList("A");
var B = new Trellinator().board("Board B").findOrCreateList("B");
var x = 0;

if(notif.member().notTrellinator())
{
  notif.board().list("A").cards().each(function(card)
  {

     x = x+1;
     card.copyToList(B,1);

    if(x>1)
       exit();
  });
 }
}

 

Right now the copyToList function is not working. If I change the copyToList for a "post comment" it will stay on a loop and post comments on first two card list infinitely. 

 

Any ideas on how to make this work?

1 answer

1 accepted

0 votes
Answer accepted
Iain Dooley Community Leader Oct 04, 2020

@Carlos Pozos Ochoa great to see you're getting some use out of Trellinator :)

Looks like exit(); doesn't exist in Google Apps Script, maybe upgrade your project to the V8 runtime? I haven't tested Trellinator extensively using the V8 runtime but I do have a couple of projects running on it and it seems to Just Work(TM) for the most part.

Here is your code rewritten without the use of exit():

https://gist.github.com/iaindooley/82e600603fa363ab41257f55818e47c4

Also note that when this failed, the reason it was "looping" was because when an exception is thrown that isn't an InvalidDataException or an InvalidActionException it will store the notification in the ExecutionQueue tab and retry it every 10 minutes (this is because sometimes it's an API error, and it's better for something to happen twice than not at all).

When debugging this, you can copy the JSON from the ExecutionQueue and do this:

var obj = {JSON GOES HERE};

functionName(obj.parameters);

If you execute that directly from the script editor then you can see more clearly what exception gets thrown. You can also see the exceptions logged in InfoLog but sometimes that moves pretty fast so I find the above an easier way to drill down into what's causing the problem.

Happy automating!

Thank you very much for the info, very useful. Help me a lot to implement this functionality.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Trello

📹 What is Trello?

Hello Community!  My name is Brittany Joiner and I am a Trello enthusiast and Atlassian Community Leader. I'll be sharing with you a series of videos with my top tips on how to best use Trello...

836 views 14 30
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you