So i have added content editor webpart in NewForm.aspx and reading the code to javascript file called HideFields.ps1. SO the script as below:
HideFields.ps1
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" language="javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
var xml = xData.responseXML.xml;
//If the current User does belong to the group "Test Group"
if (xml.search('Test Group') == -1)
{
$('td.ms-formlabel:contains("Description")').parent().hide();
}
}
});
});
</script>
The above script work as expected if i reference jquery library and SPService library externally.
What it does not work if i have save the file in the same location of this javascript file (HideFields.ps1).
<script type="text/javascript" language="javascript" src="~siteCollection/Style Library/Scripts/jquery.SPServices-0.7.1a.min.js"></script>
I tried also this one since the all the files existed in the same location
<script type="text/javascript" language="javascript" src="jquery.SPServices-0.7.1a.min.js"></script>