Skip to content

Instantly share code, notes, and snippets.

View MitchMilam's full-sized avatar

Mitch Milam MitchMilam

  • Dallas, Texas
  • 01:19 (UTC -05:00)
View GitHub Profile
@MitchMilam
MitchMilam / DoesRecordExist.cs
Last active June 8, 2024 22:57
Verify that a Dynamics 365 record exists
private static bool DoesRecordExist(IOrganizationService crmService, string entityName, Guid id)
{
try
{
crmService.Retrieve(entityName, id, new ColumnSet());
}
catch (Exception ex)
{
if (ex is FaultException<OrganizationServiceFault> orgException)
{
@MitchMilam
MitchMilam / ImportData.cs
Created September 3, 2023 19:31
Programmatically import data into Dynamics 365
public void Run()
{
var url = "https://[].crm.dynamics.com";
var userName = "";
var password = "";
// Default Azure application
var conn = $@"
Url = {url};
AuthType = OAuth;
@MitchMilam
MitchMilam / DeleteAttachments.cs
Created August 30, 2023 20:32
Dynamics 365: Delete Attachments from email messages
private static void DeleteAttachments(CrmServiceClient crmService)
{
const bool testing = true;
const int filesize = 0;
const string actualend = "2023-12-31T00:00:00-06:00";
const string operationDescription = testing ? "Retrieved" : "Deleting";
var query = new QueryExpression("email")
{
Distinct = true,
@MitchMilam
MitchMilam / DynamicListView.cs
Last active August 30, 2023 20:34
Dynamic ListView
using System;
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace XamarinFormsDeepDive
{
class ListViewDemo2 : ContentPage
{
class Person
{
@MitchMilam
MitchMilam / ListViewAlternatingBackgroundColors.cs
Last active August 30, 2023 20:34
Alternating background colors in a Xamarin.Forms ListView
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace XamarinFormsDeepDive
{
class ListViewDemo : ContentPage
{
class Person
{
@MitchMilam
MitchMilam / SetSectionLabel.js
Last active August 30, 2023 20:36
Set the Section Label based on a field value
function onLoad() {
Xrm.Page.getAttribute("address1_addresstypecode").fireOnChange();
Xrm.Page.getAttribute("address2_addresstypecode").fireOnChange();
}
function addressType_onChange(executionContextObj) {
const field = executionContextObj.getEventSource();
const addressType = field.getText();
@MitchMilam
MitchMilam / NumberCell.cs
Last active August 30, 2023 20:41
Demonstrates how to put to views into a single cell
public class NumberCellPage : ContentPage
{
public NumberCellPage()
{
var grid = new Grid
{
RowSpacing = 0,
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand
};
@MitchMilam
MitchMilam / Crm.IsTeamMember.cs
Last active August 30, 2023 20:42
IsTeamMember method for Dynamics CRM .Net developers
public static bool IsTeamMember(IOrganizationService service, Guid userId, Guid teamId)
{
var request = new RetrieveTeamsSystemUserRequest
{
EntityId = userId,
ColumnSet = new ColumnSet()
};
var response = (RetrieveTeamsSystemUserResponse)service.Execute(request);