Loading
SNOW AP - WAIT on Time (Delay)

Dear Community,

 

Due to a customer’s request, I’m actually implementing a workflow which should wait on a defined time for continuing - a delayed activity.

My simple idea was a follows:

1. Do things.

2. Wait on delay

3. Do things.

 

1. For any order placed by the user, a timestamp text file will be created with a fixed time value, which the user defines.

2.The scheduled task is initiated every 10 minutes, which proofs the defined delay and starts the activity or the Powershell if the defined time value (delay) has been reached.

3. It executes an activity afterwards.

As a downside, I cannot implement this step into a workflow, which would be great.

 

Alternatively, I could solve the delay into one activity inside of a workflow. But I guess, it would not be so wise to wait inside an executed Powershell for a periode of time.

 

Do you have any best practice solutions for a simple delay?

 

Thanks in advance.

Martin


  • Community Manager (Flexera Software)

    Hey! Use this. Take the code and save as sleep.ps1 (or whatever you like). Add it to AP as a new activity and use it in your workflow.  When this activity runs it will first execute and then re-schedule itself to the configured time. You can either send in a datetime string to the $waituntil OR send a number in the $sleepMinutes parameter. It will not run while waiting so no resources are being taken. sleep.ps1 param (   [ parameter ( Mandatory= $true ) ]   [ string ] $baseUrl,   [ int ] $sleepMinutes,   [ string ] $waitUntil   )     $requestActivityId = $SnowPowershellParamter_activityId     if ( - not ( Get- Module - Name IgapCore) )   {       Import- Module 'C:\Program Files\Snow Software\Snow Automation Platform\CoreScripts\IgapCore.psm1'   }     Write- Output "Getting information about request activity $requestActivityId..."   $thisRequsetActivity = ( Invoke- APRestMethod - uri "$baseUrl/API/RequestActivity/$requestActivityId/RequestParameter?expand=RequestActivity" - method Get) . records[ 0 ] . requestActivity     if ( - not $waitUntil - and $sleepMinutes)   {       $waitUntil = [ datetime] : : Now. AddMinutes ( $sleepMinutes)   }     if ( $waitUntil)   {       if ( [ datetime] $waitUntil - gt [ datetime] : : Now)       {           if ( - not $thisRequsetActivity. waitUntil)           {               $thisRequsetActivity | Add- Member - MemberType NoteProperty - Name "waitUntil" - Value $waitUntil           }           else           {               $thisRequsetActivity. waitUntil = $waitUntil           }           $thisRequsetActivity. status = 0                 $body = ConvertTo- Json - InputObject $thisRequsetActivity             Invoke- APRestMethod - uri "$baseUrl/API/RequestActivity/$requestActivityId" - body $body - method Put           Skip- UpdateActivityResult       }       else       {           Write- Output "Sleep done, workflow will continue"       }   }   else   {       Write- Error "No wait until or sleep minutes values passed - cannot put the activity to sleep"   }       ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍
    Expand Post
    • Hey Joakim, that worked perfectly. THX a lot

Related  Product Forums


                     → Flexera One



                      → Snow Atlas



                      → FlexNet Manager



                      → Snow License Manager



                       → App Broker


       Need help finding an answer?


        Ask a Question →


Loading
SNOW AP - WAIT on Time (Delay)