Skip to content

Instantly share code, notes, and snippets.

View kiran-machhewar's full-sized avatar

Kiran Machhewar kiran-machhewar

View GitHub Profile
/**
* Created by kmachhewar on 5/26/18.
*/
({
closeMessage : function(component,event){
component.set('v.showMessage',false);
}
})
/**
* 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'),
<!--
- 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="[]"/>
@kiran-machhewar
kiran-machhewar / PermissionSets.java
Last active December 18, 2018 16:22
Permission Set
//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 August 21, 2018 10:36
This will cache the query via workbench.
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 July 4, 2018 04:20
Analysis on Async Queues - SOQL, kill Async Jobs
****** 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 June 29, 2018 05:08
Get the DateTime from the Dates format which is GMT
/**
* @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');
}
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{
/**
* @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 June 26, 2018 22:59
Apex Documentation
/**
* @author Kiran Machhewar
* @date 26th June 2018
* @description Controller class for so and so page
*/
public class ApexClass{
}