Skip to content

Instantly share code, notes, and snippets.

@cddouglass
cddouglass / Create a New Email.OUTLOOK.yaml
Created February 16, 2024 22:15
Create a new snippet from a blank template.
name: Create a New Email
description: Create a new snippet from a blank template.
host: OUTLOOK
api_set: {}
script:
content: |
Office.context.mailbox.displayNewMessageForm({
toRecipients: ['[email protected]'],
subject: 'Script Lab Test Email',
body: {
@cddouglass
cddouglass / Create a New Email.OUTLOOK.yaml
Created February 16, 2024 22:14
Create a new snippet from a blank template.
name: Create a New Email
description: Create a new snippet from a blank template.
host: OUTLOOK
api_set: {}
script:
content: |
Office.context.mailbox.displayNewMessageForm({
toRecipients: ['[email protected]'],
subject: 'Script Lab Test Email',
body: {
@cddouglass
cddouglass / Blank snippet.OUTLOOK.yaml
Created February 16, 2024 22:14
Create a new snippet from a blank template.
name: Blank snippet
description: Create a new snippet from a blank template.
host: OUTLOOK
api_set: {}
script:
content: |
Office.context.mailbox.displayNewMessageForm({
toRecipients: ['[email protected]'],
subject: 'Script Lab Test Email',
body: {
@cddouglass
cddouglass / Work with the categories master list.OUTLOOK.yaml
Created February 16, 2024 22:12
Gets, adds, and removes categories in the master list for the mailbox.
name: Work with the categories master list
description: 'Gets, adds, and removes categories in the master list for the mailbox.'
host: OUTLOOK
api_set: {}
script:
content: |
$("#get-master-categories").on("click", getMasterCategories);
$("#add-master-categories").on("click", addMasterCategories);
$("#remove-master-categories").on("click", removeMasterCategories);
/****************************************************************************************** * Name: Gantt Auto-Date * Author: Mike Pechter * Date: 3/11/2021 * * Suggested use: Use this script to automatically complete a table of tasks, in conjunction with a Gantt View. * */
//PART 1: Script Settings
const config = input.config({ title: 'Gantt: automatically set start/end dates from dependencies', description: `A script that automatically adds start and end dates to a table of tasks. Use in conjuntion with a Gantt View. Please select the table and fields that correspond with the following:`, items: [ input.config.table('table', { label: 'Table',
}), input.config.field('task', { label: 'Task Name', description: 'String', parentTable: 'table', }), input.config.field('duration',{ label: 'Duration', description: `Integer - Contains a tasks's duration in number of weeks.`, parentTable: 'table',
let settings = input.config({
title: 'Create bar chart in Markdown',
description: 'This script will create a bar chart from your data and output it in Markdown',
items: [
input.config.table('table', {
label: 'Table'
}),
input.config.view('view', {
parentTable: 'table',
label: 'View'
let settings = input.config({ title: 'Find and replace', description: `This script will find and replace all text matches for a text-based field you pick. You will be able to see all matches before replacing them.`, items: [ input.config.table('table', { label: 'Table' }), input.config.field('field', { parentTable: 'table', label: 'Field' }), ],});
let { table, field } = settings;output.text(`Finding and replacing in the ${field.name} field of ${table.name}.`);
let findText = await input.textAsync('Enter text to find:');let replaceText = await input.textAsync('Enter to replace matches with:');
// Load all of the records in the tablelet result = await table.selectRecordsAsync();
// Find every record we need to updatelet replacements = [];for (let record of result.records) { let originalValue = record.getCellValue(field);
// Skip non-string records if (typeof originalValue !== 'string') { continue; }
// Skip records which don't have the value set, so the valu
let settings = input.config({ title: 'Delete duplicates', description: `This script will delete duplicate records in a given table according to the value oftwo input fields. Duplicate records are detected when they contain the same cell value for each identifyingfield. For any two records that are considered duplicates, it will use a third comparison field to determinewhich of the two records should be deleted.`, items: [ input.config.table('table', { label: 'Table' }), input.config.field('firstIdField', { parentTable: 'table', label: 'First identifying field', }), input.config.field('secondIdField', { parentTable: 'table', label: 'Second identifying field', }), input.config.field('comparisonField', { parentTable: 'table', label: 'Comparison field' }), ],});
let { table, firstIdField, secondIdField, comparisonField } = settings;
// Airtable limits batch operations to 50 records or fewer.let maxRecordsPerCall = 50
let settings = input.config({ title: "Validate emails", description: "This script will list all invalid emails for a field you pick.", items: [ input.config.table("table", { label: "Table" }), input.config.field("field", { parentTable: "table", label: "Email field", }), ],});
let { table, field } = settings;
// To validate a string of text we need to use a regular expression.// Regular expressions are complex — read more about them here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions// This regular expression checks to see if an email address is in the correct format.let regexp = /[A-z0-9.+-_]+@[A-z0-9-]+\.[A-z]+/g;
// Now let's grab all of the records from the table the user selected by calling the selectRecordsAsync method.// We only need the cell values in the selected field, so we'll specify that with the fields argument.let queryResult = await table.selectRecordsAsync({ fields: [field],});
// Before we move on, l
SWITCH(
{Work Type},
"WAE - Club Booked", (MAX({Revenue} - 125, 0)*.2) + 125,
"WAE - Club Not Booked", ({Revenue}*.4),
{Custom Rate}
)