Onclick javascript button - how to enable and disable based on profiles. For example the button should be displayed based on no of days created , if more than five weeks the button should be visible for all users else it should be visible for only users with profile system administrator
{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/16.0/apex.js")}
var needs = "{!Entry__c.Needs__c}";
var removal = "{!Entry__c.Removal__c})";
var Id = "{!Entry__c.Id}";
var callback = {
onSuccess: function(decompileResult){
window.location = '/{!Entry__c.WeekId__c}';
},
onFailure: function(decompileResult){
alert('Delete Action Failed: ' + decompileResult);
}
};
if(needs == 'No'||(needs == 'Yes' && removal !=')'))
{
//alert('Please Enter a Authoriser and Unavailability Notes');
window.parent.location.replace('/apex/DiaryEntryEditPage?retURL='+diarId+'&Id='+diarId+'&r=r&needsReason=No');
}
else{
//alert('Please Enter a Amendment Reason and Unavailability Notes');
window.parent.location.replace('/apex/DiaryEntryEditPage?retURL='+diarId+'&Id='+diarId+'&r=r&needsReason=Yes');
}