Auto generate time cards for specific tables

Community Alums
Not applicable

The scheduled job called Auto Generate Time Cards uses a script include called TimeCardGenerator. What is interesting is that the script include has the ability to restrict which tables can generate time cards but there is no way to specify that in the scheduled job. I can update the script include and hardcode the tables I care about but I wanted to see if maybe I am missing something. 

 

The generateFromConfig call doesn't allow you to specify the tables yet the generate function does.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I ended up creating a property and then modified the script include.

ChrisDoernbrac_0-1700156682584.pngChrisDoernbrac_1-1700156691403.png

 

View solution in original post

4 REPLIES 4

-O-
Kilo Patron
Kilo Patron

It should work to create an ad-hoc class out of the OOB one, overwrite the relevant member method - updating the Scheduled Job code to:

 

 

 

;
(function () {
	var TimeCardGeneratorOrg = Class.create();

	TimeCardGeneratorOrg.prototype = Object.extendsObject(TimeCardGenerator, {

		'U_ALLOWED_TABLES': ['<table name 1>', '<table name 2>'],

		'_timeCardAllowedForTask': function (task) {
			return TimeCardGenerator.prototype
				._timeCardAllowedForTask.call(this, task, this.U_ALLOWED_TABLES);
		},

	});

	new TimeCardGeneratorOrg().generateFromConfig(TimeCardConstants.CURRENT_WEEK);
})();

 

 

 

Of course you would use proper, real class names in place of <table name 1> and <table name 2>.

Even better stored in a property perhaps.

What this does is to "inject" the list of "allowed" tables mid-course.

 

Community Alums
Not applicable

Yeah, was hoping that perhaps I overlooked something in the OOB script include. It's odd to me that they built in this ability but didn't provide a way to use. I hate to update OOB code but perhaps I will have to.

You could just de-activate the OOB scheduled job and create a new one in place.
Also I'm sure the functionality is used somewhere.

Though I suppose the main filter they expect will be used, is marking the top task as being one for which time cards are generated or not.

Community Alums
Not applicable

I ended up creating a property and then modified the script include.

ChrisDoernbrac_0-1700156682584.pngChrisDoernbrac_1-1700156691403.png