How to add ribbon button with custom serverside handler to Dynamics CRM web? - dynamics-crm

We need to import to some external system group of contacts that user selected in contacts grid.
For now the only option I see is: get IDs if selected contacts and send it to the to external system using JavaScript.
But is it possible on ribbon button press get list of selected contact on server side? We`d like to process this contacts on server and send them to external system using our C# code (in plugin, most likely)?

Yes, in a slightly longwinded way. You can't call server side code directly from JavaScript. You can however perform an action that will call server side code.
For example:
Create a new entity - 'Contact Processor', this has a lookup to a contact.
Place a plugin (or custom worfklow activity) on the create of a 'Contact Processor'. This uses the lookup to the contact to perform whatever logic you require, e.g. Sending the data to an external system.
You add some JavaScript to a ribbon button that when clicked creates 'Contact Processor' records, this will then trigger the server side code.

Related

Outlook Add In (Exchange)- Create/Forward email - JavaScript

I have a problem with creating a script that creates/forwards an email in outlook to a constant recipiant.
the plan was to select keywords from checkboxes in its form. by pressing an inplemented button, the add-in should forward the opened email with a new subject from the checked checkboxes.
since i am very new to webdesign and js i would like to know if the idea could be realized without further ado. i have already browsed several forums and found out that sending email requires a web server and email client, which is out of the question due to the dynamic use and data security. also
I have already created the form of the add in. since this has no functions yet, i save posting a code/progress.
Any feedback?
OfficeJS doesn't provide anything for moving/forwarding items in Outlook. The web add-in is working under the currently selected item only. But you may consider using EWS or Graph API for implementing the required functionality.

Add information message when reading email

I would like to display an information message for the user when he read a specific email (i.e the email is tagged as external). The message should be displayed in the same way as outlook categories.
I know that I can use Exchange transport rule to achieve that but my client don't want to modify the message itself. He prefers displaying a message in the UI without changing the email body. The other option is to use the Office.context.mailbox.item.notificationMessages interface but as I told, I don't want to modify the email item if possible.
Do you think it is doable with outlook JS addins ?
My need is similar to this one for VSTO addin: How can my Outlook VSTO Add-in modify the read email form?
The Office.context.mailbox.item.notificationMessages interface provides the addAsync method which accepts the JSONMessage parameter which represents a JSON object that contains the notification message to be added to the item. It contains a NotificationMessageDetails object. Among properties you can find the persistent property which specifies if the message should be persistent. Only applicable when type is InformationalMessage. If true, the message remains until removed by this add-in or dismissed by the user. If false, it is removed when the user navigates to a different item. For error notifications, the message persists until the user sees it once. Specifying this parameter for an unsupported type throws an exception.
In case of categories, the message will be modified.
Do you know if it's possible to execute the function as soon as the read form is opened without having to click on an action button ?
Web add-ins are run under the context of currently selected item only. You can pin a task pane, then you'll be able to register an event handler to get notified of the change. 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);
});
};
function itemChanged(eventArgs) {
// Update on the new current item
}
Currently the event-based activation of add-in in Read mode is not supported. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered when we go through our planning process.
Currently, Event-based of activation of add-ins is only supported for Compose mode. You can explore more here- Configure your Outlook add-in for event-based activation - Office Add-ins | Microsoft Docs

Setting Activity Category on Email tracked from Outlook to CRM

I'm using Dynamics CRM 2015 (7.0.2.53) and Outlook 2016 (16.0.7766.7080) with the CRM for Outlook (7.1.1.3113) addin.
What I am trying to achieve is to give users the ability to specify an Activity Category against an email which they Track and Set Regarding from Outlook.
Currently, upon tracking and setting regarding on an email in Outlook, an Email Activity is created against the specified Entity record (let's say an Opportunity) in CRM, which is fine. The problem is that I cannot find any way to allow the user to specify an Activity Category for that created Activity either during the Track/Set Regarding process, or even after the Activity is created in CRM.
Is what I'm trying to achieve possible and if not, is there any other way to achieve a similar result, so that users can specify some value from a set of options against an email when they track it from Outlook to CRM, so that value can then be used for reporting purposes?
Basically there is no way of adding some custom functionality to Tracking Emails from Outlook. So you cannot add anything in Outlook plugin that will allow you to perform some operation on CRM side to set the Category right.
You can always make a plugin/workflow on Email creation in CRM and based on some email properties (topic, content, recipients etc.) set this category by youself - but of course users still will be unable to change it.
When email is created in CRM, it's disabled (because it usually already has been sent), but you can still modify it using workflows and dialogs. So you can always create a Dialog (https://msdn.microsoft.com/en-us/library/gg509010.aspx) and there you can prompt for proper category and set it on the email. So I can see a scenario like that - you have a view of Emails that are not categorized (or a Queue, where you put them in a plugin when user is tracking email from outlook). You pick Email, click "Start Dialog" which will be called "Set Category" or whatever, and set the category. Of course after this operation Email will vanish from the view. You can always create a reminder for the users to set the category for their mails, this should be included in new users training etc. Without any hardcore custom coding I think that's the only thing you can do (because if you don't mind writing more complex stuff you can always prepare some custom HTML5 control on Email form that will allow you to set the category field).

Kendo Upload Control: Save upload response within Control

I am new to Kendo UI Controls, and i have a question.
Currently I am using the upload control within a form to upload files to a API Service. This service returns an ID of the sent file, which must be sent at the moment of saving the whole form.
Is it possible to save the returned ID within the Upload Control and access that information at the moment of posting the form, or does that information has to be stored in a different field, at the success event handler?
Thanks in advance

Using a Workflow to auto-populate a form field upon creation in CRM 2011

I would like to have a field automatically be populated with something I define in a workflow. Currently I have the workflow running upon record creation, however the field is only populated AFTER the user saves the record for the first time.
How can I use a workflow to populate that field before the user saves the form?
You can't. Workflows function on the server-side, but you're asking about populating a client-side field before the server is contacted. Moreover, workflows are triggered asynchronously, which by definition means the record has to be created in advance.
You'll need to either attach a JavaScript function to the OnSave event, or trigger the population of the field in a pre-validation or pre-operation .NET plugin. I suppose you could use a Dialog as well, but that would require user input. See the below links for more detail on the differences between plugins, workflows, and dialogs.
Options: Plugin, Workflow or Dialog
Automate Business Processes in Microsoft Dynamics CRM

Resources