Tag Archive: Sandbox solution

Just release from last month, Office 365 is opening a new opportunity for your professionals and small businesses Collaboration to everyone. License price is easy to calculate with $6 per person per month, Office 365 is not expensive to bring your business on Cloud and  help you build solutions that leverage SharePoint Online, Exchange Online and Lync Online, Office Web App (Excel, Word, PowerPoint and OneNote)

And a very new release from Microsoft,  Office 365 Developer Training Kit – June 2011 allow you learn how to build collaborative and communication focused cloud solutions that run in Office 365 using Visual Studio 2010 and the .NET Framework

In this post, I would like to introduce my experience to build a solution with Visual Studio 2010 and deploy in Office 365 SharePoint site.

1. First of all, you need to install Visual Studio 2010 SharePoint Power Tools, this extension allow Visual Studio create SharePoint Visual web parts that can be deployed in a sandboxed solution and displays build errors on compile time

2. Create an empty SharePoint 2010 project and provide your local SharePoint 2010 for debugging

3. Add an Visual Webpart for Sandboxed Solution with several asp controls as below

All Lists of this site:
<asp:DropDownList ID=”ddlLists” runat=”server”></asp:DropDownList>
<asp:Button ID=”btnPopularDetails” runat=”server” Text=”Show Details” OnClick=”btnPopularDetails_Click” />
<asp:GridView ID=”gridListsDetails” runat=”server”></asp:GridView></p>

4. Add following code to get all existed list except document library on page load and show details info of selected list to Gridview when clicked on “Show Details” button

 public partial class VisualWebPart1 : System.Web.UI.WebControls.WebParts.WebPart
protected override void OnInit(EventArgs e)
}protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
SPWeb web = SPContext.Current.Web;
var listNames = from SPList list in web.Lists
where list.BaseTemplate != SPListTemplateType.DocumentLibrary
select list.Title;
ddlLists.DataSource = listNames;
}protected void btnPopularDetails_Click(object sender, EventArgs e)
SPList sourceList = SPContext.Current.Web.Lists.TryGetList(ddlLists.SelectedValue);
SPQuery qry = new SPQuery();
qry.ViewFieldsOnly = true;
qry.ViewFields = “<FieldRef Name = ‘Title’ /><FieldRef Name = ‘Author’ />”;
qry.RowLimit = 20;
gridListsDetails.DataSource = sourceList.GetItems(qry).GetDataTable();
gridListsDetails.EmptyDataText = string.Format(“List {0} have no data”, ddlLists.SelectedValue);

5. Build project and find Office365.wsp under Debug/Bin folder

6. Login to Office 365 with your account

7. Open  Site Setting and navigate to Solution Galleries

And then, Upload your Solution to this gallery, after that click on Active button to active your solution

8. Finally, Create a new page and insert your webpart to see the result

Related Video resources:

Hoang Nhut Nguyen
Email: nhutcmos@gmail.com
Skype: hoangnhut.nguyen

When we try to create SharePoint 2010 project with Sequential or State Machine Workflow project template from Visual Studio 2010 – there’re only option allow you will get is to deploy such workflow to the farm. It’s not available if you want to develop solution for the cloud.

However, there is a way to workaround depend on the level of customization you need for your workflow.

1. Open your target site by SharePoint Designer 2010.

2. Click Workflows under Site Objects and click on the ribbon Reusable Workflow button.

3. Set your workflow a name, after that SharePoint Designer will open a UI allow you to create the workflow by adding workflow activities into steps.

Now you can create your sequence workflow, but you need transfer this workflow to Visual Studio and deploy it with the rest of your solutions as below steps:

1. Click Save as Template ribbon button to create the base for your workflow,

2. This step will save WSP file workflow solution to the Site Assets library (at ~site/SiteAssets/)

3. Download a WSP file and open with Visual Studio 2010.

4. From Visual Studio 2010 project, click Import SharePoint Solution Package.

5.  Now you will specify type of your solution, which you can set as Sandbox solution and give the file path for the your sandbox solution.

After your solution has been imported to VS 2010, you can to make changes to it and add new workflow activities in Visual Studio. When finished, you can build the project again for WSP file or include it as a part of your overall deployment.

%d bloggers like this: