Today we announced the release of Office Developer Tools March 2014 Update which includes a number of updates for Office & SharePoint developers.
One such update is integrating document experiences into your Cloud Business Apps (CBA)
You can now relate host web document libraries to your business entities and also create Office documents on the fly or upload existing documents in the runtime without writing a single line of code.
Let me walkthrough the document experience with a sample:
Here is my CBA app with a Product entity:
Product entity has the following fields: ID, SKU, Title, Description and Category
Now that I have defined my Product entity and create products, I want to be able to associate documents for every product.
In many cases, organizations (with SharePoint environment) define a document library schema for such requirements.
For our sample, let us assume we have a ProductManuals document library in the host web to store documents associated with every product (record).
Add SharePoint Document Library
Let us add a SharePoint data source – Right click on .Server Project->Data Sources and select Add Data Source…
In the Data Source Wizard, select SharePoint as the data source type and click Next to continue:
By default, the wizard will use the host web as the SharePoint site it is connecting to. Accept the defaults and click Next to continue.
p.s: It is recommended to use host web as the desired destination to work with in your apps for SharePoint.
The next page in the wizard provides a tree view of the SharePoint entities: Lists and Document Libraries available in the host web. You can also search for the specific list or library you are looking for.
In our case, we are looking for a library called ‘ProductManuals’, so lets search for it.
In the search results, select ProductManuals and click Finish
This will add the SharePoint data source and the document library to your CBA.
Relate Product Entity and ProductManuals Document Library
Now you are able to relate the Product entity with the ProductManuals document library to associate products with documents.
Switch back to Product entity and click on Relationship in the Add toolbar:
Create a One to Many relationship between the Product entity and ProductManuals document library.
As you can see I have the selected SKU (Products) and ProductSKU (ProductManuals) as the related fields as they identify a specific product in my database and in SharePoint.
- The Id field in the entity and Id field in SharePoint document library may not be the best choice to define the relationship as the field properties vary data sources respectively.
- Make sure you select a list field in SharePoint as list fields are available to all content types.
Lets create the required screens for the Product entity so we can add products.
In the Client project, right click on Screens and select Add Screen…
Here is another new feature we have added for Mar2014 update: Common Screen Set – It creates the Browse, View and Add/Edit screens for an entity with a click of a button!
Select Common Screen Set and select Product as the Screen Data and make sure you also check Product ProductManuals under Additional Data to include:
This will create the screens and also add the ability to create associated documents for every product as we already defined the relationship:
We are all set to see how this looks now and we didn’t even write a single line of code yet!
Debug the App
Press F5 to debug the app.
The default browse screen allows you to add a product. Just click Add to add a new product.
The product is now added. Click on the product to view the product details:
As you can see, you can not only view the product details but there is an additional tab Product Manuals to view the associated documents.
Currently there are no documents. Click Add to add a document:
The Add popup allows you to create:
1) New (blank) Office Documents (requires Office Web Apps)
2) Documents from Content Types (in the document library)
3) Upload existing documents
Lets upload a file: Select UPLOAD EXISTING FILE and browse to the file and upload it
p.s: It may take a while depending on the size of the document
Let us now create a new Word document: Click Add and the click on Word document
You will be redirected to Office Online where you can continue working on the document.
Hint: To change the document title, click on Document on the top blue bar and type your desired title
Office Online does not have a Save button, instead you can just click Browser Back button to return to the app.
To view the document, just click on the document title. Depending on your environment, the document will open in Office Client or Office Online.
This new experience as we saw provides a set of new document controls (for host web document libraries) which allows users to related business entities with the document library and :
- Create Office documents
- Open documents in Office Online or Office Client
- Upload existing documents
Download the March 2014 update today to try out the new document feature and let us know if you have any feedback!
You can also submit your feedback through Visual Studio Office/SharePoint User Voice site.