Question

In a new list item form,the user wants to have a column to display month & year(pre populated on opening the form) based on the below condition.

"1. If the current date is > 15 ,then that column should display current month number.

  1. Incase if the date is <15,then that column should display the last month number."

This column should also be editable.

I thought of using calculated columns but it doesn't pre-populate values in a new list item form,also its not editable.

Can someone help me with some suggestions/ideas?

Was it helpful?

Solution

I was able to find a solution by creating a single line of text column and in the "Calculated Value" section, I updated the below formula :

 =IF(DAY(Today)>15,TEXT(Today,"m"),TEXT(Today-16,"m"))

With "number" column,the below formula worked :

=IF(DAY(Today)>15,MONTH(Today),MONTH(Today-16))

OTHER TIPS

You can do it using JQuery in new item form. Add a single line of text column to list, when new list item form opened, make calculations and set single line of text value.

Calculated columns can't be edited, so the only ways I could think to accomplish this would be a) a SharePoint workflow that populates a field with the default value when the record is created, or b) some sort of script on the form that fires when the form gets loaded and sets the initial value.

Obviously use the latter if they need to be able to edit it when they first create the entry. Some simple jQuery should do the trick.

Is this SP2010, 2013? O365?

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top