The below code for single hard coded users and hiding please help me out to achieve for group of users.
Many thanks in advance.
<script type="text/javascript">
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}</script><script language="ecmascript" type="text/ecmascript">
ExecuteOrDelayUntilScriptLoaded(getFieldUserValue, "sp.js")
var listItem;
var list;
var clientContext;
var currentUser ;
var text;
var resFin;
var resChief;
var resSnr;
function getFieldUserValue() {
this.clientContext = SP.ClientContext.get_current();
if (this.clientContext != undefined && clientContext != null) {
var webSite = clientContext.get_web();
currentUser = webSite .get_currentUser();
this.list = webSite.get_lists().getByTitle("Payment");
var itemId = parseInt(getUrlVars()["ID"]);
resFin= $("select[title='Finance Manager Approval Status']").val();
resChief= $("select[title='Chief Accountant Confirmation Status']").val();
resSnr= $("select[title='Senior Accountant Confirmation Status']").val();
this.listItem = list.getItemById(itemId);
clientContext.load(this.listItem);
clientContext.load(currentUser);
this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));
}
}
function OnLoadSuccess(sender, args) {
var fieldUserValueCreatedBy = this.listItem.get_item("Author");
var loginuser = this.listItem.get_item("Editor").value;
var account = currentUser.get_loginName();
var currentUserAccount = account.substring(account.indexOf("|") + 11);
if(fieldUserValueCreatedBy.get_lookupValue()==currentUserAccount)
{
$('td.ms-formlabel:contains("Chief Accountant Confirmation Status")').parent().hide();
$('td.ms-formlabel:contains("Finance Manager Approval Status")').parent().hide();
$('td.ms-formlabel:contains("Senior Accountant Confirmation Status")').parent().hide();
}
if('snraccountant' == currentUserAccount )
{
$('td.ms-formlabel:contains("Chief Accountant Confirmation Status")').parent().hide();
$('td.ms-formlabel:contains("Finance Manager Approval Status")').parent().hide();
}
if('financemanager'== currentUserAccount)
{
$('td.ms-formlabel:contains("Chief Accountant Confirmation Status")').parent().hide();
$('td.ms-formlabel:contains("Senior Accountant Confirmation Status")').parent().hide();
}
if('finuser1'== currentUserAccount)
{
$('td.ms-formlabel:contains("Finance Manager Approval Status")').parent().hide();
$('td.ms-formlabel:contains("Chief Accountant Confirmation Status")').parent().hide();
$('td.ms-formlabel:contains("Senior Accountant Confirmation Status")').parent().hide();
}
if('ceo' == currentUserAccount)
{
$('td.ms-formlabel:contains("Finance Manager Approval Status")').parent().hide();
$('td.ms-formlabel:contains("Chief Accountant Confirmation Status")').parent().hide();
$('td.ms-formlabel:contains("Senior Accountant Confirmation Status")').parent().hide();
}
if(resFin == "Approved")
{
$("nobr:contains('Finance Manager Approval Status')").parent('h3').parent('td').parent('tr').hide();
}
if(resChief == "Approved")
{
$("nobr:contains('Chief Accountant Confirmation Status')").parent('h3').parent('td').parent('tr').hide();
}
if(resSnr == "Approved")
{
$("nobr:contains('Senior Accountant Confirmation Status')").parent('h3').parent('td').parent('tr').hide();
}
}
function OnLoadFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>