Skip to content

Instantly share code, notes, and snippets.

View jamesasu's full-sized avatar

James Angus jamesasu

View GitHub Profile
// tJavaRow:
java.util.List<String> oppids;
if (!globalMap.containsKey("oppids")) {
oppids = new java.util.ArrayList<String>();
} else {
oppids = (java.util.List<String>) globalMap.get("oppids");
}
if (input_row.AS_External_ID__c != null && !input_row.AS_External_ID__c.equals("")) {
(function() {
window.addEventListener("DOMContentLoaded", (event) => {
const hostname = window.location.hostname;
const params = new URLSearchParams(window.location.search);
const utm_params = [];
params.forEach(function(value, key) {
if (key.startsWith('utm_')) {
utm_params.push(key+'='+value)
}
})
String dateUpdatedQueryString = "";
Integer numberOfDays = (Integer) context.NumberOfDays;
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
if (numberOfDays != null && numberOfDays > 0) {
java.util.Calendar today = java.util.Calendar.getInstance();
today.setTime(new Date());
today.add(java.util.Calendar.DATE, -numberOfDays);
dateUpdatedQueryString = "&DateUpdated[after]=" + DATE_FORMAT.format(today.getTime());
System.out.println("dateUpdatedQueryString: " + dateUpdatedQueryString);
@jamesasu
jamesasu / bigquery-lag-window-partition.sql
Created June 16, 2021 23:05
Use the LAG() function to include details about the previous record in a series.
SELECT
ocr.ContactId,
ocr.OpportunityCloseDate,
ocr.OpportunityAmount,
LAG(ocr.OpportunityCloseDate, 1) OVER (PARTITION BY ocr.ContactId ORDER BY ocr.OpportunityCloseDate ASC) AS `Prev`
FROM
`OpportunityContactRoles` AS ocr
WHERE
ocr.OpportunityAmount > 0
ORDER BY
public static String getIconName(String sObjectName){
String u;
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
List<Schema.DescribeIconResult> iconDesc = new List<Schema.DescribeIconResult>();
for(Schema.DescribeTabSetResult tsr : tabSetDesc) { tabDesc.addAll(tsr.getTabs()); }
for(Schema.DescribeTabResult tr : tabDesc) {
if( sObjectName == tr.getSobjectName() ) {
global class AFFL_AffiliationsStartDate_TDTM extends npsp.TDTM_Runnable {
global override npsp.TDTM_Runnable.DmlWrapper run(List<SObject> newlist,
List<SObject> oldlist,
npsp.TDTM_Runnable.Action triggerAction,
Schema.DescribeSObjectResult objResult) {
npsp.TDTM_Runnable.dmlWrapper dmlWrapper = new npsp.TDTM_Runnable.DmlWrapper();
List<npe5__Affiliation__c> newAffils = (List<npe5__Affiliation__c>) newlist;
List<npe5__Affiliation__c> oldAffils = (List<npe5__Affiliation__c>) oldlist;
// If not the "System" user or a System Administrator, then do the thing....
!OR(
AND(
$User.FirstName == '',
$User.LastName == 'System'
),
$Profile.Name == 'System Administrator'
)
// Visualforce Page: MySU_Redirect_Page
<apex:page controller="MySURedirectController" action="{!redirect}"/>
// Apex Controller:
public class MySURedirectController {
public PageReference redirect() {
Id serviceRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('LCC').getRecordTypeId();
Map<String,String> getParams = ApexPages.currentPage().getParameters();
String serviceId = getParams.get('service_id');
@jamesasu
jamesasu / talend-merge-address-lines.java
Created September 16, 2020 03:46
Helper functions that can be used a tMap to merge multiple address lines into a single line.
package routines;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class MyHelper {
/**