I have found a number of recommended ways in blogs looking to answer how to do this and have not successfully made any of them work using SharePoint MOSS 2007 and SharePoint Designer 2007.
I have already hidden the fields that I don't want any user to see within the site content type (those fields being set by a SharePoint Designer Workflow).
I'm trying to hide specific fields on the NewForm.aspx and EditForm.aspx based on whether the current user is in a Specific SharePoint group. My list has a site content type that I created and site columns.
When I look at the NewForm.aspx in Designer the design view gives me generic Field 1, 2, 3 and not my specific content types. If I create a new aspx page and insert SharePoint control > custom list form, then my fields show up. I'll take ways to edit in designer if you have them, but I need someone to check the solution below and help me figure out where I'm messing up.
Went with option indicating to use jquery (1.9.0.js) and SPServices (0.7.2.min.js).
I uploaded both files to a document library on my site.
I then created a CEWP on my NewForm.aspx page (not through designer but the front-end by appending "shared&ToolPaneView=2" to the url.
Pasted the following code into the CEWP:
'
<script type="text/javascript" language="javascript" src="/Style%20Library/JavaScript%20Utilities/jquery.SPServices-0.7.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
var xml = xData.responseXML.xml;
if (xml.search('MyGroupName') != -1)
function hidefields() {
var control = findacontrol("MyColumnName");
control.parentnode.parentnode.style.display="none";
}
}
});
});
</script>
When I click save in the 'Source Editor' dialogue box, it closes and on my main browser status I get a message 'Please wait while scripts are loaded..." and then nothing happens. I can click okay on the Modify Shared Web Part menu and the web part closes. Get same wait message...
Goal is that if current user is not part of MyGroupName then the field for MyColumnName will not be visible on the page. Not a developer but trying to play one in real life.
If you're still reading, Thanks!!!