ESP dSeries Workload Automation

 View Only
Expand all | Collapse all

How to set/use variable for Do not submit before field on job

  • 1.  How to set/use variable for Do not submit before field on job

    Posted Oct 18, 2022 05:49 PM
    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



  • 2.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 18, 2022 06:09 PM
    Well, unless I'm missing simething, you can just use:
    WOB.NEW_START_TIME = "now plus 15 minutes"

    And use %WOB.NEW_START_TIME in the Do not submit before field

    No need to use genTime.

    What other logic are you thinking of adding?




  • 3.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 19, 2022 04:26 AM
    Use "Now plus 15 minutes" For do not submit it before. It does not need any conversion


  • 4.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 20, 2022 04:11 AM

    Erik and Maddu,

    Thanks for the suggestion but I'm unfortunately having the same problem.  Here's what I have for the job in question:


    and


    When I simulate the event, it's clean and shows the following which is what I expect and want:

    Name: DOM_EVERY_03
    Job Type: UNIX
    Predecessors: DOM_FIRST_JOB
    Successors: DOM_EVERY_04
    Tag: %NWTIME now plus 15 minutes
    Run: DAILY
    Release Conditions:
    Type | Job Successor
    -----------------------------
    NORMAL | DOM_EVERY_04

    Anticipated Start Time: 13:53:05 Wed 19 Oct 2022
    Anticipated End Time: 13:53:05 Wed 19 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: WOB.NEW_START_TIME = "now plus 15 minutes";

    Exit Codes:
    Code | Interpretation
    ----------------------------
    8 | Success

    Do not submit before: 13:53:05 Wed 19 Oct 2022
    Agent name: UAT_AGT1
    Run a script: /apps/CA/Scripts/valueExitCode.sh
    Arguments to pass: 8

    But when I trigger the event, it doesn't run and instead generates the following error:

    Time dependencies for wob: DOM_EVERY_03 is invalid. The exception is %WOB.NEW_START_TIME.

    I feel like this is so close but I'm missing something that's causing the error.  Not sure what that is.  If you have ideas or other ways to do that, definitely interested.


    Erik,

    To answer your other question, we have other criteria that will determine how long the delay will be.  Once we get the variable to work for this, we'll add IF logic to handle that.  We've done that before so not concerned with that.  This is the first time we're using a variable to delay when the job runs so we wanted to keep it simple and get that working first.

    Thanks,
    Donna Domovic




  • 5.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 20, 2022 10:02 AM
    Looking closer, it looks like you're running the JavaScript at job run time. Try moving that to the other one, I think "event trigger time". Job run time is too late.




  • 6.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 20, 2022 04:11 AM
    Erik and Maddu,

    Thanks for the suggestion but I'm unfortunately having the same problem.  Here's what I have for the job in question:


    and



    When I simulate the event, it's clean and shows the following which is what I expect and want based on the simulation time:

    Name: DOM_EVERY_03
    Job Type: UNIX
    Predecessors: DOM_FIRST_JOB
    Successors: DOM_EVERY_04
    Tag: %NWTIME now plus 15 minutes
    Run: DAILY
    Release Conditions:
    Type | Job Successor
    -----------------------------
    NORMAL | DOM_EVERY_04

    Anticipated Start Time: 13:53:05 Wed 19 Oct 2022
    Anticipated End Time: 13:53:05 Wed 19 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: WOB.NEW_START_TIME = "now plus 15 minutes";

    Exit Codes:
    Code | Interpretation
    ----------------------------
    8 | Success

    Do not submit before: 13:53:05 Wed 19 Oct 2022
    Agent name: UAT_AGT1
    Run a script: /apps/CA/Scripts/valueExitCode.sh
    Arguments to pass: 8

    But when I trigger the event, it doesn't run and instead generates the following error:

    Time dependencies for wob: DOM_EVERY_03 is invalid. The exception is %WOB.NEW_START_TIME.

    I feel like this is so close but I'm missing something that's causing the error.  Not sure what that is.  If you have ideas or other ways to do this, definitely interested.


    Erik,

    To answer your other question, we have other criteria that will determine how long the delay will be.  Once we get the variable to work for this, we'll add IF logic to handle that.  We've done that before so not concerned with that.  This is the first time we're using a variable to delay when the job runs so we wanted to keep it simple and get that working first.

    Thanks,
    Donna Domovic




  • 7.  RE: How to set/use variable for Do not submit before field on job

    Broadcom Employee
    Posted Oct 21, 2022 01:49 AM
    Hi,

    Can you please put this javascript in the 'Event-trigger time' , it should work.
    I tried this and it worked. Can you please check.

    If it is still not working , you can raise a support ticket.
    Hope it helps!






  • 8.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 22, 2022 10:37 PM
    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



  • 9.  RE: How to set/use variable for Do not submit before field on job

    Broadcom Employee
    Posted Oct 24, 2022 04:16 AM
    Ok. In this case , can you use the field 'Delay submission when eligible by' field and see if it helps


    -Ravi Kiran


  • 10.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 24, 2022 08:29 AM
    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


  • 11.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 24, 2022 11:07 AM

    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 job
    successor_job_name = 'Job2';
    
    // Name of taks job holding successor back
    task_job_name = 'Task0';
    
    // I like to put the appl-gen spec into a variable ahead of time to keep the execCommand a little cleaner
    applgen = APPL._name + '.' + APPL._gen;
    
    // Build timespec based on logic
    if (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 job
    execCommand(successor_job_name, applgen, action);
    
    // All done; Force complete the task job
    execCommand(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
    ------------------------------



  • 12.  RE: How to set/use variable for Do not submit before field on job

    Posted Oct 24, 2022 03:54 PM
    Erik,

    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.

    Have a nice week!
    Donna Domovic