When the user clicks a button in the ribbon, I want to open the taskbar (when it is not opened already) and then I want to execute code depending on which button in the ribbon was clicked.
I m using vue.js for the taskpane.
I haven't tried this, but it's a suggestion that's too complicated to put into a comment:
For each button, add the <ExtensionPoint> and <Control> markup in the add-in's manifest. Details are in Create Add-in Commands. Set the Action type to ShowTaskpane for all the buttons. For each of the actions, set the <SourceLocation>'s resid to a different string. Then in the <Resources><Urls> section, set each of the resid strings to the URL of the taskpane page, but have a different query parameter on the end of each of them.
<bt:Urls>
<bt:Url id="residButton1" DefaultValue="https://contoso.com/Home.aspx?Button1">
<bt:Url id="residButton2" DefaultValue="https://contoso.com/Home.aspx?Button2" />
</bt:Url>
Then have startup logic in the taskpane page that reads the query parameter to determine which button was pressed. The startup logic can be in a function assigned to Office.initialize or in a callback to Office.onReady.
Related
In Outlook web addin I have provided the following property
<DisplayName DefaultValue="My test addin" />
This property is used in the following three locations:
In main Menu which shows up on clicking the three dots "..." on the right of an email :
On the custom addin page :
On the addin header :
All of the above three locations use the same label property and image. Is there a way to provide a different text label for each of the above?
Thanks
Currently, the feature to customize the display name at different locations, is not a part of the product. We track Outlook add-in feature requests on our user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.
We have several Excel add-ins in AppSource. At the moment, we have a button in Ribbon for Documentation, clicking on the button opens the documentation webpage in a taskpane in Excel.
We feel that as the taskpane is small, people are unlikely to read documentation over there. So a better way would be to open the documentation webpage in a browser outside Excel.
We notice that in Script Lab, clicking on the Reference Docs opens a small window which contains open link in new window. Then, we need to click on that link to finally open that in a browser:
https://user-images.githubusercontent.com/774409/81099107-ab068e80-8f0a-11ea-9633-eba5c1e42f90.png
So do we have to have this intermediate window? Cannot we open directly a web page from a button in Ribbon in a browser outside Excel?
PS: I don't want to use Dialog API to show documentation, because it seems that when the Dialog window is open, we cannot use Excel at the same time?
In manifest, you could make it UI less, and specifies the source code file for operations that an add-in exposes through add-in commands that execute a JavaScript function instead of displaying UI,
<DesktopFormFactor>
<FunctionFile resid="residDesktopFuncUrl" />
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<!-- information about this extension point -->
</ExtensionPoint>
</DesktopFormFactor>
and in the FunctionFile you could add a function, which can call Office.context.ui.openBrowserWindow(url) to launch the URL in the default browser outside of excel
Office.context.ui.openBrowserWindow("https://github.com");
The document can be found at here, which describes how to implement the function defined by FunctionName in the manifest.
From my manifest.xml
<bt:Url id="Contoso.DesktopFunctionFile.Url" DefaultValue="https://localhost:4000/excel-refresh" />
From my function file
Office.context.ui.displayDialogAsync('https://localhost:4000/excel-dialog?action=loading', {height:50, width:50}, dialogCallback)
Instead of loading my page in Excel Online itself, the add-in prompts me to open it in a new tab. After clicking Allow, my html page does load in a new tab. I am using the same host and port so this should not be happening.
Screenshot of generic popup that appears
Based on the comments under the OP's question, the solution is to pass and Options object to the call of displayDialogAsync that sets displayInIframe to true. Example:
displayDialogAsync("https://myDomain/myPage.html", {height:50, width:50, displayInIframe: true}, dialogCallback);
i would like to know if it is possible to intercept the event generated by the Ribbon Button of an Excel Addin. I'm able to access to the .xlam source but seems there is no code in it that intercept that event, so I think the handler is in the compiled component. Is my assessment correct? And then, if yes, can I intercept a click on a button of the ribbon, maybe using an Application Level Handler?
Thank you,
DD
The Ribbon button has a callback assigned to its onAction attribute - it will be a Sub in the addin that has an iribboncontrol parameter (or similar). If you have can view the customui part of the add-in's XML you will be able to determine exactly which callback is relevant.
How can JavaScript execute when a sub-grid receives focus?
I have a sub-grid that shows all Cases associated with an Account.
I would like to disable some fields on the form when the sub-grid receives focus.
RibbonDiffXML action for a ribbon button:
<Actions>
<JavaScriptFunction Library="$webresource:mda_convertemailtocaselib" FunctionName="ConvertEmailToCaseLib.addToCase">
<CrmParameter Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
</Actions>
This passes the sub-grid select items to a ribbon button, but I would like the JavaScript to execute before the ribbon button is pressed.
I haven't tried either of these out, but hopefully one of them should work for you.
Although it is a subgrid, there still is a control on the form. Unfortunately there is no "supported" way to know when a control gets focus since there aren't any OnFocus/OnBlur methods exposed via the CRM JS API. However you should be able to add your own JS event handler for that control and disabled the fields via the API Xrm.Page.getControl("fieldname").setDisabled(true)
I'm not 100% sure if this way would work, but it would be pretty sweet. Create a CustomRule EnableRule. In this CustomRule you call your own JS. In this create a function where you disable the fields and then return true to make the button enabled. It would look something like this:
function disableFieldsEnableRule() {
Xrm.Page.getControl().setDisabled(true);
...
...
return true; // so the button is enabled
}
The only reason I'm not sure if this will work is because I'm not sure if the Enable rules are checked each time you click on the subgrid or just the first time (I think it should be every time). Also I'm not sure if you want those fields re-enabled once you click off. If you do you might have to do something similar to this with a button on the native form, or something else.