CommentCollection Object (JavaScript API for Visio)
Applies to: Visio Online
Represents the CommentCollection for a given Shape.
Properties
| Property | Type | Description |
|---|---|---|
| items | Comment[] | A collection of comment objects. Read-only. |
See property access examples.
Relationships
None
Methods
| Method | Return Type | Description |
|---|---|---|
| getCount() | int | Gets the number of Comments. |
| getItem(key: string) | Comment | Gets the Comment using its name. |
| load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. |
Method Details
getCount()
Gets the number of Comments.
Syntax
CommentCollectionObject.getCount();
Parameters
None
Returns
int
getItem(key: string)
Gets the Comment using its name.
Syntax
CommentCollectionObject.getItem(key);
Parameters
| Parameter | Type | Description |
|---|---|---|
| key | string | Key is the name of the Comment to be retrieved. |
Returns
load(param: object)
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
Syntax
object.load(param);
Parameters
| Parameter | Type | Description |
|---|---|---|
| param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
Returns
void
Property access examples
Visio.run(function (ctx) {
var activePage = ctx.document.getActivePage();
var shapeName = "Position Belt.41";
var shape = activePage.shapes.getItem(shapeName);
var shapecomments= shape.comments;
shapecomments.load();
return ctx.sync().then(function () {
for(var i=0; i<shapecomments.items.length;i++)
{
var comment= shapecomments.items[i];
console.log("comment Author: " + comment.author);
console.log("Comment Text: " + comment.text);
console.log("Date " + comment.date);
}
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});