This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Automatic Calculated Value VBScript every day

Hi,

We have a situation where I need an Automatic Value to be inserted into the property every day. Basically, we created an entire Employee Car system that tracks everything regarding company cars. The property that we need to be updated every day is today's date as seen on the screenshot:

 

We have a VBScript that outputs today's date: 

Dim currentDate 
currentDate = Date()
Output = currentDate

We need that script to be run every day, which is not happening. It only updates when the document is checked in or the version is changed. Is there a way to have that automatic value to be updated every day at a certain time? We also tried using the Compliance Kit using the placeholder Today() but its the same problem.

  • You could run a small workflow with 2 states and these scripts:

    A transition trigger script on transition from state1 to state2, it should only allow state transition if Hour(now()) < 2 (run within the first hour of each day), and only if Last Modified is more than 1 hour ago (ensure it only runs once within that our).

    In state2 you need an action script that puts the object back to state 1. This circumvents the built in check for loops in the workflow, and it creates a new version which should then activate your calculation.

    This setup adds workload on the server because every object in the workflow will attempt to run the transition script every hour of the day. If you have a large number of objects it may take quite some time to complete that process! Also it will create a new version on each object every day adding to your database size.

  • As you have found out by default automatic values are only calculated when the object is changed. One way to trigger automatic updates would be to develop a VAF application with a recurring task that would call e.g. Recalculate method. Keep in mind that this always creates a new version of the object like bright-ideas.dk mentioned.

    (I must admit that I don't fully understand the use case and why you need today's date on the object metadata, but technically the above is one option to achieve that.)

  • Eh, I ended up simply changing my other scripts to use Now function in VBScript. It works the same, I don't even know now why we ended up going this way. :)

  • This is definitely the way to go.  You really don't want hundreds of versions of objects in the vault for no reason.