Skip to content

Instantly share code, notes, and snippets.

View ganmahmud's full-sized avatar
🎯
Focusing

Gan Mahmud ganmahmud

🎯
Focusing
View GitHub Profile
@ganmahmud
ganmahmud / ContactAndLeadSearch.cls
Last active November 21, 2018 06:48
Create an Apex class that returns both contacts and leads based on a parameter.
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads(String lastName){
List<List<SObject>> searchList = [FIND :lastName IN ALL FIELDS
RETURNING Lead(Name), Contact(FirstName,LastName)];
Lead[] searchLead = (Lead[])searchList[0];
Contact[] searchContacts = (Contact[])searchList[1];
System.debug('Found the following leads.');
for (Lead a : searchLead) {
System.debug(a.Name);
}
@ganmahmud
ganmahmud / ContactSearch.cls
Last active April 16, 2022 19:46
Create an Apex class that returns contacts based on incoming parameters.
public class ContactSearch {
public static Contact[] searchForContacts(String lastName, String postCode){
Contact[] cts = [SELECT Contact.ID,Contact.Name FROM Contact
WHERE LastName = :lastName AND MailingPostalCode= :postCode];
return cts;
}
}
@ganmahmud
ganmahmud / AccountHandler.cls
Last active November 21, 2018 06:49
Create a method for inserting accounts.
public class AccountHandler {
public static Account insertNewAccount(String accountName){
try{
Account acct = new Account(Name=accountName);
insert acct;
return acct;
}
catch (DmlException e){
System.debug('A DML exception has ocurred: ' + e.getMessage());
return (NULL);
@ganmahmud
ganmahmud / StringArrayTest.cls
Last active November 21, 2018 06:49
Create an Apex class with a method that returns an array (or list) of strings.
public class StringArrayTest {
public static String[] generateStringArray(Integer numOfStrings) {
// Create a generateStringArray object
String[] stringArr = new List<String>();
for(Integer i=0;i<numOfStrings;i++) {
stringArr.add('Test '+i);
}
return stringArr;
}
@ganmahmud
ganmahmud / AccountAddressTrigger.apxt
Last active November 21, 2018 06:38
Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account a : Trigger.new){
If (a.Match_Billing_Address__c == true && a.BillingPostalCode!=Null) {
a.ShippingPostalCode = a.BillingPostalCode;
System.debug('ShippingPostalCode: '+a.ShippingPostalCode);
System.debug('BillingPostalCode: '+a.BillingPostalCode);
}
}
}
@ganmahmud
ganmahmud / CtoP.php
Last active November 21, 2018 06:55
<?php
add_action('admin_menu', 'test_plugin_setup_menu');
function test_plugin_setup_menu(){
add_menu_page( 'Shoppers Mag CSV Import Page', 'Shoppers Mag CSV Import', 'manage_options', 'csv-import', 'test_init', "dashicons-image-rotate-right",2 );
}
function test_init(){
test_handle_post();
[
{
"gender": "male",
"name": {
"title": "mr",
"first": "aiden",
"last": "lucas"
},
"location": {
"street": "1446 oak lawn ave",
@ganmahmud
ganmahmud / search_result.html
Created January 2, 2018 18:48
Angular Sample
<!-- search fields -->
<div class="container margin-t20">
<div class="row lnb">
<div class="col-sm-6 col-xs-6">
<div class="khojnow-brand">
<a href="../app"><img src="images/logo.png" alt="Logo" class="img-responsive"></a>
</div>
</div>
@ganmahmud
ganmahmud / rtl.js
Created January 26, 2017 22:55
For RTL
jQuery(window).bind("load", function() {
// code here
if (jQuery("body").hasClass('rtl')){
var vc_rows = jQuery("body .vc_row");
for (var i = vc_rows.length - 1; i >= 0; i--) {
vc_rows.css('left', Math.abs(parseInt(vc_rows[i].style.left)));
};
}