Skip to content

Instantly share code, notes, and snippets.

View johnnycardy's full-sized avatar

Jonathan Cardy johnnycardy

  • Northern Ireland
View GitHub Profile
@johnnycardy
johnnycardy / pubsub.ts
Created July 13, 2020 18:46
Simple pub/sub TypeScript class
export default class PubSub {
private topics: { [id: string] : PubSubTopic; } = {};
private constructor(){
}
public static subscribe(topic:string, listener:(args:any)=>void) : void {
this.getInstance().subscribeToTopic(topic, listener);
}
@johnnycardy
johnnycardy / test-list-items.ts
Created May 31, 2020 17:36
Code for creating test list items for demos etc.
private createListItem() : void {
this.context.spHttpClient.post(`https://TENANT.sharepoint.com/_api/web/lists/GetByTitle('Opportunities')?$select=ListItemEntityTypeFullName`, SPHttpClient.configurations.v1, {
method: 'get',
headers: new Headers({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
}).then(result => {
@johnnycardy
johnnycardy / ExecuteQueryAsync
Last active August 29, 2019 08:18
ExecuteQueryAsync for Microsoft SharePoint CSOM 15/16 (On Premise)
private static async Task CSOM15ExecuteAsync(ClientRuntimeContext clientContext)
{
try
{
//ScriptTypeMap.EnsureInited();
Assembly csomRuntime = Assembly.GetAssembly(typeof(ClientRuntimeContext));
Type scriptTypeMap = csomRuntime.GetType("Microsoft.SharePoint.Client.ScriptTypeMap");
InvokePrivateStaticMethod(scriptTypeMap, "EnsureInited");
//ClientRequest pendingRequest = PendingRequest;
@johnnycardy
johnnycardy / GetEntityParametersCodeActivity.cs
Last active September 26, 2022 10:43
Microsoft CRM workflow code activity to retrieve various useful parameters for the current executing context.
public class GetEntityParametersCodeActivity : CodeActivity
{
[Output("PrimaryEntityID")]
[ArgumentDescription("Primary Entity ID.")]
public OutArgument<string> PrimaryEntityId { get; set; }
[Output("PrimaryEntityName")]
[ArgumentDescription("Primary Entity Name.")]
public OutArgument<string> PrimaryEntityName { get; set; }
<! Reference jQuery on the Google CDN >
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<! Reference jQueryUI on the Google CDN >
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js" type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js" type="text/javascript"></script>
<style>
.ui-widget-header { background: none; border-radius: 0; border-left: 0; border-top: 0; border-right: 0; }
#tabsContainer { border:none;}
.ms-webpartzone-cell { margin: 0 !important; border:0; }