I'm about to develop an add-in that will automatically pull some data from emails and modify some fields in our database. However this extraction could be a bit error prone so we wanted a layer of human verification when it occurred.
We do this in gmail already, when the user open an email and we find something we want to extract we display a confirmation pop-up, and this feature is very well received by our clients.
I am planning on using the dialogbox but it seems to trigger this the action to display the box needs to be attached to a ui element for the user to click.
Is there any way to tigger an action pragmatically, without a users click?
Take a look at the pinnable task pane available for Outlook add-ins, see Implement a pinnable task pane in Outlook for more information. There you can implement the ItemChanged event handler. The event handler should accept a single parameter, which is an object literal. The type property of this object will be set to Office.EventType.ItemChanged. When the event is called, the Office.context.mailbox.item object is already updated to reflect the currently selected item.
Office.initialize = function (reason) {
$(document).ready(function () {
// Set up ItemChanged event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, itemChanged);
UpdateTaskPaneUI(Office.context.mailbox.item);
});
};
// Example implementation
function UpdateTaskPaneUI(item)
{
// Assuming that item is always a read item (instead of a compose item).
if (item != null) console.log(item.subject);
}
Related
I have an Account form.
In the interactions tab I have the sub grid for meetings.
I have added the new button to this Sub-grid, 'Complete the Meeting'.
I want to trigger the 'Mark Complete' button of the Meeting form from here.
How can I do it ?
My first choice would be using Activities subgrid instead of Appointments. I just verfied as below.
If that wont work for you for any reasons, then custom ribbon button is a good choice. You have to customize the command of your custom button to use javascript command, then pass the selected IDs from subgrid to ribbon button command and iterate the IDs for updating Appointment records using Xrm.Webapi in javascript function.
I have a following problem, which I am not sure, how to solve. I am building app's setting, where user can specify list of accounts (left TableViewConstoller). As you can see on the screen, there is a Save button, which stores new account into the database.
Everything works, except for empty Name value, which cause an exception. I need to solve it in way, where Save button would be enabled only if data pass validation (Name is not empty).
I was thinking about some event, which would monitor Account.Name property and based on it's value, Save button would be enabled/disabled.
Problem is, that I have no idea, how to achieve that.
Thanks for any suggestions.
For the data to pass validation it would need an event to be triggered first, so why don't you simply hook into the touchupinside event of the 'save' button perform some validation against the data that is being submitted and if it fails display an alert to the user? Seems like a cleaner approach to me, which would also include visual prompting. otherwise you would need the button to be set to disabled from the start and then perform a check every time one of the tableviewcells is interacted with.
The validation would be fairly simple: (obviously use an '&&' operand to validate against more than one empty textbox)
If(nameTextBox.Text.Trim().Length != 0)
{
// Great store the data
}
else
{
UIAlertView alert = new UIAlertView () {
Title = "alert title", Message = "this is a simple alert"
};
alert.AddButton("OK");
alert.Show ();
}
If you have a code example I may be able to be more specific.
Edit:
It's also worth considering your future requirements, should you be able to handle no name being passed, if the user doesn't have one already stored should you force them to supply one, or if the user already has a name and passes through no name change, should you simply keep the existing name and proceed to update all of the other fields that the user may have interacted with. It always pays to take some time to architect out your requirements for any given feature.
If I have an Outlook.MailItem how can I get the Location, Width and Height of this?
Also I need to "disable" the entire Outlook.MailItem form - how do I do this?
I want to show a centered "modal" dialog (just a Windows.Forms.Form) over this MailItem without it actually being modal.
Thanks
Update (more explaining)...
When a user clicks "Send" on a mail, I want to check it for large files before sending and if the file size are too big, then I want to show a "Files are too big, do you want to zip them" dialog. The dialog must be centered to the mail form and disable the mail form (like a dialog would) without freezing outlook.
There is no need to disable the default form in Outlook.
For example, the Open event of the MailItem class which is fired when an instance of the parent object is being opened in an Inspector. The Cancel parameter passed to the event handler allows to abort the default action. If the event procedure sets this argument to True, the open operation is not completed and the inspector is not displayed.
When this event occurs, the Inspector object is initialized but not yet displayed. The Open event differs from the Read event in that Read occurs whenever the user selects the item in a view that supports in-cell editing as well as when the item is being opened in an inspector.
Also you may consider using Outlook form region. The Replacement-all layout allows to override the whole inspector window. See Creating Outlook Form Regions for more information.
Why do you need to do anything with the form? Process the Application.ItemSend event, display the prompt if necessary, and cancel the submission process if you need to.
Suppose that I have a registration screen, and when the user clicks the "Register" button an asynchronous operation takes place, at the end of which a delegate method is invoked. I want the button to be turned off when the user clicks it (that part is easy), and for the button to be re-enabled if the registration fails (server declined the registration). How do I access this button's properties from the delegate function?
Assuming you've declared the Button's name in XAML, in the delegate callback function, I'd do something like (The Dispatcher.BeginInvoke is necessary to execute the code on the UI thread):
Dispatcher.BeginInvoke(() =>
{
MyRegisterButton.IsEnabled = true;
});
I'm trying to create three dynamically filled FlyoutAnchor Ribbon buttons, based on the following SO answer: Add Dropdown Menu to CRM 2011 ribbon
All three FlyoutAnchor buttons use the same PopulateQueryCommand. The JavaScript function which is linked to the command (see code block below) gets the CommandProperties CrmParameter passed as the first argument to be able identify the flyout button which was clicked (and should be filled with dynamically added dropdown menu items).
function DynamicMenu(CommandProperties) {
/// <summary>Dynamically generate menu items based on context</summary>
/// <param name="CommandProperties">
/// Command properties crm parameter sent from the ribbon. object used to inject the Menu XML
/// </param>
debugger;
var menuXml = '<Menu Id=\"Sample.DynamicMenu\">' +
// ... Other menu XML stuff goes here
'</Menu>';
CommandProperties.PopulationXML = menuXml; // error here...PopulationXML is undefined... :-(
// ...
}
The function gets nicely called and the 'CommandProperties' argument is passed (it isn't null and not undefined), but when I try to set the PopulationXML I get an error, because this property is undefined. The other three expected properties listed below are also undefined:
SourceControlId: The Id value of the Ribbon control that initiated the event.
CommandValueId: A string that is sent with the command event when a button is clicked.
MenuItemId: A reference from a control to the Id of a menu item.
When I pass in a second different CrmParameter, for example PrimaryEntityTypeName, this argument is correctly filled / set.
What could be the cause of the messed-up CommandProperties argument?
Update 21-2-2012: To be complete, I also tried the single button approach, such as described in Add Dropdown Menu to CRM 2011 ribbon, but that gave me the same result (no usable Commandproperties object). My CRM server is running Rollup 6, maybe that has something to do with it? Is there a different way of getting this kind of flyout ribbon menu's? Maybe something in pure JavaScript? It should also work in the Outlook CRM Client...
I was facing the same issue, the resolution is instead of using
'<Menu Id=\"Sample.DynamicMenu\">', use '<Menu Id="Sample.DynamicMenu">'
the difference is of not using escape character for "