OfficeDev / office-js-docs

[ARCHIVED] Microsoft Office Add-ins API Reference Documentation
https://docs.microsoft.com/javascript/api/overview/office
398 stars 247 forks source link

Word Online: OBJ characters get inserted in a document having fields #1505

Closed abhijeetnarvekar closed 5 years ago

abhijeetnarvekar commented 5 years ago

I am creating a word addin which requires to get current selection

In Word Online if I upload the document containing fields and select data between fields and query getSelection API. OBJ characters get inserted in document

Attached sample document and video recording of issue: https://drive.google.com/drive/folders/1McawZdvswlO5iB3_8VSyymBY5cduMc6g?usp=sharing

Steps to reproduce:

  1. Open Word Online
  2. Upload document containing fields(Download from above URL)
  3. Run the below code
  4. Refresh document
  5. Observe fields property is lost and OBJ character get inserted.
Word.run(function (context) {
    var textSample = 'This is an example of the insert text method.';
    var range = context.document.getSelection();
    range.insertText(textSample, Word.InsertLocation.end);
    return context.sync().then(function () {
        console.log('Inserted the text at the end of the selection.');
    });  
}).catch(function (error) {
    console.log('Error: ' + JSON.stringify(error));
    if (error instanceof OfficeExtension.Error) {
        console.log('Debug info: ' + JSON.stringify(error.debugInfo));
    }
});

Thanks, Abhijeet

Reezaali commented 5 years ago

@abhijeetnarvekar - can you post your question on Stack Overflow and use the [office-js] tag please? You'll likely get a faster answer there. This repo is used for documentation. Thank you!

kbrandl commented 5 years ago

@abhijeetnarvekar thanks for reaching out and sorry to hear that you've run into this problem. As @Reezaali mentioned, issues in this GitHub repository (OfficeDev/office-js-docs) are intended for reporting errors/problems with the API documentation.

However, instead of posting this issue to Stack Overflow as Reeza suggested, please post it to the OfficeDev/office-js repository, which members of the product team monitor for customer-reported API issues such as this. Stack Overflow is the place for "how-to" questions, but API issues/problems should be reported in the OfficeDev/office-js repository. Thank you!