1

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?

2

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))
1

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.

  • Thanks compengTR for your response. But with my method,i was only able to take the value as text. Is there any trick so that i can make the value as an integer(since month should be an integer)? – George Jun 25 '14 at 13:10
  • Can you change single line of text column type to number column type? At default value section, you can use this calculated formula and also you can use excel formulas to convert string to integer. – newbie Jun 25 '14 at 13:16
  • I tried that but it didnt work. :( Looks like number column couldnt recognise "today" function. – George Jun 25 '14 at 13:19
  • This formula worked with "Number" column: =IF(DAY(Today)>15,MONTH(Today),MONTH(Today-16)) – George Jun 25 '14 at 13:27
  • So... Your problem solved, I guess :) – newbie Jun 25 '14 at 13:31
0

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.