Dynamics 365 version 9.0.2 (Unified Client Interface)
Sometimes businesses have a requirement to reject Time Entries entries based on a set cut-off date. This blog post covers two different cut-off date examples and includes a detailed customization walkthrough for implementing cut-off dates in Dynamics 365 Project Service Automation. Let’s look at two possible requirements:
1. Set a project specific cut-off date. Don’t allow a user to submit Time Entries for a time period that is after the cut-off date.
2. Set a cut-off date for the 1st of month. Don’t allow a user to submit Time Entries for a previous month.
These two examples require slightly different approaches when it comes to customizing Dynamics 365 Project Service Automation. The examples will give you ideas on designing a logic that fits your specific business requirements.
Project specific cut-off date
1. Create a new field on the Project entity with a Data Type of Date and Time. Then put the field on the Project form. Create a Project record and set a value to the new field.
2. Create a similar Date and Time field on the Time Entry entity and place the field on the Time Entry main form. The cut-off date is added on the Time Entry form so that a user sees what the cut-off date is. Note that I’ve placed the field on the main form and not on the quick create.
3. Create a real-time workflow for the Time Entry entity. The workflow is fired off when a Time Entry record is crated. The workflow pulls a cut-off date from Project. It then checks if the Date of a Time Entry is greater than the cut-off date. Be sure to use the Date field as that holds the value of the actual date of a Time Entry. For example: You can have a Time Entry for the 1st of July but the created on date can be the 2nd of July. If the Date of a Time Entry is greater than a cut-off date, stop the workflow as canceled and display a custom message. This prevents a user from submitting an incorrect Time Entry.
4. Submit a Time Entry with a Date that is greater than a cut-off date you have set on a project. In this example the cut-off date on a project is the 4th of July. When Save is clicked, a Business Process Error with a custom message is displayed. This is the workflow in action.
1st of month cut-off date
1. Download and install Jason Lattimer’s CRM-DateTime-Workflow-Utilities in your instance. This solution will allow you to easily display a value of a cut-off date’s month as well as of a Time Entry’s month.
2. Create three new fields for the Time Entry entity. The fields display today’s date, the month of a Time Entry’s date as a whole number and the current month as a whole number. Place the fields on the Time Entry main form and hide them – the fields aren’t relevant for the users.
Today’s Date is a Calculated field.
Time Entry’s month and Current Month are Whole Number fields.
3. Create a workflow that sets month numbers to the fields that were created in the previous step. Jason Lattimer’s solution is needed to set input parameters in the workflow. The workflow then updates a Time Entry record and sets month numbers to the custom fields as an output. It’s a good idea to fire off the workflow when a record is created and when the Date of a Time Entry changes. I have created the workflow as a real-time workflow.
4. Create a workflow that rejects a submitted Time Entry if Current Month does not equal the Time Entry’s month. I have created the workflow as a real-time workflow that is fired off before the Entry Status field changes.
5. Create a new Time Entry and set its Date for a previous month. I have left the three custom fields visible on the form for this example. When submitting a Time Entry for a month that doesn’t match the current month, an error is displayed.
I hope this article helps you take more out of Time Entries. Jason Lattimer’s solution is pretty versatile and you can easily adjust the 2nd example to fit you needs if you want to restrict Time Entries based on days, weeks or months.
All my blog posts reflect my personal opinions and findings unless otherwise stated.