Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • A Job Resource can hold any number of variables. Such variables are available for JVM Jobs from arguments and for Shell Jobs from environment variables.
  • A Job Resource environment variable is automatically available as a local environment variable to a Shell Job.
    • If a Workflow is assigned the Job Resource then any Shell Jobs in the workflow are propagated the environment variables of the Job Resource.
    • If a Job is assigned the Job Resource then this job can use the propagated environment variables of the Job Resource.
  • As a result you can add a variable such as BusinessDate to an existing or to a new Job Resource and assign the Job Resource to a Workflow to make it available to all jobs or assign it to an individual Job to limit the scope.

Download (.json upload)pdBusinessDate.jobresource.json

...

Job for Unix

Download for Unix (.json upload)pduVariableBusinessDateGet.workflow.json

...

Job for Windows

Download for Windows (.json upload)pdwVariableBusinessDateGet.workflow.json

...

  • Users can create a workflow with a single job that updates the businessDate variable.
  • The workflow is triggered by an order from JS7 - Schedules to switch the business date for example at midnight in the respective time zone and for specific days.

Job for Unix

Download (.json upload)pduVariableBusinessDateSet.workflow.json

...

Code Block
languagepowershell
titlePowerShell implementation to update the business date with a Job Resource variable
linenumberstrue
#!/usr/bin/env pwsh

# Adjust the path to your Job Resource
$jobResourcePath = '/ProductDemo/Variables/pdBusinessDate'

# Consider to use the appropriate URL that matches host and port of the JOC Cockpit instance
$url = "http://joc-2-0-primary:4446"

# Consider to store credentials with a PowerShell profile or with a credential store or to use certificate based authentication as an alternative to user/password
$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "root", ( "root" | ConvertTo-SecureString -AsPlainText -Force) )


Import-Module JS7
Connect-JS7 -Url $url -id $env:CONTROLLER_ID -Credentials $credentials

$jobResource = Get-JS7InventoryItem -Path $jobResourcePath -Type JOBRESOURCE

    if ( $jobResource.arguments.BusinessDate )
    {
        # update the business date
        $jobResource.arguments.BusinessDate = (Get-Date -Format "yyyy-MM-dd")
    } else {
        # add a business date variable to the Job Resource
        $jobResource.arguments | Add-Member -Membertype NoteProperty -Name BusinessDate -Value (Get-Date -Format "yyyy-MM-dd")
    }

# Update and deploy the Job Resource
Set-JS7InventoryItem -Path $jobResourcePath -Type JOBRESOURCE -Object $jobResource
Publish-JS7DeployableItem -Path $jobResourcePath -Type JOBRESOURCE -ControllerID $env:CONTROLLER_ID

Disconnect-JS7

Job for Windows

Download (.json upload)pdwVariableBusinessDateSet.workflow.json

...

To automate the execution of the JS7 workflow in order to update the business date users can create JS7 - Schedules that generate orders for execution at a given point in time.

Download (.json upload)pdsVariableBusinessDateSet.schedule.json

...