-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Project snippets #16
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
id: ciz79iwgk0000456w9wch1l0m | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change filename to get-project-information |
||
gist: '' | ||
source: PROJECT | ||
author: Microsoft | ||
name: Get information about the project | ||
description: >- | ||
Shows how to use project level fields to find things like the project's start | ||
date | ||
script: | ||
content: | | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove 2 blank lines |
||
|
||
$('#run').click(getProjectInformation); | ||
|
||
// Get the specified fields for the active project. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove indentation |
||
function getProjectInformation() { | ||
var fields = | ||
[Office.ProjectProjectFields.Start, Office.ProjectProjectFields.Finish, Office.ProjectProjectFields.GUID]; | ||
var fieldValues = ['Start: ', ' Finish: ', ' GUID: ']; | ||
var index = 0; | ||
getField(); | ||
|
||
// Get each field, and then display the field values in the add-in. | ||
function getField() { | ||
if (index == fields.length) { | ||
var output = ''; | ||
for (var i = 0; i < fieldValues.length; i++) { | ||
output += fieldValues[i]; | ||
} | ||
console.log(output); | ||
} | ||
else { | ||
Office.context.document.getProjectFieldAsync( | ||
fields[index], | ||
function (result) { | ||
|
||
// If the call is successful, get the field value and then get the next field. | ||
if (result.status === Office.AsyncResultStatus.Succeeded) { | ||
fieldValues[index] += result.value.fieldValue; | ||
getField(index++); | ||
} | ||
else { | ||
onError(result.error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use console.log(result.error) |
||
} | ||
} | ||
); | ||
} | ||
} | ||
} | ||
|
||
function onError(error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
console.log(error); | ||
} | ||
language: typescript | ||
style: | ||
content: /* Your style goes here */ | ||
language: css | ||
template: | ||
content: |- | ||
<button id="run" class="ms-Button"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add short description: "This snippet demonstrates how to get project information such as..." |
||
<span class="ms-Button-label">Run</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run -> Get project information |
||
</button> | ||
language: html | ||
libraries: |- | ||
// Office.js | ||
https://appsforoffice.microsoft.com/lib/1/hosted/Office.js | ||
|
||
// NPM libraries | ||
jquery | ||
office-ui-fabric-js/dist/js/fabric.min.js | ||
office-ui-fabric-js/dist/css/fabric.min.css | ||
office-ui-fabric-js/dist/css/fabric.components.min.css | ||
@microsoft/office-js-helpers/dist/office.helpers.min.js | ||
core-js/client/core.min.js | ||
|
||
// IntelliSense: Use dt~library_name for DefinitelyTyped or URLs to d.ts files | ||
dt~office-js | ||
dt~jquery | ||
dt~core-js | ||
@microsoft/office-js-helpers/dist/office.helpers.d.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
id: ciz78veu00000456sgv494kcb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change filename to get-task-guid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id: '' |
||
gist: '' | ||
source: PROJECT | ||
author: Microsoft | ||
name: Get Task GUID | ||
description: Get the selected task's GUID. | ||
script: | ||
content: |- | ||
$('#run').click(run); | ||
|
||
function run() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. run -> getTaskGUID |
||
Office.context.document.getSelectedTaskAsync( | ||
function (asyncResult) { | ||
if (asyncResult.status === Office.AsyncResultStatus.Failed) { | ||
console.log(asyncResult.error.message); | ||
} else { | ||
console.log('Selected task GUID is ' + asyncResult.value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. task -> task's |
||
} | ||
} | ||
); | ||
} | ||
language: typescript | ||
style: | ||
content: /* Your style goes here */ | ||
language: css | ||
template: | ||
content: |- | ||
<button id="run" class="ms-Button"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add short description |
||
<span class="ms-Button-label">Run</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run -> Get task GUID |
||
</button> | ||
language: html | ||
libraries: |- | ||
// Office.js | ||
https://appsforoffice.microsoft.com/lib/1/hosted/Office.js | ||
|
||
// NPM libraries | ||
jquery | ||
office-ui-fabric-js/dist/js/fabric.min.js | ||
office-ui-fabric-js/dist/css/fabric.min.css | ||
office-ui-fabric-js/dist/css/fabric.components.min.css | ||
@microsoft/office-js-helpers/dist/office.helpers.min.js | ||
core-js/client/core.min.js | ||
|
||
// IntelliSense: Use dt~library_name for DefinitelyTyped or URLs to d.ts files | ||
dt~office-js | ||
dt~jquery | ||
dt~core-js | ||
@microsoft/office-js-helpers/dist/office.helpers.d.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to id: ''