Skip to content

Instantly share code, notes, and snippets.

View junaideqbal's full-sized avatar
🌩️
Salesforcing...

Junaid Iqbal junaideqbal

🌩️
Salesforcing...
View GitHub Profile
javascript:(function(){window.open('/ltng/switcher?destination=classic%27,%27_blank%27);})()
@junaideqbal
junaideqbal / controller.cls
Last active May 13, 2024 04:43
LWC Lightning Map
public with sharing class MapDataController {
@AuraEnabled(cacheable=true)
public static List<Opportunity> getAllLocations(){
List<Opportunity> oppList;
try {
Map_data__c settings = Map_data__c.getInstance();
String filters = settings.QueryFilters__c;
@junaideqbal
junaideqbal / Formula
Created April 25, 2024 05:59
How to remove line breaks from billing street formula field Salesforce remove HL_ENCODED problem in formula field
SUBSTITUTE( Account.BillingStreet ,SUBSTITUTE($Label.linebreak, "-", "")," ")
@junaideqbal
junaideqbal / ExtractDeadAccounts.cls
Last active April 3, 2024 09:27
Send email from Apex with csv attached
// set email address where to recieve extracted ids in csv format
String emailAddress = 'junaid.iqbal@u-blox.com';
// Collect accounts without related records
Set<Id> accountsWithoutRelatedRecords = new Set<Id>();
for(Account acc : [SELECT Id FROM Account WHERE Id NOT IN (SELECT AccountId FROM Opportunity) AND Id NOT IN (SELECT AccountId FROM Contact)]) {
accountsWithoutRelatedRecords.add(acc.Id);
}
system.debug('==Total=Acc=from=opportunity=AND=contact=======>'+accountsWithoutRelatedRecords.size());
@junaideqbal
junaideqbal / SyncLineItemandOppProduct.cls
Last active August 24, 2023 09:35
Sync 2 Salesforce Objects
public with sharing class SyncLineItemandOppProduct {
public static Boolean triggeredFromLineItem = true;
public static Boolean isOppProductUpdateCall = true;
public static Boolean syncRecursion = true;
private List<Schema.FieldSetMember> lineItemFieldSetMemberList;
private List<Schema.FieldSetMember> opProductFieldSetMemberList;
public static List<Schema.FieldSetMember> readFieldSet(String fieldSetName, String ObjectName) {
@junaideqbal
junaideqbal / component.cmp
Last active December 4, 2022 08:05
Lightning Aura File Upload
<aura:component description="CaseFeedComments" access="global" controller="CaseFeedCommentsCtrl" implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId,force:LightningQuickAction">
<aura:attribute name="filetype" type="List" default="['.png', '.jpg', '.jpeg', '.pdf']" />
<aura:attribute name="fileContentVersionId" type="String"/>
<aura:attribute name="fileContentDocumentId" type="String"/>
<lightning:fileUpload label="Supported files (.png, .jpg, .jpeg, .pdf)"
name="fileUploader"
multiple="true"
accept="{!v.filetype}"
recordId="{!v.recordId}"
@junaideqbal
junaideqbal / controller.js
Last active November 10, 2022 11:18
Aura quick action confirmation dialogue
({
sendEmail : function(component, event, helper) {
component.set("v.loaded", false);
var recordId = component.get("v.recordId");
var recordIdStr = recordId.toString();
let action = component.get("c.updateSubscriptionField");
action.setParams({ "contactId" : recordId });
// Callback
action.setCallback(this, function(response) {
@junaideqbal
junaideqbal / BatchFieldUpdater.cls
Last active September 27, 2022 09:25 — forked from AlwaysThinkin/Batch Field Updater
A generic Apex Batch Update to update a field on all records for an sObject class based on the examples from the Developer Guide
/* BatchRecordUpdate will update any 1 field on any 1 object.
*
* String values must be set to Object, Field and Value to be added to Field.
*
* Query can be modified to limit records updated.
* Example below excludes records for which Degree Offering already equals the new value.
*
* All 4 strings' values must be set to operate when executed.
*
* Execute in Anonymous Apex.
@junaideqbal
junaideqbal / package.xml
Created August 24, 2022 06:11 — forked from iamsonal/package.xml
Package.xml to retrieve all metadata from salesforce org
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ActionLinkGroupTemplate</name>
</types>
<types>
<members>*</members>
<name>AnalyticSnapshot</name>
</types>
@junaideqbal
junaideqbal / SFileHandler.cls
Last active December 3, 2021 05:03
Salesforce and SharePoint Integration using SFiles
public with sharing class SFileHandler {
// Integration with Salesforce Opportunity Object
@future(callout=true)
public static void createFolder(Id opId) {
Opportunity opp = [select id, name, fileforcem1__Sharepoint_Folder_Id__c from opportunity where id=:opId Limit 1];
//get auth info from the Settings MDT
fileforcem1__SharePoint_Settings__mdt orgSettings = [SELECT fileforcem1__Named_Credential__c,fileforcem1__Document_Library_Id__c,fileforcem1__Site_Id__c FROM fileforcem1__SharePoint_Settings__mdt WHERE Developername = 'Default' limit 1];
//get the root folder id for the account object
fileforcem1__SharePoint_Object_Settings__mdt objectSettings = [SELECT fileforcem1__Root_Folder_Id__c,fileforcem1__Site_Id__c,fileforcem1__Document_Library_Id__c FROM fileforcem1__SharePoint_Object_Settings__mdt WHERE MasterLabel ='Opportunity' LIMIT 1 ];
//Initialize the client object