Skip to content

Commit 9c97514

Browse files
Merge pull request SharePoint#10111 from andrewconnell/content-fix/pr-fix-10104
fix broken links + markdown issues
2 parents 2b32cdb + 839b044 commit 9c97514

8 files changed

+797
-930
lines changed

docs/sp-add-ins/add-first-run-logic-to-the-provider-hosted-add-in.md

Lines changed: 112 additions & 137 deletions
Large diffs are not rendered by default.

docs/sp-add-ins/add-sharepoint-write-operations-to-the-provider-hosted-add-in.md

Lines changed: 32 additions & 31 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,61 @@
11
---
22
title: Get a quick overview of the SharePoint object model
3-
description: Get introduced to the content hierarchy, and client-side runtime and batching.
3+
description: Get introduced to the content hierarchy, and client-side runtime and batching.
44
ms.date: 09/26/2023
55
ms.localizationpriority: high
66
ms.service: sharepoint
77
---
8-
9-
108
# Get a quick overview of the SharePoint object model
119

1210
[!INCLUDE [sp-add-in-deprecation](../../includes/snippets/sp-add-in-deprecation.md)]
1311

14-
This is the fourth in a series of articles about the basics of developing provider-hosted SharePoint Add-ins. You should first be familiar with [SharePoint Add-ins](sharepoint-add-ins.md) and the previous articles in this series, which you can find at [Get started creating provider-hosted SharePoint Add-ins](get-started-creating-provider-hosted-sharepoint-add-ins.md#SP15createprovider_nextsteps).
15-
12+
This is the fourth in a series of articles about the basics of developing provider-hosted SharePoint Add-ins. You should first be familiar with [SharePoint Add-ins](sharepoint-add-ins.md) and the previous articles in this series, which you can find at [Get started creating provider-hosted SharePoint Add-ins](get-started-creating-provider-hosted-sharepoint-add-ins.md#next-steps).
13+
1614
> [!NOTE]
1715
> If you have been working through this series about provider-hosted add-ins, you have a Visual Studio solution that you can use to continue with this topic. You can also download the repository at [SharePoint_Provider-hosted_Add-Ins_Tutorials](https://github.com/OfficeDev/SharePoint_Provider-hosted_Add-ins_Tutorials) and open the BeforeSharePointWriteOps.sln file.
1816
19-
In this article you'll take a brief break from coding to get a quick overview of the SharePoint Client-side Object Model (CSOM). This model is large and well-documented in MSDN with reference topics, "how-to's", and code samples. In this article, we can only provide the tip of the tip of the tip of the iceberg. But even a very short introduction will make much of the code you see in this series a lot less mysterious.
17+
In this article you'll take a brief break from coding to get a quick overview of the SharePoint Client-side Object Model (CSOM). This model is large and well-documented in MSDN with reference topics, "how-to's", and code samples. In this article, we can only provide the tip of the tip of the tip of the iceberg. But even a very short introduction will make much of the code you see in this series a lot less mysterious.
2018

2119
## Content hierarchy
2220

2321
The following table shows the hierarchy of content in SharePoint and the CSOM classes that represent them. Each of these entities has children of the type just under it.
24-
2522

26-
|**Entity**|**Class**|**Remarks**|
27-
|:-----|:-----|:-----|
28-
|SharePoint on-premises farm or SharePoint Online subscription (also called a tenant)||There is only limited programmatic access to this level in CSOM. There is no Farm or Subscription or Tenant class, for example. (SharePoint's server-side object model, which cannot be used in add-ins, enables programmatic access to these entities.)|
29-
|site collection|**Site**|A collection of websites that are grouped together for mainly administrative reasons and to house SharePoint components, such as branded master pages or custom security groups, that can be applied to all the child websites. All websites belong to some site collection.|
30-
|website|**Web**|A set of pages and SharePoint components. Can have subwebsites.|
31-
|list|**List**|Document libraries and other kinds of file libraries are also at this level. A document library is a special kind of list in which each row includes an attached document, and the other columns are data about the document, such as its author, when it was last edited, and who has it checked out. |
32-
|list item|**ListItem**|A row in a list—that is, a list item—with particular values in the fields of the row. Also has a type. See next row. |
33-
|list item|**Content Type**|The type of a list item. These are represented by the **ContentType** class. Each is basically a set of columns and metadata. The simplest is the built-in **Item** content type. All other content types are derived from **Item**. SharePoint includes many built-in content types, such as Event and Announcement. |
34-
|column|**Field**|A **Field** object includes not only information about the underlying data type, but also information about how the data is formatted and rendered on forms, such as the forms for creating, displaying, and editing specific list items.|
23+
| **Entity** | **Class** | **Remarks** |
24+
| :----------------------------------------------------------------------------------- | :--------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25+
| SharePoint on-premises farm or SharePoint Online subscription (also called a tenant) | | There is only limited programmatic access to this level in CSOM. There is no Farm or Subscription or Tenant class, for example. (SharePoint's server-side object model, which cannot be used in add-ins, enables programmatic access to these entities.) |
26+
| site collection | **Site** | A collection of websites that are grouped together for mainly administrative reasons and to house SharePoint components, such as branded master pages or custom security groups, that can be applied to all the child websites. All websites belong to some site collection. |
27+
| website | **Web** | A set of pages and SharePoint components. Can have subwebsites. |
28+
| list | **List** | Document libraries and other kinds of file libraries are also at this level. A document library is a special kind of list in which each row includes an attached document, and the other columns are data about the document, such as its author, when it was last edited, and who has it checked out. |
29+
| list item | **ListItem** | A row in a list—that is, a list item—with particular values in the fields of the row. Also has a type. See next row. |
30+
| list item | **Content Type** | The type of a list item. These are represented by the **ContentType** class. Each is basically a set of columns and metadata. The simplest is the built-in **Item** content type. All other content types are derived from **Item**. SharePoint includes many built-in content types, such as Event and Announcement. |
31+
| column | **Field** | A **Field** object includes not only information about the underlying data type, but also information about how the data is formatted and rendered on forms, such as the forms for creating, displaying, and editing specific list items. |
3532

36-
You can programmatically create custom lists, content types, column types, and list items.
33+
You can programmatically create custom lists, content types, column types, and list items.
3734

3835
In addition to content, the CSOM gives you access to users, groups, roles and permissions, taxonomy, search, and more.
3936

40-
<a name="CSOMBatching"> </a>
4137
## Client-side runtime and batching
4238

43-
CSOM uses a batching system. Chunks of managed code are converted into XML and sent to the server in a single HTTP request. For every command, a corresponding server object model call is made, and the server returns a response to the client in JavaScript Object Notation (JSON) format.
39+
CSOM uses a batching system. Chunks of managed code are converted into XML and sent to the server in a single HTTP request. For every command, a corresponding server object model call is made, and the server returns a response to the client in JavaScript Object Notation (JSON) format.
4440

45-
SharePoint code on a client begins by retrieving a client context object that represents the current request context, including the identity of the SharePoint website (and its parent site collection), and through this context you can obtain access to CSOM objects. The following is the basic structure that you will see again and again.
41+
SharePoint code on a client begins by retrieving a client context object that represents the current request context, including the identity of the SharePoint website (and its parent site collection), and through this context you can obtain access to CSOM objects. The following is the basic structure that you will see again and again.
4642

4743
```csharp
48-
using (var clientContext = spContext.CreateUserClientContextForSPHost())
49-
{
50-
// CRUD operation or query code goes here.
44+
using (var clientContext = spContext.CreateUserClientContextForSPHost())
45+
{
46+
// CRUD operation or query code goes here.
5147
52-
clientContext.ExecuteQuery();
53-
}
48+
clientContext.ExecuteQuery();
49+
}
5450
```
5551

5652
Note the following about this code:
5753

5854
- The `spContext` object is of the type **SharePointContext** and is defined in the SharePointContext.cs (or .vb) file that is generated by the Office Developer Tools for Visual Studio. This file can be modified, but it is not often that you need to do so. For most SharePoint Add-in projects, this file and the TokenHelper.cs (or .vb) file, which is also generated by the tools, effectively function as extensions of CSOM itself.
59-
6055
- The `clientContext` object is the CSOM type **ClientContext**.
61-
6256
- The **ExecuteQuery** method bundles up the CRUD operation code in an XML message that it sends to the SharePoint server. There it is translated into equivalent server-side object model code and executed.
6357

64-
There was an example of this pattern in the previous article of this series, in the `GetLocalEmployeeName` method shown here.
58+
There was an example of this pattern in the previous article of this series, in the `GetLocalEmployeeName` method shown here.
6559

6660
```csharp
6761
private string GetLocalEmployeeName()
@@ -82,14 +76,8 @@ private string GetLocalEmployeeName()
8276
Note the following about this method:
8377

8478
- The first two lines in the **using** block appear to get references to the list and the list item object. But actually when these lines execute in the SharePoint client-side runtime, they are simply translated into an XML format. The **ExecuteQuery** method sends that XML to the server.
79+
- The **Load** method adds something extra to the message: it tells the server to send the specified object down to the client. The **ExecuteQuery** method receives this object (as JSON) and uses it to initialize the client-side `localEmployee` variable. Subsequent client-side code then references that **ListItem** object and its members. As you can see, the next line references the value of the item's `"Title"` field. This line would have thrown an exception if the **Load** method had not been called because the object doesn't really exist on the client-side until it is loaded.
8580

86-
- The **Load** method adds something extra to the message: it tells the server to send the specified object down to the client. The **ExecuteQuery** method receives this object (as JSON) and uses it to initialize the client-side `localEmployee` variable. Subsequent client-side code then references that **ListItem** object and its members. As you can see, the next line references the value of the item's `"Title"` field. This line would have thrown an exception if the **Load** method had not been called because the object doesn't really exist on the client-side until it is loaded.
87-
8881
## Next steps
89-
<a name="Nextsteps"> </a>
9082

9183
In the next article, we get back to coding and learn how to [add SharePoint write operations to the provider-hosted add-in](add-sharepoint-write-operations-to-the-provider-hosted-add-in.md).
92-
93-
94-
95-

0 commit comments

Comments
 (0)