Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

How to set effectivity date with scripting

philipfrench
Collaborator

How to set effectivity date with scripting

philipfrench
Collaborator
Collaborator

On the Managed Items tab, I want to set the lifecycle and effectivity date.

 

I can set the lifecycle using

item.workflowItems[i].lifecycle = 'Production'

 

But please how to read/write the effectivity date in javascript?

Reply
Accepted solutions (1)
1,062 Views
2 Replies
Replies (2)

sven.dickmans
Autodesk
Autodesk
Accepted solution

You can pass a java date object to property effectivityDate ... the following code will set the effectivity date to today:

    for(var i = 0; i < item.workflowItems.length; i++) {
        var workflowItem = item.workflowItems[i];
        workflowItem.effectivityDate = new Date();
    }

 See the Methods on Workflow Items array in the online documentation within : https://help.autodesk.com/view/PLM/ENU/?guid=DEV-SCRIPT-REF#item-workflow-items-array

0 Likes

philipfrench
Collaborator
Collaborator

Thanks Sven.
I actually tried this again this morning before your post.
There was enhancement added in April 2024 to allow this property to be set by scripting. Thanks Autodesk dev!

 

If anyone wants to try Sven's (correct) example, there are two problems you may encounter:

  1. "EffectivityDate for workflow item 2246955 is not editable". Go to Lifecycle Manager, right-click the eg Released box, and ensure that 'effectivity' checkbox is selected.
  2. "Cannot set past date 2024-xx-xx as effectivity date" - you may have forgotten that month in javascript's Date(yyyy, mm, dd) constructor is zero-based, so 0=Jan, 1=Feb...


Respectfully, to the other poster, please stop this run of posting AI generated nonsense.
We can all paste questions into Co-pilot. You are copying rubbish that doesn't even answer the question, and code examples that wouldn't anyway work.