I have customized the lead entity in CRM for our business, is there a mechanism in CRM Online via the webservices that I can invoke to insert new records as a Lead in CRM from our local database? I cant find the correct details in Dynamics CRM Online's API. Please help!
Thanks. This is in C#.
Use the Simplified Connection
MS Dynamics CRM online 2011 - Authentication issues
and after create the records. The metadata of the Lead entity is here:
http://msdn.microsoft.com/en-us/library/gg334250(v=crm.5).aspx
Create your lead and define their attributes and save it
Entity lead = new Entity("lead");
// definition of lead attributes goes here
// lead.Attributes["xxxx"] = yyyy;
service.Create(lead);
Related
I've currently got a Bot running in Microsoft Teams, which has been built many years ago using the Microsoft Bot Framework v3 SDK. Now I will show an example of a location where I have saved some data after using the Bot, which I understand is stored in the "IBotDataBag".
So this method is the first method that is called when I enter a message to the Bot in Teams (as a result of the framework). It is injected with an object of type "IDialogContext" and this object contains other objects, one, which is of type "IBotData" and above in the image is "context.UserData". I use this to set some data, for example I had set it to store a value inside the key of "test_data", which I retrieve in the image above.
Now my question is, where in the Bot application is this data actually held? My application is deployed to Azure as an application service. It is installed locally in my Microsoft Teams after installing it from my Org's application catalogue. I want to know whether this data is held somewhere locally on my PC or in the cloud somewhere. Based on a test by uninstalling the Bot I thought if it was held in the cloud then the data set in the "IBotDataBag" would be removed but after installing the Bot after, the information was still present, which leads me to believe the Bot held onto the information locally on my machine. I have tried to find information to support this conclusion online but I have not spotted anything useful so far and I understand Microsoft are now very much pushing SDK v4 so was hoping someone on here can shed some light on the question for me please?
So after reviewing the architecture of the bot in its resource group in the Microsoft Azure portal, I found an entry of type "Storage Account", which is basically Azure Table Storage for the bot. In here there is a section for "Tables" and in here you will find an entry called "botdata". Inside of this table you will find several entries, which are identifiable by their partition key. After running doing some trial and error I found that removing the "msteams:user" entries would result in my bot not having any "UserData" inside of the context object. Based on several tests, I concluded that the data is held in table storage and that the bot framework handles the CRUD operations on this data.
The V3 SDK is being retired with final long-term support ending on December 31st, 2019. Accordingly, there will be no more development in this repo.We highly recommend that you start migrating your V3 bots to V4.
The v3 SDK currently supports two programing language. Bot builder SDK v3 includes samples for all supported languages:
.NET
JavaScript
Here some Code snippest-
private async Task MessageReceivedAsync(IDialogContext context,
IAwaitable result)
{
var activity = await result as Activity;
// An example of a string value saved directly to UserData
context.UserData.SetValue("test", "test");
// If we have not asked the user their name, ask it now
var askedName = context.UserData.GetValueOrDefault<bool>(AskedNameProperty);
if (!askedName)
{
await context.PostAsync($"v3: Hi. What is your name?");
// We've asked the user their name, so persist the information in UserData
context.UserData.SetValue(AskedNameProperty, true);
}
Reference Sample-https://github.com/microsoft/BotBuilder-Samples/blob/4d209edeaaaa72d29279057ff2c1ac3ce213694b/Migration/MigrationV3V4/CSharp/V3StateBot/V3StateBot/Dialogs/RootDialog.cs
Document-https://github.com/microsoft/botbuilder-v3
To disable a Dynamics CRM 2016 user with C# code the SetStateRequest is currently used.
Example:
var requestToDisableUser = new SetStateRequest()
{
EntityMoniker = new EntityReference("systemuser", userGuid),
State = new OptionSetValue(1),
Status = new OptionSetValue(-1)
};
organizationService.Execute(requestToDisableUser);
However, according to Microsoft the SetStateRequest is deprecated and should be replaced by using Update
But when I try to use Update to disable a user
Example:
var userToDisable = new Entity("systemuser", userGuid)
{
["statecode"] = new OptionSetValue(1),
["statuscode"] = new OptionSetValue(-1)
};
service.Update(userToDisable);
Then it raises the error :
Unhandled Exception:
System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]:
'systemuser' entity doesn't contain attribute with Name =
'statecode'.
Which is true, because the systemuser Entity doesn't have a statecode.
And the systemuser Entity has a IsDisabled attribute, but that one is read-only.
So how can a user then be disabled/enabled without using SetStateRequest?
I don’t think it is possible, unless someone proves it is. To support my opinion: the latest SDK (8.2.1.1; 4/6/2017) still gives an example with SetStateRequest in SDK\SampleCode\CS\BusinessDataModel\UsersAndRoles\DisableOREnableUser.cs. Therefore, it should be the recommend way to do it, regardless the fact it is marked as deprecated in another part of documentation.
You might start an incident with MS support, or give suggestion on Connect; but according my experience, they don’t care much if workaround is available.
After CRM online 2015 update 1, special messages were deprecated for special attributes. Read more.
Per metadata, IsDisabled attribute of systemuser may be showing as not valid for update. And few other business owned entities like Team, BU, etc won't use statecode & statuscode.
You should be using IsDisabled attribute if planning to not to use deprecated methods.
It's probably a missing piece in documentation. But hints can be found wrt Specialized operations using Update message like below per MSDN
These specialized messages will continue to work with the 2011 endpoint. However, the recommendation is to use the UpdateRequest or Update method when possible to set these attributes. The Update message simplifies the Organization Service and makes it easier to code standard data integration tools used with Dynamics 365. In addition, it is easier to code and register a plug-in to execute for a single Update message instead of multiple specialized messages. The AttributeMetadata.IsValidForUpdate property for the above listed attributes has been changed to true in this release to enable this capability.
You can continue to use these specialized messages of the 2011 endpoint in your code. However, the Web API that eventually replaces the Organization Service supports only the Update message for these types of operations. If you want to get a head start on changing your code to align with the Web API, you can now do so. See Use the Microsoft Dynamics 365 Web API for more information.
Some new fields were create in Dynamics CRM.
Now need to push some data to those new fields from asp.net website.
Need to add those new fields to:
[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
namespace Xrm
how should this be done? I read that these is a tool that generates this class file (CrmSvcUtil.exe).
But I do not understand how this would work.
Is this something that need to be done through Dynamics CRM admin?
Please advise.
Thanks
This should be done by user which has System Administrator or System Customizer, because this user has to have access to all entities metadata.
Basically you should start with downloading CRM SDK, for your version of CRM. For example the latest SDK can be found here:
https://www.microsoft.com/en-us/download/details.aspx?id=50032
Install the SDK and go to the bin folder inside the folder where you installed it. There you can find crmsvcutil.exe. This tool is something like svcutil.exe - it simply generates proxy classes using CRM metadata service. So instead of referring to Account entity like that:
var account = new Entity("account")
you can simply do:
var account = new Account();
and you will have all the properties that account in your system has.
In order to generate this classes just run crmsvcutil.exe using windows command line with proper credentials (it's very well documented if you run it without any parameters). example usage would be:
crmsvcutil /url:https://orgname.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /u:user#orgname.onmicrosoft.com /p:password /serviceContextName:XrmServiceContext /out:Proxies.cs /n:Xrm
this would generate file Proxies.cs, containing namespace Xrm (the one you have posted in your question) with all the entities and fields. Of course the parameters may vary based on what type of organization you are connecting to. If you have problems with specifying proper values then simply put /il as last command line parameter - it will open an interactive login form, that would make it simpler for you to pass proper connection data.
Creating an external MVC website using CRM 2011/2013 web services. Must hide/show parts of the application based on write access to a certain custom entity. Found solutions like
http://mileyja.blogspot.de/2011/05/using-retrieveuserprivileges-requests.html
Here the RetrieveUserPrivilegesRequest requires the systemuser id and the entity record id as parameters. Workarounds on the subject use .First() to get a record and retrieve the privileges. The solution is not convincing because of the possibility of the absence of records.
The other solutions as RetrieveUserPrivilegesRequest returns Guid-s of privileges. These can change from CRM instance to instance. Also roles get things complicated. Does anyone knowif there exists a straight forward way to
verify if the system user has write access to a certain entity?
This requirement can be fulfilled by a combination of a QueryExpression and a RetrieveUserPrivilegesRequest or by a single QueryExpression.
Check if a User has a specific Privilege
This is a simple task, but i am wasting more than a day. Thats why coming to you. Please help me to get out of the issue.
My requirement is very simple, i have an ASP.NET project. And i have an Entity in Online CRM
Entity Name: "Employee" and Fields are "Name, Age, Gender"
I cann't add CRM Dlls in my asp.net project. So i must use REST Service.
I have added service reference https://myoffice.crm5.dynamics.com/xrmservices/2011/organization.svc?wsdl
This is the code i am using
OrganizationServiceClient orgClient = new OrganizationServiceClient();
orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("admin#something.com", "mypassword");
Entity myContact = new Entity();
myContact.LogicalName = "Employee"; //Is it right? i must provide it here right.
ConsoleApplication1.ServiceReference2.AttributeCollection myAttColl = new ConsoleApplication1.ServiceReference2.AttributeCollection();
myAttColl.Add(new KeyValuePair<string, object>("Name","Emp1"));
myAttColl.Add(new KeyValuePair<string, object>("Age", "26"));
myAttColl.Add(new KeyValuePair<string, object>("Gender", "Male"));
myContact.Attributes = myAttColl;
try
{
orgClient.Create(myContact);
}
catch (Exception ex)
{
}
I am getting "An error occurred when verifying security for the message" error when it run orgClient.Create(myContact).
No matter what i did so far. This is my requirement, a very simple adding entry to my custom entity into Online CRM using REST Service. I am going to run my webapplication in a separate domain called http://xyz.com. From here, i need to add the entries into Online CRM.
Any help?
It could seems strange but the reason is that the clock on the server and on the client are certainly not synchronized.
All you have to do is check that :
The client clock is synched with the server clock.
Both client and server are coordinated on the day time saving settings
Regards,
Kévin
Sources : here and here
The REST service is not exposed for external applications, it is for internal applications only. You may be able to get around this in an on premise deployment but in CRM Online there is no workaround that I am aware of. You are much better off if you add the CRM assemblies and do this in C#. Also, with the REST service you are severely limited to CRUD operations and you can't perform things like assign or change state. In my opinion the SOAP service is superior, but it still cannot be called from an external web application.
See the note that reads the following at this link - Data Access Using JavaScript
Note
It is not possible for an external application to use these web services because authentication is provided by Microsoft Dynamics CRM.