Office PowerPoint Add-in: update content after presentation started - powerpoint

I am developing an add-in for PowerPoint which receives data from a server with WebSockets. When data is received, I update the slide.
But, I want to know if it's possible to update slide content (Text, XmlSvg...) after the presentation is started? And how?
Currently, I update content like this but when I try during presentation, I got an internal error:
Office.context.document.setSelectedDataAsync(
myText,
{
coercionType: Office.CoercionType.Text
},
result => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(result.error.message);
}
}
);
Thanks for your help.

Related

Get the current selection on PowerPoint Add-In

I'm developing a Add-in for PowerPoint that inserts images in the document.
I'm currently able to insert the image, but what I'm not able to do is to replace a current selected image.
So, for example, imagine that:
The user added an image available on the Add-in, inside an empty slide
He then selected this image and wants to replace it with another one also available on the Add-in.
He clicks/selects the slide image, and then clicks on the image inside the Add-in that he wants to replace.
The thing is that I'm not able to get his selection with the Office API.
Can someone help me?
My current code looks like this:
const insertFile = (binaryStr: string) => {
Office.context.document.setSelectedDataAsync(
binaryStr,
{
coercionType: Office.CoercionType.Image,
},
(result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(result.error.message);
}
}
);
};
Try to use the getSelectedDataAsync method which reads the data contained in the current selection in the document.

SAPCAI quick replies displayed as attachments

I used SAPCAI (SAP Conversational AI is a French development platform like Azure Bot Service) to build my chatbot, but I'm using the Bot-Framework Webchat on my web app. Therefore, I don't have any C# or JS code. The problem is SAPCAI quick replies are displayed as "attachments". How can I fix that?
Expected
Got
What you want is the Quick replies type.
Quick replies: Same purpose as buttons, but disappear once clicked. Great if you don’t want the user to have to scroll up the conversation and click on a button again.
There is information about how to create click replies on this page. It seems to be in the format of:
{
"type": "quickReplies",
"content": {
"title": "TITLE",
"buttons": [
{
"title": "BUTTON_TITLE",
"value": "BUTTON_VALUE"
}
]
}
}
The important part would be "type": "quickReplies". Since you haven't provided any code I'm not sure if you know how to get to the stage where you enter/edit this JSON. From the documentation on the first page that I linked it would seem that you get to this via:
On the Actions tab of a skill (or on the Requirements tab), you can choose among other things to send messages.
Under the send message button you will be displayed a list of message types to send, quick replies is one of these types. See my screenshots here.
I hope this helps.
I'm not entirely sure how SAPCAI works, but if you are receiving a card in Web Chat, you can use a custom middleware store to convert the card's title to text and its buttons to suggested actions. Then you can add them to the activity in place of the attachment. Note, the store middleware below will convert all card to suggested actions, so you may want to add some additional logic if you do intend to use other cards in your dialog. Also, if the card is an AdaptiveCard, you will need to do some more modifications as well since those tend to more complex than rich cards.
Middleware
const store = createStore(
{},
({ dispatch}) => next => async action => {
if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
const { attachments, from: { role }} = action.payload.activity;
if (role === 'bot' && attachments) {
const text = attachments.map(({ content: { title }}) => title).join(' ');
const actions = attachments.map(({content: { buttons }}) => buttons).flat();
action.payload.activity.text = text;
action.payload.activity.attachments = [];
action.payload.activity.suggestedActions = { actions };
}
}
return next(action)
}
);
renderWebChat({
directLine,
store,
}, document.getElementById('webchat'));
Screenshot
Hope this helps!

Refresh Parent Form after Quick Create in Dynamics CRM 2016

In Dynamics CRM 2016 we have a Quick Create Form which works well. But once the Quick Create is done, and the record is saved (and the new record appears in the sub-grid in the parent form), the roll-up field under the sub-grid doesn't get re-refreshed on the screen until the user presses F5.
(we have some C# code to update the roll-up).
Does anyone know how to force the refresh of the main form after the Quick Create has successfully run?
You may add timeout on refresh event, and after 1-2 sec refresh once more.
function OnFormLoad() //add this function onload form
{
var subGrid = window.parent.document.getElementById("id of your subgrid")
if (subGrid !== null) {
if (subGrid.control)
subGrid.control.add_onRefresh(fnOnRefresh)
else
setTimeout(OnFormLoad, 500);
} else {
setTimeout(OnFormLoad, 500);
}
}
function fnOnRefresh() {
setTimeout(function() {
Xrm.Page.ui.controls.get("id of your subgrid").refresh();
}, 2000) //after 2 sec refresh subgrid
}
I would try stopping the OOB save event using the below snippet: Read more
function onSave(context) {
var saveEvent = context.getEventArgs();
saveEvent.preventDefault();
//save explicitly here
//reload the window here
}
And then save the entity in code using:
Xrm.Page.data.entity.save();
And then refresh/reload the browser window. I haven’t tried this but very rough theory :)
We got it working ... used what Timur suggested but just changed the last function to:
function fnOnRefresh() {
setTimeout(function() {
window.parent.location.reload(true);
}, 500)
}
Thank you

