Search This Blog

Showing posts with label Workflow2010. Show all posts
Showing posts with label Workflow2010. Show all posts

Saturday, August 2, 2014

SharePoint Designer Workflow required for Custom Lists

New SharePoint Designer Alerts required for Test Site & Issues Custom Lists below:

https://testsite.com/sites/test/Lists/Risk%20List/All%20Items.aspx

https://testsite.com/sites/test/Lists/Issue%20List/All%20Items.aspx

1) Requirement for email alerts to be sent to a specific user on either of the above lists when a user is assigned as an "Owner" or "Manager"(People Picker-field) to a new Risk or Issue.
Emails to be sent immediately upon "Manager" or "Owner" being assigned.

2) Requirement for email alerts to be sent to a specific user on either of the above lists when a user is assigned as  "Owner" or "Manager" (People Picker-field)of an existing Risk or Issue where either of the fields have changed.


Emails to be sent immediately upon "Manager" or "Owner" field change.

1         Implementation Plan:

1.1.1           Open SharePoint designer click open the site. 





1.1.2           Enter the site link on https://testsite.com/sites/test


1.1.3           Next you have seen Credential section login the service account (domain\test_usrl)

1.1.4           Next Click List Workflow on ribbon menu
1.1.5           Select one of the Custom List of  Issue List.

1.1.6           Now SharePoint designer will ask you to enter a name for your workflow. I have named the workflow as “SendMailWorkLFow”. Click on create button once you are done.


1.1.7           We just need to add a step that will send email click the Action-event on ribbon menu


1.1.8           You can add conditions and actions to workflow. In our case, it is just one action. Select send an Email option.


1.1.9           In Step1 Section and Email option click these users link


1.1.10       Displaying one popup menu, on popup menu we have configure To address and Subject and body contains, First you need to enter the To address. Click on the browser button next to To: text box.


1.1.11       Select the Workflow Lookup for a User... and click add->> button


1.1.12       Next screen to select the follwin item DataSource : Current Item,

Field from Source: Issue Owner, Return field as : As string

1.1.13       Same as repeat 2.1.11 to 2.112 and select Field from Source: Issue Manager


1.1.14       Displaying selected users on right side list box and say ok.


1.1.15       Next Define email dialog. Here you need to enter the  subject and a body for the email from the attached excel sheet. Copy paste the content as per attached screen shot.


Then delete the  bulleted line(Title) and keep the cursor same line.


1.1.16       Next Click the Link button on right side cornor.




1.1.17       Click on the Text to display textbox fx Icon in the right side corner.



1.1.18       Next screen choose DataSource: Current Item, Field from Source : Title, Return as field as: As String.


1.1.19       Next follow the 2.1.17 and click Address textbox  fx icon.


1.1.20       Next click Add or Change Lookup and that screen select datasource : Current Item, field from source : Path, Return field as : As String. And then say ok


1.1.21       Click OK.


1.1.22       Click OK..


1.1.23       Below is the screenshot of the email body we have configured. Once verified and Click Ok.


1.1.24       Next you choose the Action on ribbon menu and select Stop Workflow action; it will be inserted in the Step1.




1.1.25       Click this message


1.1.26       Click the button and add some message.


1.1.27       Similar to following.


1.1.28       Since the workflow to start automatically when an Item is created and updated. So click the workflow settings,


1.1.29       Select the below attached screen shot option only.


1.1.30       Now we need to publish it. To publish the workflow, press on the publish button in the top



2          Test Plan

2.1.1           After implementing the change, Go to  site.

2.1.2           Now go and click View all Site Content

2.1.3           Now go and click Issue List under List Section

2.1.4           Click on the Workflow Settings link,

2.1.5            This will open the workflow settings for the Issue list and you can find our workflow is available in the list


Friday, March 16, 2012

Workflow

Intro:
This isa sample workflow , it ll send mail to a depends on a status,that status ismatained by a field of a list
Step1: Create a empty sharepoint project

Create a list in your sit with the following columns:
1. EmployeeName
2. StartDate
3. EndDate
4. PMStatus
5. MailPM
6. MailAdmin
7. AdminStatus
8. ReasonforLeave
Step2: Create a new Sequential workflow(by add new item inthat project)

You can find this workflow in soln explorer

And also you can find this in thatWorkflow1[Design]


Step3: By double click on thatevent(onWorkflowActivated1)you ll get invoked method for that you can writesome codings which are need to be done.at the time of workflow activated.
Step4:we can insert a condition (If-else)that’s placed attoolbox

Step5: you can write conditions with the property ofifElseActivity1&2
Properties-condition-codecondition-contion-“name of thatfunction”(ismailsenttoPM) it ll create a function in cs page,
Paste this coding in that function
private void ismailsenttoPM(objectsender, ConditionalEventArgs e)
{
getdata();
if(mailStatis == “Yes”)
{
e.Result = true;
}
else
{
e.Result = false;
}
}
private void getdata()
{
//GetUsername();
intid1 = Convert.ToInt16(workflowProperties.Item["ID"].ToString());
SPListobjList = workflowProperties.Web.Lists["Leave"];
SPListItemmyItem = workflowProperties.Web.Lists["Leave"].GetItemById(Convert.ToInt16(id1));
if((int)myItem["ID"]== id1)
{
id = Convert.ToInt16(myItem.ID);
Name = Convert.ToString(myItem["EmployeeName"]);
StartDate = Convert.ToString(myItem["StartDate"]);
EndDate = Convert.ToString(myItem["EndDate"]);
Status = Convert.ToString(myItem["PMStatus"]);
mailStatis = Convert.ToString(myItem["MailPM"]);
mailstatusadmin = Convert.ToString(myItem["MailAdmin"]);
adminappstatus = Convert.ToString(myItem["AdminStatus"]);
Reason = Convert.ToString(myItem["ReasonforLeave"]);
}
}
Step6: we can put a code activity in that ifElseActivity1and write the code condition for that activity

code condition Name(sendmailtouser)
private void sendmailtouser(objectsender, EventArgs e)
{
SPSitespSite; SPWeb spWeb; SPList spList;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using(spSite = new SPSite(“http://sp4:1″))
{
spSite.AllowUnsafeUpdates =true;
using(spWeb = spSite.OpenWeb())
{
spWeb.AllowUnsafeUpdates = true;
StringBuilder Body = new StringBuilder(“”);
Body.Append(“

Dear PM,
”);
Body.Append(“I need Leave from “ + StartDate + ” To “ + EndDate + ”
”);
Body.Append(“for the Reason of” + Reason + “
”);
Body.Append(“URL:Click Here to see Approve orReject
”);
Body.Append(“
”);
Body.Append(“Sincerely,
”);
//Body.Append(“Administrator,
”);
Body.Append(“”+ Name + “
”);
SPUtility.SendEmail(spWeb, false,false, “test@test.com”,“Hi”, Body.ToString(), false);
}
}
});
}
Step7: create code conditions and code activity for theother branch.
Finally it shows likebelow image

Step8: deploy this for the desired list (it would haveoption for initiate at the time of item created and updated)
Step9: In your site you can find that workflow (in workflowsettings of that list)
Step10:add an item to that list (you ll be receiving maildepends on status of that item)