2

I have a team site collection , which have 6 custom lists. now our customer ask us to add a message when users create/edit list items , to exaplin what does the "*" means, something as follow:-

enter image description here

now i find this appraoch:-

1- inside the 6 custom lists to edit their Create/Edit forms.

2- this can be done by going to the Create/Edit forms >> Edit Page.

3- then add a "Content Editor" web part.

4- inside the "Content Editor" web part to define a Content Link as follow, to referecne a .txt file:- enter image description here

5- then inside the .txt file to add a message text :-

<span style="color:red"> * Represents Mandatory Fields</span>

is this case i can manage the message from one place (.txt file), and even if i save my site as template and create a new sites based on the template,, the new sites will benefit from this also.. but can anyone adivce if my above appraoch is valid ? or there is another way to allow my Create/Edit forms to explain what does "*" means ? using JSLINK or other approaches ? Thanks

  • 1
    Are you trying to modify manual the NewForm.aspx and EditForm.aspx for 6 lists? – Ola Jan 5 '17 at 13:21
  • @Ola yes can you explain your point ? i need to modify them to add a Content Editor web-part which will be referencing the .txt file... and this will be done for one time only – john Gu Jan 5 '17 at 13:23
  • Are these 6 lists already in use or are they new? And do you use the same fields in all 6 lists? – Ola Jan 5 '17 at 13:32
  • @Ola i can not get your point... Yes they are in use,, and we will be creating additional sites based on the site template so each site will have 6 lists.. and for the fields each list have different fields and different content type linked to it,,, but i want to show the same message under the 6 lists' create and edit forms.. – john Gu Jan 5 '17 at 13:37
  • @Ola can you please check my update to my original question as i explain it in more details ? – john Gu Jan 6 '17 at 2:40
7

That's a kind of bulky way to do it, what if you create multiple sites using this template and then need to change something in the text document? That would be a lot of manual work to update the document in all site collections.

While it would be possible to store this text file on the root site and give everyone read access, i think it can lead to confusion if the permissions would be changed by mistake.

Would it not be better to create site columns and content types for the list, and use the Description field and column validations + error messages?

A simple validation to check if a column is blank would be =LEN([Column])>0

Then you should be able to easy push any changes that needs to done in a content type or column by using a content hub.

It would make more sense for your customer to be able to administer the list content types and site columns from one central place.

EDIT

Read about the benefits about having a content type hub. While it would take some planning to implement it in your customers environments, i'm sure that long term benefits would make it worthwhile.

Publish a content type from a content publishing hub

  • now for the permission this is not a problem as i will place the .txt file on the root site,, and all the sub-sites will be using this .txt file. now if i want to update the message i will only have to edit the .txt file. and all the related create/edit forms will get the new message. now in your appraoch if i want to set a column as required, then i need to update its description and add a validation to it. while setting a column as required will automatically add "*" beside the field. so not sure why you do not prefer my appraoch ? as it seems less work compared to ur appraoch ? – john Gu Jan 5 '17 at 13:22
  • Just giving you another option. While this may work i think it's a little bit of dirty as you need to know what you are doing if your customer need to fix anything themselves. I think it would look better as well, delivering a OOTB solution without custom coding. (as of the formula of course). Go with the option that suits you the best and that you think works the best. Just giving my opinion. :) – Christoffer Jan 5 '17 at 15:02
  • i still did not understand why you want to manually write this formula "=LEN([Column])>0" ?? as if i set a column as Required i will get this validation out of the box !! – john Gu Jan 5 '17 at 15:32
  • I prefer a custom error message to help the user for a specific column instead of the generic error message. – Christoffer Jan 5 '17 at 16:05
  • but the error message which indicates that a field is required will be shown regardless if i specify a formula or not ...this is my point – john Gu Jan 5 '17 at 17:56
3
+25

I donot suggest to add content editor webpart for this. Instead you can leverage JS link of New/ Edit list web parts. Add script to JS in the below format

~site/SiteAssets/scripts/jquery.min.js | ~site/SiteAssets/scripts/main.js

It includes jquery and other file and you can add script from there on as you do in text file.

Script in main.js

$(".ms-formtable").after('<span style="color:red"> * Represents Mandatory Fields</span>');

Scrrenshot

  • thanks for the suggestion, but why you would prefer the jquery appraoch over the HTML appraoch i proposed ? second question how you are linking the jQuery with the new and edit forms,, i did not get it? can you please advice on my 2 questions – john Gu Jan 15 '17 at 1:40
  • 1) HTML Content Editor Webpart add extra load to the page and its old way of using sharepoint where we no need to add more webparts to page. Alternatively if want to use you can try with script editor webpart(But i donot prefer for this use case) 2) Go the New Item Page of any list. Look for the JS link in miscellaneous tab. Refer your javascripts with this notation: ~site/SiteAssets/scripts/jquery.min.js | ~site/SiteAssets/scripts/main.js – Shiva Jan 15 '17 at 9:13
0

In Sharepoint Online, once you are in the form if you hit the top right cog you will get the option to "Edit Page", after this just add a Content Editor Webpart with the text you would like and voila.

Of course, this is something you would need to do for every form you create.

Another good option as already stated, is to add as part of the column details that it is mandatory, so it will show below the item (Or the last item so it will only show once).

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.