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

Set Date as 'Today()'

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Chad-Smith
1257 Views, 7 Replies

Set Date as 'Today()'

With a Date field, is there a way to set the default date to 'today()'?

 

Further to this, is it also possible to set a default date as 'today()+7', or what ever to date is in X number of days?

Tags (1)
7 REPLIES 7
Message 2 of 8
broepke
in reply to: Chad-Smith

There isn't a way to do this directly in the field.  However, you can create a small script that will do that - make it an action script and set it as part of the "create" bevaior.    Inside the tenant there are a bunch of examples to pick from.  Particularily where the milestones are created. "createMileStones" Library script.  Check this one out.

 

The script could be as simple as the following for setting today's date

 

var today = new Date();

 

item.MY_TODAY_FIELD = today;

 

When you want to add dates and JavaScript it's a little harder... But not much.  Here is how it would look

 

var nextweek = new Date();

var dayOfMonth = nextweek.getDate();
nextweek.setDate(dayOfMonth + 7);


item.MY_NEXT_WEEK_FIELD = nextweek;

 

Remember - Google examples like this and you'll find tons of samples out there.

 

 



Brian Roepke
Director, Analytics & Insights
Message 3 of 8
Chad-Smith
in reply to: broepke

Thanks for the reply Brian. Unfortunately this is not quite what I am after, let me explain further.

 

When I referred to a default date value, I want the field to be pre-populated at the time the user is creating a New workspace item, not after they press the Save button.

 

In my example, I would like the user to press New to start the creation process. They are presented with the fields to fill out, but I want my Date and Date Due fields to be pre-populated with todays date and a date in 7 days respectively. This way they don't need to fill them out each time. But, I also want to user to be able to override the values if they are not correct, i.e. maybe the Due Date should be in 3 days.

 

It's almost as though we need a Workspace Behaviour for Script to run at item spawing.

Message 4 of 8
Chad-Smith
in reply to: Chad-Smith

The other thing is that Scripts only seem to run at the Item Details level in a Workspace and not in the Grid view, which is where I need this to happen.

 

To give a clearer picture of what I want to do, I would like to use the Grid view for recording some general notes and actions. This tab contains the following fields;

Note

Date Due

Date Due Reminder (Non-editable and invisible) - Controlled via a Script at this point would be fine but I can't.

Status

Flag

 

I would like the Date Due to be 7 days after the current date, but offer the user the flexibility to change it. The Date Due Reminder would be auto-calculated to be 2 days prior to the Date Due.

The Flag would then be set by some rules including the Status field, but in general it would be set by; Green=on track, Orange=within the 2 day reminder period, Red=Overdue.

Message 5 of 8
Chad-Smith
in reply to: Chad-Smith

Looks like I may have spoke too soon on my last reply. I seem to have figured it out by using a Computed Field Formula. After some testing it is working pretty well, and thought I'd share the result.

 

STATUS field - Picklist 3 options (Complete, In Progress, No Action Required)

 

FLAG field - Computed Field Formula

----------

CASE WHEN (STATUS = 1) OR (STATUS = 3) THEN '<span style="text-align:center; line-height:30px; color:gray; background:gray; width:100%; float:left; height:20px;">GRAY</span>'

 

WHEN (STATUS = 2) AND (DATE_DUE > getdate()) AND (DATE_DUE < (getdate()+2)) THEN '<span style="background: orange; color: orange; width:100%; float:left; height:20px;">ORANGE</span>'

 

WHEN (STATUS = 2) AND (DATE_DUE < getdate()) THEN '<span style="background:red; color:red; width:100%; float:left; height:20px;">RED</span>'

 

ELSE '<span style="text-align:center; line-height:30px; color:green; background:green; width:100%; float:left; height:20px;">GREEN</span>'

 

END

----------

 

 

The hardest part is working out the syntax of the code which PLM will accept. Is there a reference in the Help to this? I've looked but have not been able to find anything.

Message 6 of 8
michelle.stone
in reply to: Chad-Smith

A couple links that might help - a tutorial on computed fields (though from your previous reply looks like you have the hang of it), and a link to the developer's guide on the Wiki.

 

HTH!

Michelle



Michelle Stone
Technical Marketing, PDM & PLM
Autodesk, Inc.
Message 7 of 8
scottmoyse
in reply to: Chad-Smith

Date created would take care of today's date automatically. Use an action script on creation to fill out the due date. But don't have it run on edit. Then once created it can be edited. But shouldn't you be using milestones for due date stuff? Regards Scott Moyse Sent from my iPhone ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal #####################################################################################

Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 8 of 8
punisher
in reply to: Chad-Smith

Thanks Brian, that hooked me up.

John Evans
Autodesk Certified Professional

http://designandmotion.net

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

Post to forums  

Autodesk Design & Make Report