Skip to content

Instantly share code, notes, and snippets.

@chrisobriensp
chrisobriensp / PowerApps_TimerSubmitIfOnline.txt
Created December 27, 2018 13:35
PowerApps formula to submit a record if device is online - can be run on a timer OnEnd function for example.
If(
Connection.Connected && !IsEmpty(LocalRecord),
ForAll(
LocalRecord,
Patch(
'My SharePoint list',
Defaults('My SharePoint list'),
{
Title: Concatenate(
"Leave Request - ",
@chrisobriensp
chrisobriensp / PowerApps_SubmitIfOnline_SaveIfOffline.txt
Created December 24, 2018 12:02
PowerApps formula to save a record locally if device is offline, or submit it to datasource otherwise.
If(
Connection.Connected,
Patch(
'My SharePoint list',
Defaults('My SharePoint list'),
{
Title: Concatenate(
"Leave Request - ",
User().Email,
" - ",
@chrisobriensp
chrisobriensp / UpgradeSPFx1.6.bat
Created September 21, 2018 14:31
Commands to upgrade an SPFx project to version 1.6 - though additional commands would be needed for any 3rd party npm packages used.
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
npm install @microsoft/[email protected] --save
@chrisobriensp
chrisobriensp / COB_KeepEndpointWarm_Function.cs
Last active September 17, 2018 11:20
A C# Azure Function to keep other function apps warmed-up (to avoid cold-start issues). Expects URL(s) to be specified in environment variables/app settings.
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace COB.AzureFunctions
{
public static class EndPointKeepWarm
{
@chrisobriensp
chrisobriensp / BadFetchUserProfile_PowerAppsFormula.txt
Created August 29, 2018 12:49
Do not do this - this is the inefficient way to hook up a data source/Azure Function to PowerApps form controls
// do NOT do this - using your Data Source/Azure Function this way *WILL* result in the function being called multiple times..
UpdateContext({fetchedDisplayName: 'cob-gen-functions.azurewebsites.net'.apiFetchUserDetailspost({userPrincipalName: lblUserEmail.Text}).displayName});
UpdateContext({fetchedUserPhone: 'cob-gen-functions.azurewebsites.net'.apiFetchUserDetailspost({userPrincipalName: lblUserEmail.Text}).phone});
UpdateContext({fetchedUserLocation: 'cob-gen-functions.azurewebsites.net'.apiFetchUserDetailspost({userPrincipalName: lblUserEmail.Text}).officeLocation});
UpdateContext({fetchedUserJobTitle: 'cob-gen-functions.azurewebsites.net'.apiFetchUserDetailspost({userPrincipalName: lblUserEmail.Text}).jobTitle})
@chrisobriensp
chrisobriensp / UpdateUserProfile_PowerAppsFormula.txt
Created August 28, 2018 16:39
PowerApps formula to call Azure Function via existing data source - in this case to UPDATE the user's profile data from Office 365
'cob-gen-functions.azurewebsites.net'.apiUpdateUserDetailspost(
{
userPrincipalName: lblUserEmail.Text,
displayName: txtDisplayName.Text,
jobTitle: txtJobTitle.Text,
mobilePhone: txtPhone.Text,
officeLocation: txtLocation.Text
}
)
@chrisobriensp
chrisobriensp / FetchUserProfile_PowerAppsFormula.txt
Last active August 28, 2018 16:45
PowerApps formula to call Azure Function via existing data source - in this case to FETCH the user's profile data from Office 365
UpdateContext({fetchedUserData: 'cob-gen-functions.azurewebsites.net'.apiFetchUserDetailspost({userPrincipalName: lblUserEmail.Text})})
@chrisobriensp
chrisobriensp / COB_AadProfileFunctions_CompletedDefinition.json
Last active August 1, 2018 16:11
Updated Open API definition for my functions, providing low level detail of data passed in and returned.
swagger: '2.0'
info:
title: cob-gen-functions.azurewebsites.net
version: 1.0.0
host: cob-gen-functions.azurewebsites.net
basePath: /
schemes:
- https
- http
paths:
@chrisobriensp
chrisobriensp / COB_AadProfileFunctions_DefaultDefinition.json
Last active July 30, 2018 19:55
Default Open API definition for my functions, as generated by Azure
swagger: '2.0'
info:
title: cob-gen-functions.azurewebsites.net
version: 1.0.0
host: cob-gen-functions.azurewebsites.net
basePath: /
schemes:
- https
- http
paths:
@chrisobriensp
chrisobriensp / UpdateAadProfileFunction.cs
Last active August 7, 2018 09:47
An Azure Function to be used in PowerApps/Flow for updating the user's Office 365/Azure AD profile.
public static class UpdateUserDetails
{
// tip - use Managed Service Identity + Key Vault in real-life. In this example, AAD app registration details are kept simple/in code..
public static string resourceId = "https://graph.microsoft.com";
public static string tenantId = "TODO";
public static string authString = "https://login.microsoftonline.com/" + tenantId;
public static string upn = string.Empty;
public static string clientId = "TODO";
public static string clientSecret = "TODO";