Outlook 2016 does not render logo (image) in Event Email invitation

We have an O365 add-in that works on Calendar. It puts HTML to the body of the invite. All works well except the Image we put. How to make the image appear in the Invitation email view?
var logo = "<div style=\"line-height:60px\"><img src=\"https://static-a.test.com/a2/custom-assets/enterprise/4714/isg_logo/d05aa76d58614c0e88b864eec963cec0.png\" height=\"30\" alt=\"Test Meet\" style=\"user-select: none;\" tabindex=\"0\"></div>";
var formattedBody = agenda
+ _.repeat(newLine, 1)
+ logo
+ testInvitation;
return Q.oinvoke(Office.context.mailbox.item.body, "setAsync", formattedUserBody, { coercionType: coercionType })
.then(function() {
logger.info("Add meeting completed successfully");
});
Is there another way to fix it or is it a known limitation of Outlook?
Logo renders properly in Calendar view, not on Email view
Some VSTO add-in can render the logo, but not Office 365 addin
Logo is seen in OWA and Mobile apps, but not in Outlook 2016 Mac and windows
We fixed the issue by following this link in Outlook 2013.
----- 01/09/19 - Update on Issues following the Solution provided ----------
The primary issue reported got fixed by the solution. Now, we can see Logo in email invitation, but it is broken in Calendar view.
The changed code:
var formattedBody = agenda
+ _.repeat(newLine, 1)
+  "<img src='cid:testMeet.png'/>"
+ testInvitation;
Office.context.mailbox.item.addFileAttachmentAsync(
"https://static-a.test.com/a2/custom-assets/enterprise/4714/isg_logo/d05aa76d58614c0e88b864eec963cec0.png",
"testMeet.png",
{asyncContext: null, isInline: true},
function (asyncResult)  {
Office.context.mailbox.item.body.setAsync(
formattedBody,
          { coercionType: Office.CoercionType.Html, asyncContext:null });
});
This fix also breaks the logo rendering in Outlook Mobile App. Please advise as we need to have the logo between Agenda (if any) and our Text.
---- Screenshot 01/16/2019 -----
------ Outlook Matrix 01/26/2019 -------
Adding an image to the body this way is incorrect, and as you have seen, sometime buggy. Instead you should use addFileAttachmentAsync, more specifically the isInline property, which will allow you to use a cid: reference to add your image.
An example of this would be:
Office.context.mailbox.item.addFileAttachmentAsync(
"https://static-a.test.com/a2/custom-assets/enterprise/4714/isg_logo/d05aa76d58614c0e88b864eec963cec0.png",
"testMeet.png",
{asyncContext: null, isInline: true}, 
function (asyncResult)  {
Office.context.mailbox.item.body.setAsync(
          "<img src='cid:testMeet.png'/>",
          { coercionType: Office.CoercionType.Html, asyncContext: null });
});

Drupal Node Forms - Image field: How to directly upload an image after choosing a file (no need to click upload button)

I'm trying to change the default behavior of Drupal when adding an image through image field on a content type.
When you choose an image to assign to a node, it's not directly uploaded. You also need to click "upload" to display the preview of your image, and this is not really user friendly.
How can I change this (programmatically) to make Drupal start uploading directly the image after choosing the file.
Thank you for help
You can do it this way:
(function ($) {
Drupal.behaviors.autoUpload = {
attach: function(context, settings) {
$('.form-item input.form-submit[value=Upload]', context).hide();
$('.form-item input.form-file', context).change(function() {
$parent = $(this).closest('.form-item');
setTimeout(function() {
if(!$('.error', $parent).length) {
$('input.form-submit[value=Upload]', $parent).mousedown();
}
}, 100);
});
$('.form-item input.form-submit[value=Transférer]', context).hide();
$('.form-item input.form-file', context).change(function() {
$parent = $(this).closest('.form-item');
setTimeout(function() {
if(!$('.error', $parent).length) {
$('input.form-submit[value=Transférer]', $parent).mousedown();
}
}, 100);
});
}
};
})(jQuery);
This solution works with either english and french browsers. Unlike AutoUpload module, which only works on browsers configured in english. Note the [value=Upload] / [value=Upload] attribute
I found a similar post:
https://drupal.stackexchange.com/questions/31121/how-can-i-automatically-upload-images-on-file-selection-rather-than-pressing-the
It's exactly what I need..
You should be able to use http://drupal.org/project/imce for your needs.
I am not sure about the Image field but when I encountered this issue I decided letting users add images in body since it is a much easier option for durpal - When inserting images in text They will show immediately .
IMCE + filefield seems like a viable option for your direct needs,They do mention AJAX support.

Resources