Skip to content

Instantly share code, notes, and snippets.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes">
<ltng:require scripts="{!join(',',
$Resource.jQuery_3_1_1)}"
afterScriptsLoaded="{!c.onScriptLoaded}"/>
<aura:attribute name="hasreCaptchaVerified" type="Boolean" default="false" />
<aura:attribute name="hostUrl" type="String" />
<aura:attribute name="recaptchaPageName" type="String" default="apex/reCaptcha"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
validateEmail : function(component, event, helper) {
var id = event.getSource().getLocalId();
var emailInp = component.find(id);
var value = emailInp.get("v.value");
var patt = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var res = patt.test(value);
var saveBtn = component.find("saveBtn");
private static Boolean sendEmail (String[] toAddresses, String OTP) {
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.toAddresses = toAddresses;
message.optOutPolicy = 'FILTER';
message.subject = 'OTP';
message.optOutPolicy = 'FILTER';
if (Label.UseOrgWideFromAddress != null && Label.UseOrgWideFromAddress == '1') {
message.setOrgWideEmailAddressId (Label.OrganizationEmailAddress);
}
public with sharing class DataTableColumns {
@AuraEnabled
public String label {get;set;}
@AuraEnabled
public String fieldName {get;set;}
@AuraEnabled
public String type {get;set;}
public DataTableColumns(String label, String fieldName, String type){
this.label = label;
public class DependentPickListUtil {
public static Map<String, List<String>> getDependentMap(sObject objDetail, string contrfieldApiName,string depfieldApiName) {
String controllingField = contrfieldApiName.toLowerCase();
String dependentField = depfieldApiName.toLowerCase();
Map<String,List<String>> objResults = new Map<String,List<String>>();
Schema.sObjectType objType = objDetail.getSObjectType();
//System.debug('objType' + objType);
@sudikrt
sudikrt / Ui_PickListUtility.apxc
Created August 8, 2019 19:12
This Utility class helps to get the pick-list values based on record type (those pick-list values which are available to given record type)
public class Ui_PickListUtility {
public List<Values> values;
public static List<PickListValueWrapper> picklistValuesByRecordType (String objectName, String fieldName, String recordTypeId) {
List<PickListValueWrapper> result = new List<PickListValueWrapper> ();
result.add (new PickListValueWrapper ('--None--', ''));
try {
Http http = new Http ();
HttpRequest request = new HttpRequest ();
jQuery(function($){
var lastHeight = 0, curHeight = 0, $frame = $('iframe:eq(0)');
setInterval(function(){
curHeight = $frame.contents().find('body').height();
if ( curHeight != lastHeight ) {
$frame.css('height', (lastHeight = curHeight) + 'px' );
}
},500);
});
@sudikrt
sudikrt / CaseController.apxc
Created August 10, 2019 06:09
This vf page helps to upload the attachment to the web to case. So that you can embed this VF page inside your lightning component.
public class CaseController {
public transient Attachment objAttachment;
public String message{get;set;}
public String messageType{get;set;}
public Boolean fileUploadProcessed{get;set;}
public Attachment getObjAttachment () {
objAttachment = new Attachment ();
return objAttachment;
<iframe>
<html>
<head>
<script src='https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit' /> </script>
<script type="text/javascript">
var callPostMethod = function (action, response) {
var hostURL = window.location.origin;
parent.postMessage({ action: action, response : response }, hostURL);
}
var onVerifyCallback = function () {
function searchReport(searchInputId, searchTableId)
{
var input, filter, table, tr, td, i;
input = document.getElementById(searchInputId);
filter = input.value.toUpperCase();
table = document.getElementById(searchTableId);
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {