Monday, May 24, 2010

Sharepoint 2010 Out of the Box features - Multi State Workflow

I had a requirement where in first step Item should be sent to Approvers for approval.
And if its approved subsequently item request should be forwarded to another group who
will be downloading related attachments and marks workflow complete.

If at step 1 approvers rejects the item request, workflow should be terminated.
Here is what I configured in 2010 Sharepoint...

Step 1 - Select Three State Workflow from available workflow list











Step 2 - Configure Various States of Workflow and Step 1 details









Step 3 - Configure Middle State of workflow and complete

Sharepoint 2010 Out of the Box features - Add Unique Key on List column

In Sharepoint 2010 now you can setup unique key constraint on column. While creating column
select "Enforce unique values" and Sharepoint will index the field.. Bingo...



Sharepoint 2010 Out of the Box features - Validate List field

Have you wrote code to validate a column in Sharepoint 2007? Well 2010 solves the problem. You can configure the validation out of the box at column level in Sharepoint 2010 List...

Here you Go..

Enter your validation and custom message and bingo....








and when you insert\edit item you will see validator message...

Monday, April 12, 2010

How to Populate Current Username in Sharepoint Designer

Question - How can I pre-populate current logged in Username in People picker in Sharepoint designer custom form?

Solution - Paste followng Javascript code in designer... This will work for first people picker control that it finds on the form...

_spBodyOnLoadFunctionNames.push("fillDefaultValues");
function fillDefaultValues() { fillPeoplePickerWithCurrentUser();}
function fillPeoplePickerWithCurrentUser(){ //get the current user from the welcome menu var currentUser = getCurrentUser();
//check to see that we've got it if(currentUser != null) { //get the people pickers input div var pp = getPickerInputElement(); //set it to the current user if we've found it if(pp != null) { //see if it's already set as we don't want to override when editing an item //if it's already set then the people picker element will contain a SPAN element for the resolved entity var spans = pp.getElementsByTagName('SPAN'); if(spans.length == 0) pp.innerHTML = currentUser; } }}
function getCurrentUser(){ var tags = document.getElementsByTagName('a'); for (var i=0; i < result = "" divs =" document.getElementsByTagName(" i="0;" id="=" innerdivs =" divs[i].getElementsByTagName(" k="0;"> 0) { result = innerDivs[k]; break; } } } } return result;}

Sunday, March 28, 2010

Multiple Value Lookups in Sharepoint Designer Workflow

Requirement
----------------------------------------------------------------------------------------------
I had a requirement where Lookup column has multiple value selection turned on. There is a field in Master list with person & groups as datatype. I need to send email to each user for the selected value in multiple lookup column.

Issue
----------------------------------------------------------------------------------------------
Sharepoint designer workflow lookup returns single value for the joined criteria.

Resolution
---------------------------------------------------------------------------------------------
Solution is to write a Custom Activity that can be used in Sharepoint Designer workflow.
Activity can return comma seperated string of email addresses Or any other field based on user
input.

Wednesday, April 15, 2009

SPEmailEventReceiver not working?

I was working on the SPEmailEventReceiver attach to sharepoint list and faced the same issue that most of the people faced. Once you deploy the code to GAC and attach receiver code works fine. After that if you change the code and deploy the assembly event doesnt get fired.

The only problem here is that somehow sharepoint receiver handler keeps referencing old
assembly version and as a result doesnt fire the event.

Solution is to change a version number every time you deploy the dll to GAC. Remove the receiver and attach once again. This way sharepoint always refers to a new version of the dll
and event is fired all the time.