Thanks so much for sticking with this, testing, and all the detail. What you show is similar to what we have in a few other schedules. We were hoping we could consolidate and move that logic to the job itself but, since that's not possible at least not right now, we'll go ahead and use similar logic for this.
Sorry if I wasted your and other people's time. There's so many ways to do things, we were hoping we were simply missing a secret trick to make it work.
Truly appreciate everything you and others have done with examples, suggestions, etc.
Original Message:
Sent: Oct 24, 2022 11:07 AM
From: Erik Schminke
Subject: How to set/use variable for Do not submit before field on job
I think I understand the problem now, and have had some time to think about and experiment with it.
Essentially you want a "Delay submission when eligible by" that you can change while the application is processing.. but ESP DE doesn't give you ability to do that-- not that I can see. Running JavaScript "At event time" is too early, and "At job run time" is too late to set a time relative to the completion of a predecessor.
To make this work, I had to use a the JavaScript "execCommand()" function with an action of "ACTION RESET EarlySub('')". And to make that run, I had to use a combination of JavaScript, Alert, an "On Complete" Alert notification, and a Task Job.
What I did was setup a job flow like this:
The Task job is necessary to ensure your command is executed before the successor job becomes eligible to run. Once your job becomes eligible to run, you can't make this change.
Here is the JavaScript code. I added this into the JavaScript repository:
// Name of your successor jobsuccessor_job_name = 'Job2';// Name of taks job holding successor backtask_job_name = 'Task0';// I like to put the appl-gen spec into a variable ahead of time to keep the execCommand a little cleanerapplgen = APPL._name + '.' + APPL._gen;// Build timespec based on logicif (APPL._ADOWNUM == 1) { // Sunday timespec = 'NOW PLUS 10 MINUTES';}if (APPL._ADOWNUM == 2) { // Monday timespec = 'NOW PLUS 15 MINUTES';}if (APPL._ADOWNUM == 3) { // Tuesday timespec = 'NOW PLUS 15 MINUTES';}if (APPL._ADOWNUM == 4) { // Wednesday timespec = 'NOW PLUS 30 MINUTES';}if (APPL._ADOWNUM == 5) { // Thursday timespec = 'NOW PLUS 30 MINUTES';}if (APPL._ADOWNUM == 6) { // Friday timespec = 'NOW PLUS 30 MINUTES';}if (APPL._ADOWNUM == 7) { // Saturday timespec = 'NOW PLUS 10 MINUTES';}// Build action command for execCommand()action = 'ACTION RESET Earlysub("' + timespec + '")';// Execute action command against sucessor jobexecCommand(successor_job_name, applgen, action);// All done; Force complete the task jobexecCommand(task_job_name, applgen, 'ACTION COMPLETE');
Next, create an alert that executes the JavaScript from repository:
Next, set up an notification on your predecessor job to fire the Alert you created "On Complete".
That should be all you need. It's a bit fiddly, but if everything goes right, you should find that your successor job start time is the X minutes after end time of your predecessor.
------------------------------
Erik Schminke
Systems Engineer
ITS Tech Services
Hormel Foods Corporation
Original Message:
Sent: Oct 24, 2022 08:29 AM
From: DONNA DOMOVIC
Subject: How to set/use variable for Do not submit before field on job
Ravi,
That does work where we want a set delay but in this case we want the delay to vary based on certain criteria. For example, if the delay was based on day of the week (which it isn't), we would want a 15 minute delay if it's Monday or Tuesday, a 30 minute delay if it's Wednesday, Thursday, or Friday, and a 10 minute delay if it's Saturday or Sunday.
Thanks,
Donna Domovic
Original Message:
Sent: Oct 24, 2022 04:15 AM
From: Ravi Kiran Kunduri
Subject: How to set/use variable for Do not submit before field on job
Ok. In this case , can you use the field 'Delay submission when eligible by' field and see if it helps
-Ravi Kiran
Original Message:
Sent: Oct 22, 2022 10:36 PM
From: DONNA DOMOVIC
Subject: How to set/use variable for Do not submit before field on job
Hello,
Thanks for all the input. I did move the code to the At Trigger Time section and can then trigger the event but it doesn't give me what we want. The delay is based on when the event triggered not when all predecessors complete as we want. Here's what I mean:
The event is triggered at 10:18 am. The DOM_FIRST_JOB runs and competes at 10:20 am.
DOM_FIRST_JOB releases DOM_EVERY_03 which is the job that has the variable delay. I would expect this to wait 15 minutes and run at 10:35 am but it instead runs at 10:33 am CT which is 15 minutes after the event was triggered rather than 15 minutes after all predecessors completed and it could run:
This is the reason we started out putting in the At Run Time section on the Java Script tab thinking then the variable would be set at the time the job should run but that's obviously not allowed.
If anyone has other ideas on how to accomplish this within the job definition, definitely interested in hearing those. I will try to call into the office hours that were mentioned but if we can't find a way to do this within the job definition, we may need to go a different route and use a link to set the delay rather than trying to do it in the job definition itself.
Thanks,
Donna Domovic
Original Message:
Sent: Oct 18, 2022 05:15 PM
From: DONNA DOMOVIC
Subject: How to set/use variable for Do not submit before field on job
Hello,
We have a situation where we want to delay the start time of a job based on certain criteria. Since the duration of the delay will vary, we were thinking of using a JavaScript at the job level to set a variable the specify that variable for the Do Not Submit Before field but we've run into some issues.
Below is what we coded for the job in the JavaScript section. We're starting simple then will add additional if logic to vary the delay based on criteria.
And below is what we specified for the Don't Submit Before field for the same job. All fields on the Time Dependencies tab are blank.
When we simulate the event, it appears to work as shown below for the job in question:
Name: DOM_EVERY_03
Job Type: UNIX
Predecessors: DOM_FIRST_JOB
Successors: DOM_EVERY_04
Tag: 16.01.40 16:01
Run: DAILY
Release Conditions:
Type | Job Successor
-----------------------------
NORMAL | DOM_EVERY_04
Anticipated Start Time: 16:01:00 Tue 18 Oct 2022
Anticipated End Time: 16:01:00 Tue 18 Oct 2022
Execution time: 0 mins
Life time: 0 mins
Auto-Resubmit failed job: RetryCount(0) RetryInterval(0)
JavaScript to run at job run time: genTime('NW','now plus 15 minutes');
WOB.NEW_START_TIME=NWHH+':'+NWMN;
Exit Codes:
Code | Interpretation
----------------------------
8 | Success
Do not submit before: 16:01:00 Tue 18 Oct 2022
Agent name: UAT_AGT1
Run a script: /apps/CA/Scripts/valueExitCode.sh
Arguments to pass: 8
But when we trigger it, it fail to trigger and instead gets the following error:
Time dependencies for wob: DOM_EVERY_03 is invalid. The exception is %WOB.NEW_START_TIME.
Has anyone done anything like this or know why it seems to simulate ok but has issues when it's triggered?
Thanks,
Donna Domovic