Advance warning: Im an absolute newbie to Dynamics CRM!
Intention
I want to have a feature like Lync/Skype integration but use my own URL. (Click on any telephone number inside CRM and call it).
For eg. assuming I have a web service which can initiate a call per URL: http://telephony.com/call?nr=012345678. Now, whenever a CRM user clicks onto a telephone number field (in forms and views) inside the CRM my web service should be called instead of Skype/Lync.
In fact I'm trying to reproduce sth. like the InGenius Connecter.
Attempts
I already tried to inject a JS web resource to a specific formular (in my case it was the default contact form) and override the Mscrm.ReadFormUtilities.openPhoneClient callback (which seems to handle the Lync/Skype integration).
function load() {
// override integrated CTC (Lync/Skype)
Mscrm.ReadFormUtilities.openPhoneClient = function (telephoneNr) {
// redirect user to my web service
window.location.replace("http://telephony.com/call?nr="+telephoneNr);
return;
}
}
Found this method at: Disable Lync completely
This does work well in forms of Dynamics 2015 (my custom link pops up instead of Skype/Lync). However, this does only work on entity forms since I can't inject web resources into an entity view.
My other ideas how to implement such a feature are:
Inject global JS resource which disables Lync/Skype and encapsulate every telephone number with link to my custom URL.
Extend/Manipulate Lync/Skype integration to use my custom URL instead of Lync/Skype.
Write plugin which encapsulate telephone numbers server side.
Question
Since I have a grasp understanding of Dynamics and no experience in plugin/resource development, I'm left a bit confused with these questions.
Is it possible to achieve any of the three ideas above ?
If not, any idea how InGenius solved this problem ?
Do you have any other idea/resources about this topic ?
Currently I found two options available to achieve a custom CTC feature. (Both has the downside of not being officialy supported by the dynamics crm.)
Global Ribbon
Pretty simple: Add a Click-To-Call button to global ribbon which is only enabled on specific grids when one row is selected.
This button refers to an JS-Action which retrieves the telephone number via ODATA and then launches the dial process.
Global Ribbon CustomRule injection
Add a global button to ribbon which refers to a JS resource per <CustomRule>. The JScript then unbinds all actions from links with .ms-crm-Phone classes and replaces its href-attribute.
This would be useful if one want to override the integrated "Skype / Lync - Click to Dial" feature with his own logic.
I didn't test this method until now, so I can't guarentee it's working !
Note: I will include example scripts as soon I got the time.
Related
Is there someone who can explain how to code dialog from bot framework properly?
I'm trying to code from scratch using the empty bot template to understand every pieces of code and why and how they piece together. But even after reading so many times I don't how it is properly implemented or coding for dialogs in Microsoft Bot Framework. I've read the documentation from microsoft many times and many version or doc from microsoft but still can't comprehend how it link together every piece of code. Even blogs or website i found did not explain why such pieces of code is needed but just ask you to add this and that. I understand concept but not the mechanics. The code seems to span from startup.cs, yourMainBotLogic.cs, dialogClassName.cs, BotAccessors.cs which confuse me which are the steps the program is run on and how.
Please explain in detail why the pieces of code/components is needed/what use it has and why it has to be there in such files (e.g. Startup.cs). For example;
var accessors = new BotAccessors(conversationState) { ConversationDialogState = conversationState.CreateProperty<DialogState>("DialogState"), }; return accessors;
Create a accessor for the DialogState and then return it. This is just example and my description of the code might not be right.
Your question about how everything fits together is a bit broad, but I will attempt some explanation:
startup.cs: bot configuration should be loaded here, and singletons created. Including IStatePropertyAccessors. Many of the samples contain a BotConfig file with bot specific setup code, and call it from startup. Many samples also contain a bot file. Bot files can make loading some bot services easier. But, they aren't necessary. Ids and passwords can still be retrieved from App Settings, or web.config and your code can create the services.
Some things usually initialized in startup are:
ICredentialProvider is used by the sdk to create the BotAdapter and provide JWT Token Auth. For single appid/password bots, the SDK provides a SimpleCredentialProvider. If your bot is using the integration libraries, you can create one during the IBot initialization, or just supply the botConfig with appid/pass:
webapi:
public static void Register(HttpConfiguration config)
{
config.MapBotFramework(botConfig =>
{
var appId = ConfigurationManager.AppSettings[MicrosoftAppCredentials.MicrosoftAppIdKey];
var pass = ConfigurationManager.AppSettings[MicrosoftAppCredentials.MicrosoftAppPasswordKey];
botConfig.UseMicrosoftApplicationIdentity(appId, pass);
}
}
netcore:
public void ConfigureServices(IServiceCollection services)
{
services.AddBot(options =>
{
options.CredentialProvider = new SimpleCredentialProvider(appId, appPassword);
});
}
IStorage is an implementation for interacting with a state store. The sdk provides MemoryStorage CosmosDbStorage and AzureBlobStorage These are each just using JsonSerializer to store and retrieve objects from the underlying storage.
BotState are objects that provide keys into the IStorage implementation. The SDK provides three examples:
ConversationState scoped by {channelId}/conversations/{conversationId}
UserState scoped by {channelId}/users/{userId}
PrivateConversationState scoped by {channelId}/conversations/{conversationId}/users/{userId}
IStatePropertyAccessors These are an implementation layer providing for typed access into the scoped BotState explained above. When a get/set is performed, the actual state store is queried and persisted (through an internal cache provided by the sdk).
BotAccessors.cs is just a container to hold the state classes and IStatePropertyAccessors. This isn't needed, but is for convenience.
yourMainBotLogic.cs: this is where the adapter's OnTurn implementation exists, and should load the dialog stack and process the user's message. The dialog stack is managed by a dialog set that contains an IStatePropertyAccessor of DialogData type. When a get is performed on this property accessor by calling create context, the state store is queried to fill the dialog stack of the DialogContext.
dialogClassName.cs is a dialog implementation. The specific dialog types are delineated here: Dialog types Examples of how to use them are in the samples on github and documentation.
As with other asp.net applications, startup is run when the application first loads (see aspnet-web-api-poster or lifecycle-of-an-aspnet-mvc-5-application and note that the Microsoft.Bot.Builder.Integration.AspNet.Core uses an IApplicationBuilder extension to add the message handler to the request pipeline ApplicationBuilderExtensions and Microsoft.Bot.Builder.Integration.AspNet.WebApi uses an HttpMessageHandler implementation). However, you can choose to not use the integration libraries, and create your own controllers. Like this sample: MVC-Bot
V4 additional references
Implement sequential conversation flow
Create advanced conversation flow using branches and loops
Gather user input using a dialog prompt
Managing state
Save user and conversation data
Implement custom storage for your bot
I am very new to MS Dynamics. I am using dynamics CRM 2016 and I need to remove, in the activities page, the views about entities that I am not using such as Campaign Response, Campaign Activity, etc.
I do not see them in the list of views of the Activity entity in my solution, so I cannot remove them from there, am I missing something? Is there a way to remove those views?
Its possible. I found the way to do it finally after just 3 days of research.
Open your CRM web in XRM Tool kit (download if not having it)
XRM toolkit access your org using url and login. Assuming you have privilege access.
Load all web resources and scroll down to find "activitypointer_ribbon_home.js"
Add below lines of code into the file,
finally Save and publish to make it available for all users. Whoa.. it works like charm !!!
hideactivitiesview() // call under onload of xrm page; comes in default script of this file
function hideactivitiesview()
{
var viewSelector = $('#crmGrid_SavedNewQuerySelector')[0];
if(viewSelector)
{
$(viewSelector).click(function(){
var _activity = $('#ViewSelector_activity')[0]; //get this id from DOM using F12
if(_activity)
$(_activity).hide();
});
}
}
Unfortunately you cannot hide/remove those.
Reason: They are not usual views, they are part of System tailored Activity entity family (Activity, Activity Pointer, Activity Party, Custom Activity types, etc).
If you see any Activity entity properties, the checkbox 'Display in Activity Menus' is checked & disabled. This settings is being used for navigation, views, filters, etc.
Even while creating custom activity, this option is enabled & if you forget to check it, that particular Custom Activity type will be hidden from everywhere wherever you are using its siblings (Email, Fax, etc)
If its unchecked, Even Associated view will not be showing this activity under it's regarding Parent record, which is failing the main reason why we are using CRM & activity relationship.
In a nutshell, this setting once enabled, cannot be undone. The activity cannot be distinguished/disabled using security role, because all are of same bucket.
Maybe you can try some unsupported customizations using DOM explorer in javascript & hide it, which I don't recommend. PowerObjects blog talk about renaming it to something to avoid users using it & other options.
I am working on designing a lengthy approval system in CRM using a combination of OOB workflows (designed using CRM UI Workflow Designer) and custom actions (actions written using .NET code). Idea is to keep the entire branching/simpler logic in OOB workflow and call custom Actions wherever necessary. However I have few questions with this approach:
How can I handle run-time errors generated in the action code?
For example, one of my Actions contain the code to push data to an external system via web service. In case this web service call fails, I need to perform some steps in the parent workflow.
How can I handle 'if conditions' which can't be handled by 'Check Condition' step? For example, suppose that before performing a certain workflow step I need to check some data which can't be queried within CRM. I can create an Action which will return true/false based on the custom logic which can then be checked in parent workflow.
An alternate approach would be to use plugins but I am inclined towards using OOB functionalities as much as possible. Any inputs would be helpful.
First of all let's clear the semantics, because I'm not sure if you understand what are you talking about - there are Actions (you can refer to them as custom actions, but then you should refer to every workflow you create as custom and I figured out of your post that you are describing them as OOB, which also is semantically wrong - every workflow you create is a custom workflow, maybe it's using OOB steps, but that's a different story) and Custom Workflow Activities. I'm assuming that you want to use Custom Workflow Activities, because the are more suited for what you are trying to achieve here. Also you tagged your question as CRM 2011 and CRM 2013 - not sure what you meant, because Actions were not available for CRM 2011.
So basically Custom Workflow Activities can have Input and Output parameters. Output parameters are answer to both your questions, because you can use them to get the error message after your custom processing or use then in conditional statements later in your workflow. Output parameters can be defined like that:
[Output("Error message")]
public OutArgument<string> ErrorMessage { get; set; }
You can find more examples here:
https://technet.microsoft.com/en-us/library/gg327842.aspx
You can of course set this properties simply by calling
ErrorMessage.Set(executionContext, messageText)
So now when you define your workflow, wherever you need something not configurable in OOB blocks, you can put your Custom block, after it's done simply check it's output for the error (this is just an example, you can pimp it up by adding additional output parameters, to make it more generic), if it's empty then do something, if not then do something else for example send email with the error message. It all depends on what are you trying to achieve.
Actions are serving different purposes, they are useful to create a logic that can be easily called through plugin or javascript (webAPI) and allows you to also put a plugin on it alongside doing everything within one transaction. Maybe it will be useful somewhere in your workflow, but as far as I remember in CRM 2013 actions could not be called from a workflow...
UPDATE:
Ok so if we are dealing with CRM 2016, we can call Action from a workflow. What is best in this situation really depends on the scenario and what we are trying to achieve, but to make it easier to decide let me highlight main differences:
1) Activities are simply a blocks of code that can be put inside your workflow. Actions by themself are not code, they are custom Messages that you can call. Of course you can register a plugin on this custom Message and do there any custom logic you want, but this is another step to take
2) Actions can be run in transaction, Activities not (but you can run Activities inside Actions, so in this case they can run in transaction)
3) Actions can be called directly from Javascript, plugins and workflows. It's a great thing, but if you will make let's say 10 custom Actions which you will be using ONLY inside you one workflow, they will be visible when you will be registering plugins (and also any js developer will be able to call them with JS)
So basically Actions are a big, fat feature that can serve many purposes (including running Activities on their own!), Activities are much simpler but in your case they will also do their job. So you should ask yourself questions:
Do I need my logic to run inside transaction?
And
Do I need to call this logic somewhere else than my workflow?
If you have any "Yes" then go for Actions, of no, then go for Activities, because you will be overcomplicating things without any good reason.
I need to sync entities from Ms Dynamics Crm 2015 - On Premise to my 3rd party application, for this I have set a JavaScript function on the OnSave event of the Entites( eg. account) I can access all of the attributes and send them to my webservice, but the Id (GuId) of the entity!
how can I access the Id (or set it manually) on this event?!
Xrm.Page.getAttribute("accountid") or Xrm.Page.getAttribute("id") both return null, so I can not setValue using them.
Also Xrm.Page.data.entity.getId() returns "" which is probably logical, since Object has not been inserted in the db yet, this is the reason which makes inserting a runtime generated guid for the entety seems doable !
P.S.
I know I can do same thing with plugins, which I have gone through, but the problem there is that when I register my plugin for Update message it gets called a lot of times, (mostly when it has been set for invoice), this is the reason that made me go with the JScript, since the OnSave Event seems more logical than the Update Message of the plugin
As you already found out, records which have not yet been saved have no ID. That's by design (and obvious).
Also, IDs being PKs in the database, they are handled by the system and cannot be touched or hand-crafted.
Your best bet to keep a similar behavior would be a Post-Operation Create plugin living outside the sandbox (Isolation mode: None).
Another good option would be to pull data instead of pushing it: the 3rd party application can periodically fetch new records through any of the exposed APIs (REST, SOAP, SDK ... there are many options).
I have a Web Service like ServiceA.asmx. What is the right way to consume it?
I have two ways to consume a service:
1)adding Service Refernce:
I have added Service Refernce of ServiceA.asmx ( Like in http://microsoftfeed.com/2011/part-14-how-to-consume-a-web-service-in-windows-phone-7) and i am able to call the Functions in Service like in the link i have given. If we use this way there is no need to parse the Result, Result returned in Objects(easy to use).
2)Hitting the URL and Calling asynchronously:
Here we can hit the URL, that function will call the asynchronous function that asynchronous function will return the response. But here response will be in XML here we have to parse that XML in to an Object.(not easy if any Big XML is there)
Please Guide me on this
Personally I would use the 'Add service reference' option. It's easy to use, and this option is added to Visual Studio especially for consuming web services. You can still use MVVM to build up your models/viewmodels.
I don't have the option to check it right now, but from my head the classes generated when adding the service reference also implement INotifyPropertyChanged. So you could probably use the object directly (if they are in the structure as you want to use it.) as your Model. Based on that model you can create your own ViewModel which you can bind to the UI.
To see how this works have a look at the code samples on MSDN:
Implementing the Model-View-ViewModel Pattern in a Windows Phone Application
Weather Forecast Sample