Is there a way to hide certain column from DispForm based on if the current user is part of a Security Group? Unfortunately, the security group contains Active Directory group not individual names thats why I was hoping target audience
would work.
Here's what I've done so far:
In DispForm.aspx, added a content editor web part linked to a txt file with
<div id="hidValue"></div>
Added a target audience
in the CEWP.
In SharePoint Designer, I edited the custom DispForm.aspx
and added the following
<xsl:variable name="varInfo" select="@AdditionalInfo"/>
<script language="javascript">
var i =<xsl:value-of select="$varInfo"/>;
alert('<xsl:value-of select="$varInfo"/>');
</script>
The alert works but when I attempted to populate the <div id="hidValue"></div>
with any of below lines, none of them worked:
document.getElementById("hidValue").innerHTML = '<xsl:value-of select="$varInfo"/>';
document.getElementById("hidValue").innerHTML = {$varInfo};
Basically, I want the value of @AdditionalInfo
hidden to all except for the target audience.
I also tried below code which identifies the current user's group but does not work if user is part of an AD group inside the SharePoint group:
var ckUserGrp = _spPageContextInfo.webAbsoluteUrl +'/_api/web/currentuser/groups'
$.getJSON(ckUserGrp, function (data) {
$.each(data.value, function (key, value) {
var grpName = value.Title;
console.log(grpName);
});
})