Skip to content

Instantly share code, notes, and snippets.

@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 ();
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);
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;
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);
}
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");
<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}"/>
<apex:page showHeader="false" applyBodyTag="false">
<apex:includeScript value="{!$Resource.jQuery_3_1_1}"/>
<script src='{!$Setup.foolish__reCaptcha__c.foolish__libraryUrl__c}?onload=onloadCallback&render=explicit' type="application/javascript"/>
<style>
body, div{
background:transparent !important;
}
html {overflow:hidden;}
.recaptcha {
transform: scale(0.74);
var path = $A.get("$Resource.sampleScript");
var req = new XMLHttpRequest();
req.open("GET", path);
req.addEventListener("load", $A.getCallback(function() {
$A.createComponent ('aura:unescapedHTML', {value: req.response},
function(newComp, status, errorMessage ) {
if (status === 'SUCCESS') {
component.set ('v.scriptDataComp',newComp );
}
});
var lastHeight = 0, curHeight = 0, iframe = $('.recaptchaFrame');
iframe = iframe[0];
setInterval(function(){
// for lwciframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
curHeight = $frame.contents().find('body').height();
if ( curHeight != lastHeight ) {
$frame.css('height', (lastHeight = curHeight) + 'px' );
}
},500);
$.getScript( "https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" )
.done(function( script, textStatus ) {
console.log( textStatus );
})
.fail(function( jqxhr, settings, exception ) {
$( "div.log" ).text( "Triggered ajaxError handler." );
});