2

Is it possible to have more than one form associated with just one custom list and have one of those forms display based who is viewing it?

If that's not possible (or not the right way to go about it), then I believe there's a way to have some portions of the same form to be viewable only by certain types of users (using Sections, I believe). Is that correct?

If that is correct, then I have the following questions:

  1. How can I configure the form to show Section A to User 1 and Section B to User 2?
  2. Would I be setting myself up for a conflict if I have multiple copies of the same field in each section? According to my tests, changing the value in one field updates it to the same value in the copied field. I just want to be sure I'm not overlooking something in this case.

Thanks in advance to any and all help.

0

If you are using Infopath to create the form - you can have specific views associated with it. One thing we created internally was a list of validators, and had a special view on the infopath form to check if current user's ID was on that list in Sharepoint. If that was true, then form loaded to a different view.

So you would have to look at "Form Load" rules, and put in a condition to that data connection = where "if username() = UserID", switch to view: Validator.

Hope this is a possible suggestion for you.

  • Thanks, Jan. So if I understand you correctly, you created a separate list of usernames and used that to compare it to the actual list you wanted them to view. That would require foreknowledge of the usernames, yes? If so, could this method be configured to have it check if a user is in a particular Sharepoint group instead? – rizingfenix Apr 5 '18 at 16:30
  • I don't believe you can compare against a group in Sharepoint, unfortunately. – Jan Hariharan Apr 5 '18 at 19:57
  • Ok. Thanks for your assistance. Still plugging away at it. :) – rizingfenix Apr 5 '18 at 22:27
  • Jan, your solution suits my situation the best, but I'm hitting a bump. I've created a list for User A and one for User B and corresponding data connections for each list. I'm finding the username using another connection: GetUserProfileByName. I've tried comparing "Name" (in that connection) to "DisplayName" in the connection I created for User A. I get this error when I load the form: An error occurred while trying to connect to a Web service. So I tried comparing other values from each list and still get the same message. Can you please help me identify what's wrong? I'm so close. – rizingfenix Apr 6 '18 at 15:33
  • Hmm thats weird. I just did a google search for you - perhaps this might be your answer? social.technet.microsoft.com/Forums/office/en-US/… Let me know how it works out... – Jan Hariharan Apr 9 '18 at 15:22
0

Yes that's possible, using custom forms , you can use info-path forms and the form may contains multiple views.
Display a view that is based on a user role
How to Configure and Publish InfoPath to SharePoint 2013

beside you can use PowerApps if you're using sharepoint online
SharePoint custom forms: Build separate forms to create, show or edit the list item.

0

There are a few approaches you could use here

Break One Form into Sections Controlled by Permission

You can create custom forms that organize the fields by section, then hide/show the section based on who is logged in with javascript. The best way to manage who can see what would be to create permission groups to match the desired visibilities.

Easiest way to check if a user is a member of a group is to use SPServices but you can do it with the CSOM. You can hide all the fields by the default, then only show them when you confirm group membership.

SPServices: Check if Current User is in Group

3 Different Versions of the Same Form

You can create 3 versions of each form in the list (new, edit, and display), then use javascript to check whether the current user is authorized to see it. If not, redirect.

The downside of this approach is that when users try to access the form from the out of the box list view pages, they'll get routed to the default form(s) for that list. If they don't have access to that version of the forum, they'll get a redirect and another page load.

Create the Form in Infopath and Create 3 Different Views

I wouldn't necessarily recommend Infopath but you can also meet your requirement by adding a rule for the form load that checks the userprofile service for group membership.

http://www.hishamqaddomi.ca/spg/index.php/sharepoint-2010/infopath-2010/65-checking-if-a-user-is-a-member-in-a-sharepoint-group-within-web-infopath-2010-forms

  • Thanks, GVIrish! On several occasions I've heard people advise against using InfoPath. I'd like to understand more about the reason why, please? Is it limiting in some way? And if not using InfoPath, then I presume SharePoint designer as an alternative? Something else? – rizingfenix Apr 5 '18 at 16:42
  • Infopath has been deprecated by Microsoft so if you're using SP Online that means they could pull support for it from the platform and any existing Infopath forms would be broken. On prem you can count on it being supported for a few more years at least. The other thing with Infopath is it's great for visual layout but once you start adding a bunch of rules and code it can get unwieldy quickly. – GVIrish Apr 6 '18 at 18:44
0

There is no "secure" way to do this unfortunately. Field-level access is not something you can restrict.

Having said that, you can create alternate forms and simply show/hide the links for these forms using audience targetting.

The idea is you would setup multiple forms (e.g. NewForm1.aspx. NewForm2.aspx, etc.). Then you would hide all of the "default" options for creating a new item wherever you can (javascript may be involved in some cases).

Next, you want to setup manual links using webparts that have audience targetting set to the respective users/groups that get access to each form.

Link 1, targets users a, b, c, points to NewForm1.aspx

Link 2, targets users d, e, g, points to NewForm2.aspx

etc.

Begin Edit:

To add these links, use content editor webparts or script editor webparts. In the webpart itself just add an anchor tag like this <a href="urlToNewForm1.aspx">Form 1</a>. Style it using CSS if you're familiar.

The Newform1.aspx can be added by opening the site/list in SharePoint Designer. Or you could probably use the windows explorer view in IE to copy-paste a newform.aspx into the Forms folder of the list. I recommend SPD though.

End Edit

Again, this is NOT SECURE. If user A "deep links" to NewForm2.aspx, they will still be able to get to it. Or if they edit the list using CSOM (javascript) they can set the properties you don't want them to because they have "edit" rights to the list itself. There's no other security settings preventing them from touching specific fields. To truly achieve that you would need to break your form out into multiple different lists, but that leads down a slippery slope full of regret.

Another secure option would be to code a provider hosted solution that uses elevated permission and restrict edit access to the list through the provider hosted app only.

Hope this helps!

  • This is great information, Chad. Thanks! Security is not a concern of mine for now. I'll be uploading all the data, so no need for them to create new items. I consider myself on the beginner's level, but I do understand your overall concept. It's when I get into javascript that I'm getting into deeper waters. So can you please expand on that a bit more? Like what and where the code is to be inserted? – rizingfenix Apr 5 '18 at 16:32
  • See my edit, there's no javascript needed if you're going with the NewForm1.aspx, NewForm2.aspx approach. Just webparts and a bit of html. – Chad Apr 5 '18 at 19:36

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.