Posts

Showing posts from April 30, 2015

Send SMS Using Batch Class in Salesforce

Que:  Integrate SMS Functionality in salesforce using batch Class Requirement: Send Sms to user if user has birthday today. Solution: Fristly Create a batch class and schedule this class every day //Note: you need to create Custom Setting for Username password sender id and etc //and also Add Url in Remote Site Setting global class ClassName implements Database.Batchable<Sobject>,Database.AllowsCallouts {     List<Contact> lstofContactBirthdate = new List<Contact>();          static CustomSettingName__c objCS = CustomSettingName__c.getOrgDefaults();// Custom setting     List<string> lstofSMSString;     //Get date and Month from Today Date      Date currentdate = system.Today();     Integer TodayDay = currentdate.Day();     Integer TodayMonth = currentdate.month();     String CurrentDayandMonth = TodayDay+'/'+TodayMonth;          global Database.Querylocator start(Database.Batchablecontext BC)     {         //  Birth_Day_and_Mon

Get All Sub-ordinate User in Role Hierarchy

Que: To Get all Sub-ordinate users in role hierarchy . Solution :  Create a Util Class: public with sharing class RoleUtils {   public static Set<ID> getRoleSubordinateUsers(Id userId) {     // get requested user's role     Id roleId = [select UserRoleId from User where Id = :userId].UserRoleId;     // get all of the roles underneath the user     Set<Id> allSubRoleIds = getAllSubRoleIds(new Set<ID>{roleId});     // get all of the ids for the users in those roles     Map<Id,User> users = new Map<Id, User>([Select Id, Name From User where        UserRoleId IN :allSubRoleIds]);     // return the ids as a set so you can do what you want with them     return users.keySet();   }   private static Set<ID> getAllSubRoleIds(Set<ID> roleIds) {     Set<ID> currentRoleIds = new Set<ID>();     // get all of the roles underneath the passed roles     for(UserRole userRole :[select Id from UserRole where ParentRoleId 

Validate Email ,Date, Mobile Field On Web To Lead Form in Salesforce

Que: Before Creating Web to Lead form Validate Email should be proper format and Date should be dd/mm/yyyy and Mobile No Should be 10 digits. Solution: Validate Web to Lead form using Javascript/Jquery <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"> <head> <script type = "text/javascript"> function check() { var emailadd = document.getElementById('email').value; //alert(emailadd);     if(emailadd!= ''  &&  emailadd != null) { var str=document.getElementById('email').value; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) { alert("Please input a valid email address!"); return false; } } var mobileVale = document.getElementById('mobile').value; //alert(mobileVale.length); if(mobileVale!='' && mobileVale!=null) {   if(mobileVale