Jump to content

Script Filter Noob Questions

Recommended Posts



I'm trying to move beyond simple Keyword inputs and List Filters and set up my first Script Filter. I'm having a hard time though to get started. I'm trying to write the script in JS because that's the language I know best. First of all, I have no idea how to access variables I saved in the steps before the Script Filter. Basically I'm trying to create a simple day select. In the 2 previous steps I save a year and a day variable. In the script filter I want to return a list of 28 to 31 items (title: 1-31, arg: 01-31), depending on the year and month selection.


In the script I was planning to use a simple function to get the number of days in a month:

function daysInMonth(month,year) {
    return new Date(year, month, 0).getDate();

That's as far as I got though. I don't know how to pass the month and year variable (that I entered earlier) into the function. And then I don't know how to create the list of items properly and display them.


Hope somebody can help guide into the right direction.



Link to comment

@macg Welcome to the forum. Before asking workflow-related questions, please fill in your Powerpack email address in your forum profile. This is only visible to admins (Andrew and I) and allows us to confirm your Powerpack user status :)



Link to comment

@dfay I had checked out that post before and tried the JS solution but got errors all the time. Turned out I was using the wrong variable names. Thought I was using the wrong solution all the time =)

@deanishe Thanks, that made it pretty clear what had to be done

@Vero I updated my information


Thanks a lot for the quick help to all. Here's what I did in the end for anybody who's interested:



function daysInMonth(month,year) {
	return new Date(year, month, 0).getDate();

function run(argv) {
	var items = [];
	var year = $.getenv('receipt_year');
	var month = $.getenv('receipt_month');
	var days = daysInMonth(month, year);
	for (let i = 1; i <= days; i++) {
		items.push({title: i.toString(), arg: ('0' + i).slice(-2)});
	items = items.filter( item => item.title.indexOf(argv) !== -1 );
	return JSON.stringify({items: items});


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...