Skip to content

Instantly share code, notes, and snippets.

@melamriD365
melamriD365 / Plg_ExecuteFetchXml.cs
Created Mar 16, 2022
Power Automate - Dataverse] How to execute a fetchXml query that includes options not supported by the List rows connector?
View Plg_ExecuteFetchXml.cs
// <copyright file="Plg_ExecuteFetchXml.cs" company="">
// Copyright (c) 2022 All Rights Reserved
// </copyright>
// <author></author>
// <date>3/14/2022 2:38:36 PM</date>
// <summary>Implements the Plg_ExecuteFetchXml Plugin.</summary>
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
@melamriD365
melamriD365 / AccountForm.js
Created Mar 1, 2022
OnChange events always called twice after new record creation (Good Practice)
View AccountForm.js
var MEA = window.MEA || {};
var accountForm = MEA.accountForm || {};
(function () {
this.OnLoad = function (onLoadContext) {
console.log("onLoad ....");
var eventArgs = onLoadContext.getEventArgs();
var formContext = onLoadContext.getFormContext();
if (eventArgs.getDataLoadState() == 1) {
formContext.getAttribute('telephone1').addOnChange(this.OnChangeHandler);
@melamriD365
melamriD365 / AccountForm.js
Last active Mar 2, 2022
OnChange events always called twice after new record creation (Bad Practice)
View AccountForm.js
var MEA = window.MEA || {};
var accountForm = MEA.accountForm || {};
(function () {
this.OnLoad = function (onLoadContext) {
console.log("onLoad ....");
var formContext = onLoadContext.getFormContext();
formContext.getAttribute('telephone1').addOnChange(this.OnChangeHandler);
};
this.OnChangeHandler = function (onChangeContext) {
@melamriD365
melamriD365 / OptimisticConcurrencyForm.js
Created Jan 9, 2022
Optimistic Concurrency in Model-Driven Apps Forms.
View OptimisticConcurrencyForm.js
//Optimistic Concurrency in Model-Driven Apps Forms
var MEA = window.MEA || {};
var OptimisticConcurrencyForm = MEA.OptimisticConcurrencyForm || {};
(function () {
var versionNumber = null;
var entityReference = null;
this.OnLoad = async function (executionContext) {
var eventArgs = executionContext.getEventArgs();
if (eventArgs.getDataLoadState() == 1) {
@melamriD365
melamriD365 / CancelMergeForChilds_PostOperation.cs
Last active Jan 1, 2022
Dynamics 365 CRM [Dataverse] - How to cancel of the merge cascade for a given relationship ? (Post-Operation Plugin)
View CancelMergeForChilds_PostOperation.cs
using System;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Xrm.Sdk.Query;
namespace MergePoc.Plugins
{
@melamriD365
melamriD365 / CancelMergeForChilds_PreOperation.cs
Last active Jan 1, 2022
Dynamics 365 CRM [Dataverse] - How to cancel of the merge cascade for a given relationship ? (CancelMergeForChilds_PreOperation)
View CancelMergeForChilds_PreOperation.cs
using System;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Xrm.Sdk.Query;
namespace MergePoc.Plugins
{
@melamriD365
melamriD365 / PreOperationAccountMerge.cs
Created Dec 17, 2021
Dynamics 365 For Sales: How to merge Accounts if the subordinate record is associated with one or more active quotes?
View PreOperationAccountMerge.cs
// <copyright file="PreOperationAccountMerge.cs" company="">
// Copyright (c) 2021 All Rights Reserved
// </copyright>
// <author></author>
// <date>12/17/2021 6:04:07 PM</date>
// <summary>Implements the PreOperationAccountMerge Plugin.</summary>
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
@melamriD365
melamriD365 / sendObjectFromMDAToCustomPage.js
Created Oct 25, 2021
pass an object from a model driven app to a custom page
View sendObjectFromMDAToCustomPage.js
var pageInput = {
pageType: "custom",
name: "mea_home_809de",
recordId:JSON.stringify({prop1: "Hello,", prop2: " World !"})
};
Xrm.Navigation.navigateTo(pageInput).then(
function success() {
// Run code on success
},
@melamriD365
melamriD365 / AsyncScriptTraining.js
Last active Oct 16, 2021
DEMOS Source Code (Async Web Client Capabilities on Model-Driven-Apps/Malaysia D365 & Power Platform User Group - October 2021 Meetup)
View AsyncScriptTraining.js
function onLoad(executionContext) {
var formContext = executionContext.getFormContext();
//DEMO 1
//formContext.getAttribute('firstname').addOnChange(displayDialogAfter5Secondes);
//DEMO 2
formContext.data.entity.addOnSave(validatePhoneNumber);
//DEMO 4
//formContext.ui.addOnLoad(applyForm);
}
//DEMO 1
View AccountForm.js
function openDialog(exectionContext) {
var dialogParameters = {
pageType: "custom",
name: "new_dialogsample_bb2dc",
};
var navigationOptions = {
target: 2,//use 1 if you want to open page inline or 2 to open it as dialog
width: 800, // value specified in pixel
height: 420,
position: 1,//1 to locate dialog in center and 2 to locate it on the side,