Skip to content

Instantly share code, notes, and snippets.

pawelgradecki

Block or report user

Report or block pawelgradecki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ConnectToCrm.cs
var crmClient = new CrmServiceClient(ConfigurationManager.ConnectionStrings["D365"].ConnectionString);
if (crmClient.IsReady)
{
using (var ctx = new OrganizationServiceContext(crmClient))
{
var result = ctx.CreateQuery<Contact>()
.Where(a => a.FirstName == "Jan")
.Select(a => new Contact
{
View ServiceResponse.cs
public class ServiceResponse
{
public string RecognitionStatus { get; set; }
public int Offset { get; set; }
public int Duration { get; set; }
public Nbest[] NBest { get; set; }
}
public class Nbest
{
View ConvertSpeechToTextPlugin.cs
public class ConvertSpeechToTextPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
var organizationServiceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var orgService = organizationServiceFactory.CreateOrganizationService(null);
tracingService.Trace("Plugin started");
View ValidationPlugin.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
namespace Validation.Plugin.CoreLib
View showLocalizedMessage.js
function showAlertDialog() {
var localizedResult = Xrm.Utility.getResourceString("odx_/resx/messages", "qualifyingLeadMessage");
var alertStrings = {
confirmButtonLabel: "OK",
text: localizedResult
};
var alertOptions = {
height: 200,
width: 400
View open_webresource.js
function openWebResource() {
var windowOptions = {
openInNewWindow: false,
height: 400,
width: 400
};
Xrm.Navigation.openWebResource("new_mywebresource.html", windowOptions, "someAdditionalParameter");
}
View open_url.js
function openUrl() {
var url = "http://google.com";
var openUrlOptions = {
height: 400,
width: 800
};
Xrm.Navigation.openUrl(url, openUrlOptions);
}
View open_form.js
function openEntityForm() {
var entityFormOptions = {
entityName: "account",
useQuickCreateForm: false
};
var formParameters = {
name: "Sample Account",
description: "This is example of how you can prepopulate the fields on opened entity"
};
View open_file.js
function openFile() {
var file = {
fileContent: "bXkgc2VjcmV0IGNvbnRlbnQ=", //Contents of the file.
fileName: "example.txt", //Name of the file.
fileSize: 24, //Size of the file in KB.
mimeType: "text/plain" //MIME type of the file.
}
Xrm.Navigation.openFile(file, 2);
}
View show_error_dialog.js
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 => {
You can’t perform that action at this time.