Skip to content

Instantly share code, notes, and snippets.

@melamriD365
melamriD365 / fetchsubgridClassicUI.js
Last active Apr 29, 2019
Change fetchXml for a subgrid dynamically
View fetchsubgridClassicUI.js
/*----------------------------------------
Change fetchXml for a subgrid dynamically
-----------------------------------------*/
function FetchViaName(executionContext) {
var formContext = executionContext.getFormContext();
var tabObj = formContext.ui.tabs.get("tab_summary");
var secObj = tabObj.sections.get("sec_contactCompaigns");
secObj.setVisible(false)
@melamriD365
melamriD365 / fetchsubgridClassicUIAndUCI.js
Created Apr 29, 2019
set fetchXml dynamically to a subgrid in classic UI and Unified Client Interface
View fetchsubgridClassicUIAndUCI.js
function FetchViaName(executionContext) {
var formContext = executionContext.getFormContext();
var fullname = null;
var tabObj = formContext.ui.tabs.get("tab_summary");
var secObj = tabObj.sections.get("sec_contactCompaigns");
secObj.setVisible(false)
var isUnified = isUCI()
//--------------------------------------Unified Interface----------------------------------------//
@melamriD365
melamriD365 / Activities.js
Created Jan 13, 2020
Dynamics365 CRM UCI get all activities (subgrid refresh)
View Activities.js
function getActivities(executionContext) {
var formContext = executionContext.getFormContext();
//get current contact id;
var recordId = formContext.data.entity.getId();
var ActivitiesSubGridControl = formContext.getControl("ActivitiesSubGrid");
//recordId = recordId.replace("{", "").replace("}", "");
recordId = recordId.slice(1, -1);
var orConditionsList = [];
var orConditionsFetchXml = "";
View getViewIdFromUrl.js
var urlParams = new URLSearchParams(Xrm._page.getUrl());
var viewId = urlParams.get("viewid").replace("{","").replace("}","")
console.log("viewId: " + viewId)
/*
viewId: 61273827-328E-E011-95AE-00155D9CFA03
*/
View DisplayAllChildAccounts.js
function DisplayAllChildAccounts(executionContext) {
var formContext = executionContext.getFormContext();
var accountId = formContext.data.entity.getId();
var childAccountGridContext = formContext.getControl("ChildAccounts");
if (childAccountGridContext == null) {
setTimeout(function () { getAllChildAccounts(executionContext); }, 2000);
}
else {
View getAllUsersPersonalViewsContainingField.cs
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.ServiceModel.Description;
namespace MelTools
{
class getAllUsersPersonalViewsContainingField
View OptionSetUtilities.js
if(typeof(MEA)=="undefined"){MEA={}};
if(typeof(MEA.OptionSet)=="undefined"){MEA.OptionSet={}};
if(typeof(MEA.OptionSet.Utilities)=="undefined"){MEA.OptionSet.Utilities={}};
MEA.OptionSet.Utilities = {
//Cascading Utility
optionSetBValues : null,
Cascade: function (executionContext, optionAName, optionBName, dependecies) {
var formContext = executionContext.getFormContext();
var selectedAValue = formContext.getAttribute(optionAName).getValue();
@melamriD365
melamriD365 / opportunityForm.js
Last active Apr 13, 2021
How to set up complex conditions for business process flow ?
View opportunityForm.js
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Opportunity) == "undefined") { MEA.Opportunity = {} };
if (typeof (MEA.Opportunity.OpportunityForm) == "undefined") { MEA.Opportunity.OpportunityForm = {} };
MEA.Opportunity.OpportunityForm = {
onLoad: function (executionContext) {
var formContext = executionContext.getFormContext();
formContext.getAttribute('budgetamount').addOnChange(this.setNeedApproval);
formContext.getAttribute('mea_riskscode').addOnChange(this.setNeedApproval);
formContext.getControl('mea_isneedapproval').setDisabled(true);
@melamriD365
melamriD365 / AccountForm.js
Created Apr 23, 2021
Open all lookups in a modal dialog
View AccountForm.js
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Account) == "undefined") { MEA.Account = {} };
if (typeof (MEA.Account.AccountForm) == "undefined") { MEA.Account.AccountForm = {} };
MEA.Account.AccountForm = {
onLoad: function (executionContext) {
var formContext = executionContext.getFormContext();
var attributes = formContext.data.entity.attributes;
attributes.forEach(att => {
att.getAttributeType() == 'lookup' ?
@melamriD365
melamriD365 / Utilities.js
Created Apr 23, 2021
Open all lookups in a modal dialog across the CRM
View Utilities.js
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Utilities) == "undefined") { MEA.Utilities = {} };
MEA.Utilities = {
onLoad:function(primaryControl, cmdProperties){
var formContext = primaryControl;
this.openModalFormForAllLookupFields(formContext);
},
openModalFormForAllLookupFields: function(formContext){
var attributes = formContext.data.entity.attributes;