{
  "Name": "ReportWORQ - Add Queued Job For Workspace Sample 1.3",
  "HasSecurityAccess": false,
  "PrologProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****\r\n\r\n#==========================================================================================\r\n# PROCESS\r\n# ReportWORQ - Add Queued Job Sample\r\n#==========================================================================================\r\n# © QueBIT - ReportWORQ for Planning Analytics/TM1\r\n# Dec 28, 2022\r\n#\r\n# PURPOSE: \r\n#  \r\n#     THIS PROCESS CAN BE USED TO TRIGGER THE \r\n#               EXECUTION OF A REPORTWORQ JOB\r\n#             WHEN THE REPORTWORQ SERVICE IS \r\n#    CONFIGURED TO MONITOR THE JOB QUEUE CUBE\r\n#\r\n#         THE PROCESS CREATES A AN ENTRY IN THE \r\n#       }REPORTWORQ__QUEUEDJOBS CUBE WHICH\r\n#       IS MONITORED BY THE REPORTWORQ SERVER\r\n#\r\n# PARAMETERS: \r\n# pServer (String):TM1 Server Name.\r\n# pJobDefinition (String): ReportWORQ Job Definition.\r\n# pNotificationEmail (String): Email address to send notifications.\r\n# pReadyToRun (String): A flag to indicate that the job is ready for execution. 1 = Ready; 0 = Not Ready\r\n# pWorkspaceName (String): The name of the ReportWORQ workspace for execution.\r\n#\r\n# MODIFICATION HISTORY:\r\n# Version 1.0: initial release as part of ReportWORQ 4.3\r\n# Version 1.1: updates with better error-checking in ReportWORQ 5\r\n# Version 1.2: added support for ReportWORQ workspaces\r\n# Version 1.3: updates for polling empty cube views\r\n#==========================================================================================\r\n\r\n\r\n#Generates a unique ID for the Job Request\r\nvJobId = STR(NOW, 5, 15);\r\nsleep(1000);\r\n\r\ncJobIdDimension = '}ReportWORQ__Queued Job Id';\r\ncJobIdTotalElement = 'Total Id';\r\ncJobQueueCube = '}ReportWORQ__QueuedJobs';\r\n\r\n# Check that ReportWORQ Job ID + Queue Cube Exist\r\n\r\nIF ( DIMENSIONEXISTS( cJobIdDimension ) = 0 );\r\n  LOGOUTPUT( 'ERROR', 'Cannot find the required ReportWORQ job Queue dimension: ' | cJobIdDimension );\r\n  PROCESSERROR;\r\nENDIF;\r\n\r\nIF ( CUBEEXISTS ( cJobQueueCube ) = 0 );\r\n  LOGOUTPUT( 'ERROR', 'Cannot find the required ReportWORQ job Queue cube: ' | cJobQueueCube );\r\n  PROCESSERROR;\r\nENDIF;\r\n\r\nIF( DIMENSIONELEMENTEXISTS( cJobIdDimension, cJobIdTotalElement ) = 0 );\r\n  DimensionElementInsertDirect(cJobIdDimension, '', cJobIdTotalElement , 'C');\r\nENDIF;\r\n\r\n#Add the unique ID to the Job ID dimension\r\nDimensionElementInsertDirect(cJobIdDimension, '', vJobId , 'N');\r\nDimensionElementComponentAdd(cJobIdDimension, cJobIdTotalElement, vJobId, 1);\r\n\r\n#Add the Servers which will be used to execute the job\r\nCellPutS(pServer, cJobQueueCube, vJobId, 'Servers');\r\n\r\n#Add the semi colon separated list of emails which should be notified on job completion\r\nCellPutS(pNotificationEmail, cJobQueueCube, vJobId, 'Notification List');\r\n\r\n#Add the Job definition steps and parameters\r\nCellPutS(pJobDefinition, cJobQueueCube, vJobId, 'Parameters');\r\n\r\n#Set the ReadyToRun flag to 1 to signal the ReportWORQ server that the job is ready for execution\r\nCellPutN(pReadyToRun, cJobQueueCube, vJobId, 'ReadyToRun');\r\n\r\n#Add the workspace that the job will run for. Omitting the workspace name will run the job for the default workspace\r\nCellPutS(pWorkspaceName, cJobQueueCube, vJobId, 'Workspace Name');\r\n\r\n",
  "MetadataProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
  "DataProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
  "EpilogProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
  "Parameters": [
    {
      "Name": "pServer",
      "Prompt": "TM1 Server Name",
      "Value": "Server Name",
      "Type": "String"
    },
    {
      "Name": "pJobDefinition",
      "Prompt": "ReportWORQ Job Definition",
      "Value": "Job Definition",
      "Type": "String"
    },
    {
      "Name": "pNotificationEmail",
      "Prompt": "Email address to send notification",
      "Value": "noreply@email.com",
      "Type": "String"
    },
    {
      "Name": "pReadyToRun",
      "Prompt": "Begin Running Job",
      "Value": 1,
      "Type": "Numeric"
    },
    {
      "Name": "pWorkspaceName",
      "Prompt": "ReportWORQ workspace to run job on",
      "Value": "Default Workspace",
      "Type": "String"
    }
  ]
}