Can you suggest how schedule a Process?

Certified Lead Developer

Hi, 

I'm trying to schedule a process using start node. Below is the screen shot.

If I use pp!timezone I'm getting below.

Problem: An error has occurred in evaluation of an expression for a Start Event.
Details: ERROR:EVAL:@reason=Domain pp is valid only in execution
Recommended Action: Examine and correct the expressions on the Start Event's Event Properties.

If I'm using pm!timezone I'm getting a problem. The clients are at US and I'm working from India. If schedule 1 AM it is not executing correctly.

I want to schedule a process at 1 AM at US time zone.

How to schedule it. Please suggest.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I did a but of research and came up with a nice idea.

    The plugin "Content Tools" provides a function to retrieve some details about a process model. Including the timestamp of the last publish.

    You can add an initial XOR node to check whether that date is more than 5 minutes in the past. This way, you skip the first process initiation.

    a!localVariables(
      local!details: split(getprocessmodeldetailsbyuuid(ri!uuid), ", "),
      local!lmo: index(
        local!details,
        a!forEach(
          items: local!details,
          expression: if(
            find("Last Modified on", fv!item),
            fv!index,
            {}
          )
        ),
        ""
      ),
      local!splitLmo: split(local!lmo, ": "),
      if(
        count(local!splitLmo) <> 2,
        error("Cannot extract last modified date: " & local!details),
        todatetime(local!splitLmo[2])
      )
    )

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    I would literally pay the author(s) of Content Tools $20 in cash right now if they'd make these functions return a Map / Dictionary / JSON string instead of whatever stupid, arbitrary, unorganized, cobbled-together values they currently return Face palm

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    FWIW, I've already done the arduous task (in the past) of parsing the output of this plugin rule into a usable map output.  Pasting here.  Note that different plug-in versions may require tweaks of this code since it can break if items are switched in their return order, or if they mess with the output datetime format again (though luckily the current version is immediately useful, so hopefully they won't break it again).

    This should be saved as an expression rule i.e. "UTIL_MapProcessModelDetailsByUUID" or whatever.

    a!localVariables(
      local!rawText: if(
        a!isNullOrEmpty(ri!uuid),
        " ",
        getprocessmodeldetailsbyuuid(ri!uuid)
      ),
    
      local!type: index(extract(local!rawText, "Type: ", "," ), 1, null()),
      local!nameList: trim( split( extract( local!rawText, "Name: [", "]" ), "," )),
      local!nameArray: a!forEach(
        local!nameList,
        a!localVariables(
          local!pieces: split(fv!item, "="),
          a!map(
            locale: local!pieces[1],
            name: local!pieces[2]
          )
        )
      ),
      local!id: index(extract( local!rawText, "Id:", ", UUID" ), 1, null()),
      local!uuid: index(extract( local!rawText, "UUID:", ", Creator" ), 1, null()),
      local!creator: index(extract( local!rawText, "Creator: ", ", Last" ), 1, null()),
      local!lastModifiedBy: index(extract( local!rawText, "Last Modified by: ", ", Parent"), 1, null()),
      local!parent: index(extract( local!rawText, "Parent: ", ", Parent Id:" ), 1, null()),
      local!parentId: tointeger( index(extract( local!rawText, "Parent Id: ", "," ), 1, null())),
      local!location: index(extract( local!rawText, "Location: ", ", Is" ), 1, null()),
      local!isPublic: index(extract( local!rawText, "IsPublic: ", ", Created" ) = "true", 1, null()),
      local!createdOn: index(extract( local!rawText, "Created on: ", ", Last" ), 1, null()),
      local!lastModifiedOn: index(extract( local!rawText, "Last Modified on: ", ", Number of" ), 1, null()),
      local!numVersions: index(extract(local!rawText & "-END-", "Number of Versions: ", "-END-" ), 1, null()),
    
      a!map(
        type: local!type,
        primaryName: property(index(local!nameArray, 1, null()), "name", null()),
        nameArray: local!nameArray,
        id: local!id,
        uuid: local!uuid,
        creator: local!creator,
        lastModifiedBy: local!lastModifiedBy,
        parent: local!parent,
        parentId: local!parentId,
        location: local!location,
        isPublic: local!isPublic,
        createdOn: todatetime(local!createdOn),
        lastModifiedOn: todatetime(local!lastModifiedOn),
        numVersions: local!numVersions,
        
        /*rawText: local!rawText*/
        /* uncomment the above line as-needed for debugging purposes */
      )
    )
    
    /* developed by: Mike Schmitt */

  • 0
    Certified Lead Developer

    The pattern I most commonly settle on for this is to allow the process to be launched anyway (using the basic setup you have pictured already), then immediately after the start node, have an XOR node that checks whether the instance's start time matches the desired launch time, and if not, exit immediately.