Skip to content

Instantly share code, notes, and snippets.

Avatar

Kiran Machhewar kiran-machhewar

View GitHub Profile
View CustomToastHelper.js
/**
* Created by kmachhewar on 5/26/18.
*/
({
closeMessage : function(component,event){
component.set('v.showMessage',false);
}
})
View CustomToastController js
/**
* Created by kmachhewar on 5/26/18.
*/
({
handleShowToastEvent : function(component,event,helper){
event.stopPropagation();
if(event.getParam('message')){
var messages = component.get('v.messages');
let messageItem = {
type : event.getParam('type'),
View CustomToast.cmp
<!--
- Created by kmachhewar on 5/26/18.
-->
<aura:component description="CustomToast">
<aura:attribute name="title" type="String" default="" />
<aura:attribute name="type" type="String" default="" />
<aura:attribute name="message" type="String" default="" />
<aura:attribute name="showMessage" type="Boolean" default="false" />
<aura:attribute name="messages" type="Object[]" default="[]"/>
View PermissionSets.java
//Add Permission Sets to Users
List<User> users = [SELECT Id FROM User WHERE username in ('<USERNAME_GOES_HERE>')];
List<PermissionSet> permissionSets = [SELECT Id FROM PermissionSet WHERE Name = '<PERMISSION SET API NAMES GOES HERE>'];
List<PermissionSetAssignment> permissionSetAssignemts = new List<PermissionSetAssignment>();
for(User theUser : users){
for(PermissionSet ps : permissionSets){
permissionSetAssignemts.add(
new PermissionSetAssignment(AssigneeId = theUser.Id,PermissionSetId = ps.Id )
);
}
@kiran-machhewar
kiran-machhewar / CacheQueryViaWorkbench.js
Created Aug 21, 2018
This will cache the query via workbench.
View CacheQueryViaWorkbench.js
function cacheQuery(){
//check if the result came or not
if(!document.getElementById('query_results') && document.getElementsByClassName('displayWarning').length == 0 ){//no results found
//check if system is not waiting for the result i.e query is processing
if(!document.getElementsByClassName('disableWhileAsyncLoading')[0].disabled){ //button is not disabled so try again
document.getElementsByClassName('disableWhileAsyncLoading')[0].click();
}
}
}
@kiran-machhewar
kiran-machhewar / AsyncUtil.cls
Last active Jul 4, 2018
Analysis on Async Queues - SOQL, kill Async Jobs
View AsyncUtil.cls
****** BEGIN --> APEX CLASS wise distribution *****
SELECT ApexClass.Name, COUNT(ID) FROM AsyncApexJob WHERE Status = 'Queued' GROUP BY ApexClass.Name ORDER BY COUNT(ID) DESC
****** END --> APEX CLASS wise distribution *****
****** BEGIN --> Kill Async Jobs *****
for ( AsyncApexJob aJob : [ Select id ,Status, ApexClass.Name
from AsyncApexJob where Status='Queued' AND ApexClass.Name ='<ApexClassName>' LIMIT 150] ){
@kiran-machhewar
kiran-machhewar / Util.cls
Created Jun 29, 2018
Get the DateTime from the Dates format which is GMT
View Util.cls
/**
* @dateString : format should be like this 2018-06-10T12:34:15.29
*/
public DateTime parseDate(String dateString){
String dateStringJSON = ('{ "thedate": "'+dateString+'"}');
Map<String, DateTime> mockMap;
mockMap = (Map<String, DateTime>)JSON.deserialize(dateStringJSON, Map<String, DateTime>.class);
return mockMap.get('thedate');
}
View LightningUtilController.cls
public without sharing class LightningUtilController {
/**
* Method to update sobject record
* @param theSObject
* @return returns the created/updated sobject record
*/
@AuraEnabled
public static SObject upsertSObjectCtrl(SObject theSObject){
try{
View JSONObject.cls
/**
* @ApexClass : JSONObject
* @Author : Kiran Machhewar
* @Description : This class can be used to parse and work with json data in apex easy.
*/
public class JSONObject {
public String jsonString; //to hold the json string
private Object jsonObject; //to hold the deserialized json data
@kiran-machhewar
kiran-machhewar / ApexClass.cls
Last active Jun 26, 2018
Apex Documentation
View ApexClass.cls
/**
* @author Kiran Machhewar
* @date 26th June 2018
* @description Controller class for so and so page
*/
public class ApexClass{
}
You can’t perform that action at this time.