Skip to main content

Posts

Showing posts from April, 2012

Another Reason for 'Group can not be found' error in SharePoint 2010

Recently I was working on an workflow where I was accessing a group from SharePoint 2010 and from there trying to get user's mail ids. I created a group in SharePoint 2010 from UI. Since this group was supposed to hold only users (approvers for workflow), I did not assign any permission to the group. I left all the check boxes unchecked. Next when you try to get the group from code in workflow, you will get error saying 'Group can not be found'. Below is the code I had written in my VS 2010 workflow. SPGroup spgApprovers = workflowProperties.Site.RootWeb.Groups["Some Group"]; After some googling, I found that if you have not assigned any permission to the group, it will not show up in the code. So I went back to the group, deleted it and recreated with reader permission. Hope this will help someone... Happy SharePointing... -Vighnesh Bendre

Validation before Save in New or Edit form

If you want to do validation based on other column in your out of the box New or Edit form, you can do it using JQuery in SharePoint 2010. In the code below I am trying to validate a text column if the value in the status drop down list is ‘In Process’. The function PreSaveAction() gets fired when the user clicks on ‘Save’ button in the New or Edit form. In this function you can create object of the drop down list and text control and check if the text control is empty when the status is ‘In Process’. function PreSaveAction() { var selectedVal = $("select[title='Status']").find('option:selected').text(); if(selectedVal == 'In Process') { var chrgtoNum = $("input[title='SID Number']").val(); if(chrgtoNum == '') { alert('Please enter SID Number.'); return false; } else{return true;} } else {return true;} } You can see my other blog to learn h...

Validation or control form from JQuery - Default New and Edit forms

When you create a custom list, you get default edit and new forms with it. So when you are entering data or modifying it SharePoint provides you a form in a popup that enables you to enter or modify data. But then, if you want to add custom features to the new or edit form, you can do so using JQuery. In the below example, based on the valued selected in the dropdown list, I want to enable or disable other control. And I want to add this JQuery code to the New and Edit forms of the custom list. function HideColumn(stat, active) { var activeObj = $("input[title='" + active + "']"); //initially when the user opens the form, we need to check if the user has selected the status that we have written code for… //if selected value is other than Suspend, disable the control var initialVal = $("select[title='"+ stat +"']").find('option:selected').text(); if(initialVal == '...