Archive for August 2011
SharePoint Client Object Model – Check user belongs to a Group – Disable controls in editfrm.aspx
Posted on: August 17, 2011
Just wanted to Share a Script which will help in checking if the Logged in User belongs to a SharePoint user group and based on it disable some controls in editfrm.aspx on Custom List. It uses JQUERY.
ExecuteOrDelayUntilScriptLoaded(disableControls, “sp.js”);
function disableControls()
{
clientContext = new SP.ClientContext();
groupCollection = clientContext.get_web().get_siteGroups();
group = groupCollection.getById(21); //The ID of the SharePoint user group
users = group.get_users();
clientContext.load(group);
clientContext.load(users);
currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(Function.createDelegate(this,
this.onQuerySucceeded), Function.createDelegate(this,
this.onQueryFailed));
RefreshCommandUI();
}
function onQuerySucceeded()
{
if(users.get_count() >0)
{
UserExistInGroup = false;
for(var i=0; i < users.get_count(); i++)
{
if(users.itemAt(i).get_loginName() == this.currentUser.get_loginName())
{
UserExistInGroup = true;
break;
}
}
}
if (UserExistInGroup)
{
var p=$(‘input[title=Priority'); //Name of the columns that needs to be disabled
var i=$('input[title=Range]‘); //Name of the columns that needs to be disabled
$($(p)[0]).attr(‘disabled’,false);
$($(i)[0]).attr(‘disabled’,false);
}
else
{
var p=$(‘input[title=Priority');
var i=$('input[title=Range');
$($(p)[0]).attr(‘disabled’,true);
$($(i)[0]).attr(‘disabled’,true);
}
}
function onQueryFailed(sender, args)
{
var p=$(‘input[title=Priority');
var i=$('input[title=Range]‘);
$($(p)[0]).attr(‘disabled’,true);
$($(i)[0]).attr(‘disabled’,true);
}
Warning ModuleName=”ManagedPipelineHandler”, Notification=”EXECUTE_REQUEST_HANDLER”, HttpStatus=”400″, HttpReason=”Bad Request”, HttpSubStatus=”0″, ErrorCode=”The operation completed successfully
Posted on: August 5, 2011
- In: .NET | Visual Studio
- 2 Comments
We are having a .NET 4.0 Web Site which is using URL Routing. This basically returns a structured XML which will be consumed by a Data Connection in Infopath form on Demand.
http://msdn.microsoft.com/en-us/magazine/dd347546.aspx
It starting throwing error all of a sudden and when enabled Failed Request Logging on IIS 7 it had below message.
Warning ModuleName=”ManagedPipelineHandler”, Notification=”EXECUTE_REQUEST_HANDLER”, HttpStatus=”400″, HttpReason=”Bad Request”, HttpSubStatus=”0″, ErrorCode=”The operation completed successfully
So initial thought was that we had some issue with the Routing mechanism but everything was great. So later when debugging the same on DEV found that there is an internal error in Database Connection which throwed an error / which was not even getting logged because of the Log size.
Some error messages are quite confusing, better not to trust them and follow by what they say. Saves time.
