Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Computed fields - date

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Kedevlin
872 Views, 7 Replies

Computed fields - date

Looking for help to create a computed field that shows 60 days prior to a date field that is manually entered.  The manual field's Field ID is BOTTLE_DATE.  For example, if BOTTLE_DATE is 9/15/2014, I want the computed field to show 7/17/2014.  Thank you!

Tags (2)
7 REPLIES 7
Message 2 of 8
gasevsm
in reply to: Kedevlin

Hi, try this via onsave/oncreate script for the workspace. When user creates/saves item, shifted date will update.

var d = new Date(item.BOTTLE_DATE);
d.setDate(d.getDate()-60);
item.TARGET_DATE = d.getDate();

Hope this helps,

Martin Gasevski | Fusion 360 Team Product Manager
Message 3 of 8
Kedevlin
in reply to: gasevsm

Thanks, Martin! I get an error when I try that code: "There has been an error in processing your request.  Please use your browser's back button and try again or contact your system administrator." I attached the form I used; is your code intended to be entered differently? 

 

Message 4 of 8
gasevsm
in reply to: Kedevlin

Yes not using computed field.  Instead.. 

1. Create an action script with that code in Admin > System Config > Scripting

2. Then go to Admin > Workspace Mgr > [Target Workspace] > Behaviors > Place your new script in onCreate and/or onEdit, depending if want your date calculation to run when items get created, edited or both.  If the Behavior section already has scripts set for onCreate or onEdit, you'd have to go back to step 1 and edit those specfic scripts instead of creating a new one, adding the code snippet somewhere in.

3. Create or edit item should now re-calculate date shifts every time.

 

HTH,


Martin Gasevski | Fusion 360 Team Product Manager
Message 5 of 8
gasevsm
in reply to: gasevsm

.. and here's how to do it via Computed Field:

 

 

BOTTLE_DATE - interval '1 day' * 60


Martin Gasevski | Fusion 360 Team Product Manager
Message 6 of 8
Kedevlin
in reply to: gasevsm

It works! Thank you Martin!

Message 7 of 8
gasevsm
in reply to: Kedevlin

pleasure~!

Martin Gasevski | Fusion 360 Team Product Manager
Message 8 of 8
RosieBrigade
in reply to: gasevsm

Hi Martin,

 

Do you think you're able to help with setting up an expiry date similar to this script please?

 

Rosie.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report