Skip to content

Commit

Permalink
[Outlook] Add sample for MailboxEnums.DelegatePermissions (#2082)
Browse files Browse the repository at this point in the history
  • Loading branch information
samantharamon authored Oct 4, 2024
1 parent 4bc644c commit 531b560
Show file tree
Hide file tree
Showing 20 changed files with 218 additions and 1,058 deletions.
96 changes: 0 additions & 96 deletions docs/code-snippets/office-snippets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4126,102 +4126,6 @@ Office.Settings#set:member(1):
function setMySetting() {
Office.context.document.settings.set('mySetting', 'mySetting value');
}
Office.SharedProperties:interface:
- |-
function performOperation() {
Office.context.mailbox.getCallbackTokenAsync({
isRest: true
},
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value !== "") {
Office.context.mailbox.item.getSharedPropertiesAsync({
// Pass auth token along.
asyncContext: asyncResult.value
},
function (asyncResult1) {
let sharedProperties = asyncResult1.value;
let delegatePermissions = sharedProperties.delegatePermissions;
// Determine if user can do the expected operation.
// E.g., do they have Write permission?
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
// Construct REST URL for your operation.
// Update <version> placeholder with actual Outlook REST API version e.g. "v2.0".
// Update <operation> placeholder with actual operation.
let rest_url = sharedProperties.targetRestUrl + "/<version>/users/" + sharedProperties.targetMailbox + "/<operation>";
$.ajax({
url: rest_url,
dataType: 'json',
headers:
{
"Authorization": "Bearer " + asyncResult1.asyncContext
}
}
).done(
function (response) {
console.log("success");
}
).fail(
function (error) {
console.log("error message");
}
);
}
}
);
}
}
);
}
Office.SharedProperties#delegatePermissions:member:
- |-
function performOperation() {
Office.context.mailbox.getCallbackTokenAsync({
isRest: true
},
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value !== "") {
Office.context.mailbox.item.getSharedPropertiesAsync({
// Pass auth token along.
asyncContext: asyncResult.value
},
function (asyncResult1) {
let sharedProperties = asyncResult1.value;
let delegatePermissions = sharedProperties.delegatePermissions;
// Determine if user can do the expected operation.
// E.g., do they have Write permission?
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
// Construct REST URL for your operation.
// Update <version> placeholder with actual Outlook REST API version e.g. "v2.0".
// Update <operation> placeholder with actual operation.
let rest_url = sharedProperties.targetRestUrl + "/<version>/users/" + sharedProperties.targetMailbox + "/<operation>";
$.ajax({
url: rest_url,
dataType: 'json',
headers:
{
"Authorization": "Bearer " + asyncResult1.asyncContext
}
}
).done(
function (response) {
console.log("success");
}
).fail(
function (error) {
console.log("error message");
}
);
}
}
);
}
}
);
}
Office.TableBinding#addColumnsAsync:member(1):
- |-
// The following example adds a single column with three rows to a bound table with the id "myTable"
Expand Down
16 changes: 16 additions & 0 deletions docs/code-snippets/outlook-snippets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,22 @@ Office.MailboxEnums.AttachmentStatus:enum:
}
Office.context.mailbox.item.addHandlerAsync(Office.EventType.AttachmentsChanged, myHandlerFunction, myCallback);
Office.MailboxEnums.DelegatePermissions:enum:
- |-
Office.context.mailbox.item.getSharedPropertiesAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error("The current folder or mailbox isn't shared.");
return;
}
const delegatePermissions = result.value.delegatePermissions;
// Check if the user has write permissions to the shared resource.
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
console.log("User has write permissions to the shared resource.");
// Perform the necessary operations.
}
});
Office.MailboxEnums.InfobarActionType:enum:
- |-
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ remarks: >-
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!-- -->**:
Compose or Read
#### Examples
```TypeScript
Office.context.mailbox.item.getSharedPropertiesAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error("The current folder or mailbox isn't shared.");
return;
}
const delegatePermissions = result.value.delegatePermissions;
// Check if the user has write permissions to the shared resource.
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
console.log("User has write permissions to the shared resource.");
// Perform the necessary operations.
}
});
```
isPreview: false
isDeprecated: false
fields:
Expand Down
108 changes: 0 additions & 108 deletions docs/docs-ref-autogen/outlook/outlook/office.sharedproperties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,6 @@ remarks: >-
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!-- -->**:
Compose or Read
#### Examples
```TypeScript
function performOperation() {
Office.context.mailbox.getCallbackTokenAsync({
isRest: true
},
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value !== "") {
Office.context.mailbox.item.getSharedPropertiesAsync({
// Pass auth token along.
asyncContext: asyncResult.value
},
function (asyncResult1) {
let sharedProperties = asyncResult1.value;
let delegatePermissions = sharedProperties.delegatePermissions;
// Determine if user can do the expected operation.
// E.g., do they have Write permission?
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
// Construct REST URL for your operation.
// Update <version> placeholder with actual Outlook REST API version e.g. "v2.0".
// Update <operation> placeholder with actual operation.
let rest_url = sharedProperties.targetRestUrl + "/<version>/users/" + sharedProperties.targetMailbox + "/<operation>";
$.ajax({
url: rest_url,
dataType: 'json',
headers:
{
"Authorization": "Bearer " + asyncResult1.asyncContext
}
}
).done(
function (response) {
console.log("success");
}
).fail(
function (error) {
console.log("error message");
}
);
}
}
);
}
}
);
}
```
isPreview: false
isDeprecated: false
type: interface
Expand All @@ -93,59 +38,6 @@ properties:
content: 'delegatePermissions: MailboxEnums.DelegatePermissions;'
return:
type: '<xref uid="outlook!Office.MailboxEnums.DelegatePermissions:enum" />'
description: |-
#### Examples
```TypeScript
function performOperation() {
Office.context.mailbox.getCallbackTokenAsync({
isRest: true
},
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value !== "") {
Office.context.mailbox.item.getSharedPropertiesAsync({
// Pass auth token along.
asyncContext: asyncResult.value
},
function (asyncResult1) {
let sharedProperties = asyncResult1.value;
let delegatePermissions = sharedProperties.delegatePermissions;
// Determine if user can do the expected operation.
// E.g., do they have Write permission?
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
// Construct REST URL for your operation.
// Update <version> placeholder with actual Outlook REST API version e.g. "v2.0".
// Update <operation> placeholder with actual operation.
let rest_url = sharedProperties.targetRestUrl + "/<version>/users/" + sharedProperties.targetMailbox + "/<operation>";
$.ajax({
url: rest_url,
dataType: 'json',
headers:
{
"Authorization": "Bearer " + asyncResult1.asyncContext
}
}
).done(
function (response) {
console.log("success");
}
).fail(
function (error) {
console.log("error message");
}
);
}
}
);
}
}
);
}
```
- name: owner
uid: 'outlook!Office.SharedProperties#owner:member'
package: outlook!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ remarks: >-
**[Applicable Outlook
mode](https://learn.microsoft.com/office/dev/add-ins/outlook/outlook-add-ins-overview#extension-points)<!-- -->**:
Compose or Read
#### Examples
```TypeScript
Office.context.mailbox.item.getSharedPropertiesAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error("The current folder or mailbox isn't shared.");
return;
}
const delegatePermissions = result.value.delegatePermissions;
// Check if the user has write permissions to the shared resource.
if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Write) != 0) {
console.log("User has write permissions to the shared resource.");
// Perform the necessary operations.
}
});
```
isPreview: false
isDeprecated: false
fields:
Expand Down
Loading

0 comments on commit 531b560

Please sign in to comment.