Expense report (follow-up)

Hi everyone!

Ok, so this is a follow-up on my last post Name of month in expense report.

I promised that I would tell you how I did to get this expense report, to be editable only until a certain date and how the field that is telling us for which month this report is valid for, would keep it’s value even if the report is opened later on.

In this example, let’s say that our finance dep would like the employees to deliver their expense reports prior to the 16 of the current month. The employees should still be able to open these reports later on to be able to check and compare but not being able to make any changes or to save the report.

If you haven’t already created a data connection to submit the form back to the form library and added a button for the users to do this with, please do so 🙂

Set the correct month and keep its value

Now we need to do a few things to keep the value of the field for which month this report is for. What I am taking about is the field right after the title.

Start by adding a new field of the type string called ValidMonth.

Add another field of the type whole number (integer) called Day and give it the value substring(TodaysDate, 9, 2), now we know which day it is.

We should now give the submit button a rule.

Highlight the button, click on the button Manage rules in the ribbon.

The action we would like this rule to do for us is to set the value of ValidMonth to the name of the month for which this report should have. It could be the current month but it could also be the upcoming month if it is created between the 16th and 31st.

Create a new rule with the condition to be fired only if ValidMonth is equal to Empty and Day is less than or equal to 15. The action should be to set ValidMonth to the name of the current month. The rule should look like this:

But what if  we would create a new form between the 16th and 31st?
We need to create one more field to hold the name of the next month.

Give the field the name NextMonth with the value MonthNr +1

Ok, so now we have the number of the upcoming month, let’s use it to set the name of the next month.

Create one more rule for the save button with the condition to be fired only if ValidMonth is equal to Empty and Day is less than or equal to 31 and greater than 15. The action should be to set ValidMonth to the name of the next month. The rule should look like this:

There you go!

Now the form’s month is set only once and depending on if it should be valid for this month or the next, it will get the correct one. If you add these rules to the Form load it will be set when you open the form.

Editable until a certain date

Let’s add a rule for the submit button. Make it a formatting rule with the condition to only fire when Day is greater than 15 and mark the choice to Hide this control. That way the button will be hidden when the date is greater than 15th, and they will not be able to save any changes.

What if we want to create a new report between the 16th and 31st?
Ok, so we also need to check if ValidMonth is equal to MonthName, in that case the submit button should not be seen.

So, add another condition to that same rule that says:

and ValidMonth equals MonthName (be sure to use “and”)

Ok, there you go!

That was pretty easy 🙂

CU!

/Niax

Advertisements


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s