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

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

Smarth bot 1 October 3, 2020

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 4, 2020

@Smarth bot 1 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!

Smarth bot 1 October 16, 2020

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
AUG Leaders

Atlassian Community Events