Skip to content

Instantly share code, notes, and snippets.

View pawelgradecki's full-sized avatar

pawelgradecki

View GitHub Profile
function showErrorDialog() {
var errorOptions = {
details: "This is simply the message that can be downloaded by clickick 'Download log file'",
errorCode: 666, //this is error code if you want to show some specific one. If you specify invalid code or none, the default error code wouldbe displayed
message: "Message show in the dialog"
};
Xrm.Navigation.openErrorDialog(errorOptions).then(
success => {
function showConfirmDialog() {
var confirmStrings = {
cancelButtonLabel: "Cancel button label, by default it's CANCEL",
confirmButtonLabel: "Confirm button label, by default it's OK",
text: "Text show on the dialog",
title: "Title of the confirmation dialog",
subtitle: "Subtitle of the confirmation dialog"
};
var confirmOptions = {
function showAlertDialog() {
var alertStrings = {
confirmButtonLabel: "This is text shown on the confirmation button",
text: "This is text shown on the dialog"
};
var alertOptions = {
height: 200,
width: 400
};
@pawelgradecki
pawelgradecki / SolutionExportFixer.cs
Last active October 3, 2017 13:44
Removes attributes that do not exist in the system anymore, from the solution
static void Main(string[] args)
{
var solutionUniqueName = "SOLUTIONNAME";
var orgService = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
var solutionComponentQuery = new QueryExpression("solutioncomponent");
solutionComponentQuery.Distinct = true;
solutionComponentQuery.ColumnSet.AddColumns("objectid", "componenttype", "solutioncomponentid");
var solutioncomponentSolutionLink = solutionComponentQuery.AddLink("solution", "solutionid", "solutionid");
solutioncomponentSolutionLink.EntityAlias = "aa";
solutioncomponentSolutionLink.LinkCriteria.AddCondition("uniquename", ConditionOperator.Equal, solutionUniqueName);
public void DoRequest(IOrganizationService service)
{
var request = new OrganizationRequest("ResolveEmailAddress");
request.Parameters["EmailAddresses"] = "test@test.com";
request.Parameters["ObjectTypeCodes"] = new int[] { 1, 2 };
var response = service.Execute(request);
if (response.Results.Contains("Entities"))
{
var result = (EntityCollection)response.Results["Entities"];
@pawelgradecki
pawelgradecki / AutonumberCorrectAgain.cs
Created July 21, 2017 08:58
Corrected Autonumbering in Dynamics 365
namespace TransactionPlugin
{
public class Autonumber : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var pluginContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(null);
@pawelgradecki
pawelgradecki / AutonumberingWrong.cs
Created July 21, 2017 08:53
Wrong autonumbering in Dynamics 365
namespace TransactionPlugin
{
public class Autonumber : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var pluginContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(null);
@pawelgradecki
pawelgradecki / Autonumber.cs
Created July 21, 2017 08:46
Autonumbering in Dynamics365
namespace TransactionPlugin
{
public class Autonumber : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var pluginContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(null);
function changeCompositeFieldLabel(attributeName, label) {
var attribute = Xrm.Page.getAttribute(attributeName);
if (attribute != null) {
attribute.controls.forEach(function (c) {
c.setLabel(label);
});
}
}
//Usage
@pawelgradecki
pawelgradecki / TransactionPlugin.cs
Created June 18, 2017 20:03
Transaction Plugin
public class TransactionPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(null);
var counter = GetCounter(service);
counter["new_name"] = "lockme";