• Mayur Tripathi
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hi Community,

This is the first integration project I have been assigned to, the requirement from the client is to sync Paypal transactions done for their NGO through Classy to sync within Opportunites field in Salesforce, I have gone through several links and documentation but could not find very useful from scratch to end, if anyone has done similar kind of integration to show PayPal transaction data (Amount field in Salesforce) it would be very useful.
 
Hi Community,

I am bit new to VF page, can someone help me with one scenario. I have to create a vf page with 2 sections in such a way that in 1st section data related to one custom object VOIP_Settings__c should pop up with fields such as username, password, phone etc. in 2nd section i have to keep a picklist having 5 standard objects (Account, Contact, Lead, Case, Opportunity) in left side. In right side the phone data type fields should populate when changing the picklist of objects.
Attaching the screenshot and vf page code snippt which i did so far. Appreciate your help genuinely .i want this kind of page
<apex:page standardController="VOIP_Setting__c" showHeader="false" sidebar="false" standardStylesheets="true">
  <apex:form >
 <div id="col1">
  <apex:pageBlock title="User Profile Settings">
  <apex:pageBlockSection title="VOIP Settings">
  <table>
  <tr>
  <td>
  <apex:inputField value="{!VOIP_Setting__c.Name}" />
  </td>
  </tr>
  <tr>
  <td>
  <apex:inputField value="{!VOIP_Setting__c.Make_Default__c}"/>
  </td>
  </tr>
  <tr>
  <td>
  <apex:inputField value="{!VOIP_Setting__c.User_Name__c}"/>
  </td>
  </tr>
  <tr>
  <td>
<apex:inputSecret required="true" value="{!VOIP_Setting__c.Password__c}"  />
  </td>
  </tr>
      <tr>
  <td>
<apex:inputField value="{!VOIP_Setting__c.Phone_Number__c}" />
  </td>
  </tr>

  </table>
  </apex:pageBlockSection>
  </apex:pageBlock>
      </div>
      <div id="col2">
            <apex:pageblock >
                <apex:pageblockSection title="Call History Settings">
                   
                    <apex:selectList id="Entity" size="1">
                        <apex:pageBlockTable columns="2" value="{!VOIP_Setting__c.Name}" var="obj">
<apex:column headerValue="Select Entity"/>    
                            </apex:pageBlockTable>
<apex:selectoption itemLabel="Leads" itemValue="Leads"></apex:selectoption>
<apex:selectoption itemLabel="Contacts" itemValue="Contacts"></apex:selectoption>
<apex:selectoption itemLabel="Accounts" itemValue="Accounts"></apex:selectoption>
<apex:selectoption itemLabel="Opportunities" itemValue="Opportunities"></apex:selectoption>
<apex:selectoption itemLabel="Cases" itemValue="Cases"></apex:selectoption>                        
</apex:selectList>
                     <apex:pageBlockTable columns="2" value="{!VOIP_Setting__c.Name}" var="obj">
                        <apex:column headerValue="Select Default Field to view History"/>
                         
                    </apex:pageBlockTable>
                </apex:pageblockSection>
                
            </apex:pageblock>
        </div>       
      <center style="margin-top: 10%"> 
      <apex:commandButton value="Save" action="{!Save}" /> <br/>
      <apex:commandButton value="Cancel" action="{!Cancel}" /> <br/>
      </center>
  </apex:form>
</apex:page>

 
public class MemberVerificationLightningController
	{


		private static Account GetAccount(string accID)
		{
			List<Account> listAccount;

			listAccount = [select Id,OTP_Code__c,OTP_Sent_On__c, Member_Verification_OTP_Invalid_Attempt__c, FirstName, LastName, home_phone__pc, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =:accID];
			if (listAccount.size() > 0)
			{
				Account acc = listAccount[0];

				return acc;
			}
			return null;

		}


		
		private static List<KeyValuePairModel> GetPhoneList_Options(List<wrapperAccount> listWrapperAccount)
		{

			List<KeyValuePairModel> options = new List<KeyValuePairModel>();

			if (listWrapperAccount != null && listWrapperAccount.size() > 0)
			{

				for (wrapperAccount a : listWrapperAccount)
				{
					if (a.fieldType == 'P')
					{
						KeyValuePairModel pair = new KeyValuePairModel();
						pair.Text = a.fieldName;
						pair.Value = a.encryptedvalue;
						options.add(pair);
					}
				}
				system.debug('Phoneoptions-----' + options);
			}
			return options;

		}

		private static List<KeyValuePairModel> GetEmailsList_Options(List<wrapperAccount> listWrapperAccount)
		{

			List<KeyValuePairModel> options = new List<KeyValuePairModel>();
			if (listWrapperAccount != null && listWrapperAccount.size() > 0)
			{

				for (wrapperAccount a : listWrapperAccount)
				{
					if (a.fieldType == 'E')
					{
						KeyValuePairModel pair = new KeyValuePairModel();
						pair.Text = a.fieldName;
						pair.Value = a.encryptedvalue;
						options.add(pair);
					}
				}
				system.debug('Emailoptions-----' + options);

			}
			return options;

		}

		@auraenabled
		public static OTPVerificationModel ListOfEmailsAndPhoneNumbers(string accid)
		{
			system.debug('accid---' + accid);
			string Brand;
			Account acc = GetAccount(accID);
			List<string> allRelatedAccounts = GetRelatedAccountsPopulated(accid, acc);
			List<wrapperAccount> listWrapperAccount = new List<wrapperAccount>();
			system.debug('allRelatedAccounts 4---' + allRelatedAccounts);
			string IsIneligibleLocal = 'false';
			string NoContactInfo = 'false';
			List<Account> listAccount;

			if (allRelatedAccounts != null && allRelatedAccounts.size() > 0)
			{

				listAccount = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID in :allRelatedAccounts];
				listWrapperAccount = new List<wrapperAccount>();
				set<string> listContacts = new set<string>();


				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Mobile_Phone__pc != null && accountLocal.Mobile_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Mobile_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();

							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Mobile_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Mobile_Phone__pc);
							accLocal.fieldName = 'Mobile_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Mobile_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Home_Phone__pc != null && accountLocal.Home_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Home_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Home_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Home_Phone__pc);
							accLocal.fieldName = 'Home_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Home_Phone__pc);
						}

					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Work_Phone__pc != null && accountLocal.Work_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Work_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Work_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Work_Phone__pc);
							accLocal.fieldName = 'Work_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Work_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.PersonEmail != null && accountLocal.PersonEmail != '')
					{
						if (!listContacts.contains(accountLocal.PersonEmail) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.PersonEmail;
							accLocal.encryptedvalue = encryptEmail(accountLocal.PersonEmail);
							accLocal.fieldName = 'PersonEmail - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.PersonEmail);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Alternate_Email__pc != null && accountLocal.Alternate_Email__pc != '')
					{
						if (!listContacts.contains(accountLocal.Alternate_Email__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.Alternate_Email__pc;
							accLocal.encryptedvalue = encryptEmail(accountLocal.Alternate_Email__pc);
							accLocal.fieldName = 'Alternate_Email__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.Add(accountLocal.Alternate_Email__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Mobile_Phone__pc != null && accountLocal.Mobile_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Mobile_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();

							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Mobile_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Mobile_Phone__pc);
							accLocal.fieldName = 'Mobile_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Mobile_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Home_Phone__pc != null && accountLocal.Home_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Home_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Home_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Home_Phone__pc);
							accLocal.fieldName = 'Home_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Home_Phone__pc);
						}

					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Work_Phone__pc != null && accountLocal.Work_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Work_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Work_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Work_Phone__pc);
							accLocal.fieldName = 'Work_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Work_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.PersonEmail != null && accountLocal.PersonEmail != '')
					{
						if (!listContacts.contains(accountLocal.PersonEmail) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.PersonEmail;
							accLocal.encryptedvalue = encryptEmail(accountLocal.PersonEmail);
							accLocal.fieldName = 'PersonEmail - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.PersonEmail);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Alternate_Email__pc != null && accountLocal.Alternate_Email__pc != '')
					{
						if (!listContacts.contains(accountLocal.Alternate_Email__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.Alternate_Email__pc;
							accLocal.encryptedvalue = encryptEmail(accountLocal.Alternate_Email__pc);
							accLocal.fieldName = 'Alternate_Email__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.Add(accountLocal.Alternate_Email__pc);
						}
					}
				}
			}


			if (listWrapperAccount.size() == 0)
			{
				SaveNoContactInfoLog(acc);

			}
			else
			{
				list<string> accids = GetAccIdsPopulated(accID, acc);
				system.debug('accids---' + accids);
				list<Account_Details__c> listAccountDetails = [select Id, Comments_Block__c,
				   Brand__c,
					Comment_Block_01__c,
									 Comment_Block_02__c,
									 Comment_Block_03__c,
									 Comment_Block_04__c,
									 Comment_Block_05__c,
									 Comment_Block_06__c,
									 Comment_Block_07__c,
									 Comment_Block_08__c,
									 Comment_Block_09__c,
									 Comment_Block_10__c,
									 Comment_Block_11__c,
									 Comment_Block_12__c,
									 Comment_Block_13__c,
									 Comment_Block_14__c,
									 Comment_Block_15__c,
									 Comment_Block_16__c,
									 Comment_Block_17__c,
									 Comment_Block_18__c,
									 Comment_Block_19__c,
									 Comment_Block_20__c



					from Account_Details__c where Id in: accids];
				list<string> wcwList = new list<string>();
				if (listAccountDetails.Size() > 0)
				{
					Brand = listAccountDetails[0].Brand__c;


					for (Account_Details__c var: listAccountDetails)
					{

						if (var.Comment_Block_01__c != NULL || var.Comment_Block_01__c != '')
						{

							wcwList.add(var.Comment_Block_01__c);
						}
						if (var.Comment_Block_02__c != NULL || var.Comment_Block_02__c != '')
						{

							wcwList.add(var.Comment_Block_02__c);
						}
						if (var.Comment_Block_03__c != NULL || var.Comment_Block_03__c != '')
						{

							wcwList.add(var.Comment_Block_03__c);
						}
						if (var.Comment_Block_04__c != NULL || var.Comment_Block_04__c != '')
						{

							wcwList.add(var.Comment_Block_04__c);
						}
						if (var.Comment_Block_05__c != NULL || var.Comment_Block_05__c != '')
						{

							wcwList.add(var.Comment_Block_05__c);
						}
						if (var.Comment_Block_06__c != NULL || var.Comment_Block_06__c != '')
						{

							wcwList.add(var.Comment_Block_06__c);
						}
						if (var.Comment_Block_07__c != NULL || var.Comment_Block_07__c != '')
						{

							wcwList.add(var.Comment_Block_07__c);
						}
						if (var.Comment_Block_08__c != NULL || var.Comment_Block_08__c != '')
						{

							wcwList.add(var.Comment_Block_08__c);
						}
						if (var.Comment_Block_09__c != NULL || var.Comment_Block_09__c != '')
						{

							wcwList.add(var.Comment_Block_09__c);
						}
						if (var.Comment_Block_10__c != NULL || var.Comment_Block_10__c != '')
						{

							wcwList.add(var.Comment_Block_10__c);
						}
						if (var.Comment_Block_11__c != NULL || var.Comment_Block_11__c != '')
						{

							wcwList.add(var.Comment_Block_11__c);
						}
						if (var.Comment_Block_12__c != NULL || var.Comment_Block_12__c != '')
						{

							wcwList.add(var.Comment_Block_12__c);
						}
						if (var.Comment_Block_13__c != NULL || var.Comment_Block_13__c != '')
						{

							wcwList.add(var.Comment_Block_13__c);
						}
						if (var.Comment_Block_14__c != NULL || var.Comment_Block_14__c != '')
						{

							wcwList.add(var.Comment_Block_14__c);
						}
						if (var.Comment_Block_15__c != NULL || var.Comment_Block_15__c != '')
						{

							wcwList.add(var.Comment_Block_15__c);
						}
						if (var.Comment_Block_16__c != NULL || var.Comment_Block_16__c != '')
						{

							wcwList.add(var.Comment_Block_16__c);
						}
						if (var.Comment_Block_17__c != NULL || var.Comment_Block_17__c != '')
						{

							wcwList.add(var.Comment_Block_17__c);
						}
						if (var.Comment_Block_18__c != NULL || var.Comment_Block_18__c != '')
						{

							wcwList.add(var.Comment_Block_18__c);
						}
						if (var.Comment_Block_19__c != NULL || var.Comment_Block_19__c != '')
						{

							wcwList.add(var.Comment_Block_19__c);
						}
						if (var.Comment_Block_20__c != NULL || var.Comment_Block_20__c != '')
						{

							wcwList.add(var.Comment_Block_20__c);
						}
					}
					if (wcwList.size() > 0)
					{
						for (string str : wcwList)
						{
							if (str != null && str.Contains('TELEPHONE/EMAIL CHANGED WITHIN 60 DAYS'))
							{

								Authenticated_Log__c log = new Authenticated_Log__c();
								log.SalesforceID__c = acc.Id;
								log.First_Name__c = acc.FirstName;
								log.Last_Name__c = acc.LastName;
								log.Staff_Name__c = UserInfo.getName();
								log.Decision__c = 'OTP – Not Eligible';
								insert log;
								acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
								update acc;
								System.Debug('not eligible---' + acc.id);

								IsIneligibleLocal = 'true';

							}
						}
					}


				}
			}
			List<KeyValuePairModel> listPhoneList = GetPhoneList_Options(listWrapperAccount);
			List<KeyValuePairModel> listEmailList = GetEmailsList_Options(listWrapperAccount);
			OTPVerificationModel obj = new OTPVerificationModel();
			obj.IsIneligible = IsIneligibleLocal;
			obj.Brand = Brand;
			obj.PhoneList_Options = GetPhoneList_Options(listWrapperAccount);

			obj.EmailsList_Options = GetEmailsList_Options(listWrapperAccount);
			system.debug('obj---' + obj);
			return obj;
		}
		@auraenabled
		  public static void DeclineOTPAtFirstStep(string accid)
		{
			Account acc = GetAccount(accid);

			Authenticated_Log__c log = new Authenticated_Log__c();
			log.SalesforceID__c = acc.Id;

			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;

			log.Staff_Name__c = UserInfo.getName();
			log.Decision__c = 'OTP – Contact Unconfirmed';
			insert log;
			acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
			update acc;
		}
		private static void SaveNoContactInfoLog(Account acc)
		{
			Authenticated_Log__c log = new Authenticated_Log__c();
			system.debug('SalesForceID =' + acc.Id);
			log.SalesforceID__c = acc.Id;

			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;
			log.Staff_Name__c = UserInfo.getName();
			System.debug('log No Contact Info ' + log);

			upsert log;
			log.Decision__c = 'OTP - No Contact Info';
			update log;
		}
		public static string encryptPhone(string value)
		{
			value = 'xxx-xxx-' + value.right(4);

			return value;
		}
		public static string encryptEmail(string value)
		{

			List<String> listStr = value.split('@');

			string finalNumber = listStr[0].substring(0, 1) + '*****' + +listStr[0].substring(listStr[0].length() - 1, listStr[0].length()) + '@' + listStr[1];
			//= listStr[0].substring
			return finalNumber;
		}

		public class wrapperAccount
		{
			public string fieldName { get; set; }
			public string fieldType { get; set; }
			public string value { get; set; }
			public string encryptedvalue { get; set; }

		}

		public class warningCodeWrapper
		{
			public string comms { get; set; }

			public warningCodeWrapper(string var)
			{
				comms = var;
			}
		}

		@auraenabled
		public static KeyValuePairModel GenerateRandomOTP(string fieldName, string BrandName, string resend, string accid)
		 {
			List<String> listStr = fieldName.split(' - ');
			string field = listStr[0];
			string accountid = listStr[1];
			string phone = '';
			string email = '';
			boolean IsEmail = false;
			Account accEmailTOSend = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =: accountid];

			if (field == 'Home_Phone__pc')

			{
				phone = accEmailTOSend.Home_Phone__pc;

			}
			else if (field == 'Mobile_Phone__pc')
			{
				phone = accEmailTOSend.Mobile_Phone__pc;

			}
			else if (field == 'Work_Phone__pc')
			{
				phone = accEmailTOSend.Work_Phone__pc;

			}
			else if (field == 'PersonEmail')
			{
				email = accEmailTOSend.PersonEmail;
				IsEmail = true;
			}
			else if (field == 'Alternate_Email__pc')
			{
				email = accEmailTOSend.Alternate_Email__pc;
				IsEmail = true;

			}

		   string RandomNumber = String.valueOf(Math.random());
			 RandomNumber= RandomNumber.substring(2,8);
			Account acc = GetAccount(accid);
			
			if(IsEmail)
			{
						
				SendOTPEmail(RandomNumber, email, BrandName, acc);

			}
			else
			{
				SendSMS(phone, string.valueof(RandomNumber), 'SMS - User', BrandName, acc);
			}
			
			system.debug('keyvaluemodel1---');
			KeyValuePairModel keyvaluemodel = new KeyValuePairModel();
			system.debug('keyvaluemodel2---' + keyvaluemodel ); 
			keyvaluemodel.Text = EncryptString(RandomNumber);
			keyvaluemodel.Value = EncryptString(string.valueof( system.now()));
			
			system.debug('keyvaluemodel3---' + keyvaluemodel );
			 Authenticated_Log__c log = new Authenticated_Log__c();
			 log.SalesforceID__c = acc.Id;
			 log.First_Name__c = acc.FirstName;
			 log.Last_Name__c = acc.LastName;
			 log.Staff_Name__c = UserInfo.getName();
			 if(IsEmail)
			 {
			   log.OTP_Email__c = email;
			 }
			 else
			 {
				 log.OTP_Phone__c = phone;
			 }
			 if(resend == 'true')
			 {

				 log.Decision__c = 'OTP – Code Resent';
			 }
			 else
			 {
				 log.Decision__c = 'OTP – Code Sent';
			 }
		   insert log;
		   system.debug('keyvaluemodel4---' + keyvaluemodel );
			return keyvaluemodel;

		 }
		@auraenabled
		public static string verifyOTP(string accid, string EnteredOTP, string fieldName, string model)
		{
			system.debug('--verify OTP start--');
			string fieldValue = fieldName;
			List<String> listStr = fieldValue.split(' - ');
			string field = listStr[0];
			string accountid = listStr[1];
			string phone = '';
			string email = '';
			boolean IsEmail = false;
			Account accEmailTOSend = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =: accountid];
			system.debug('field - ' + field);
			
			if (field == 'Home_Phone__pc')

			{
				phone = accEmailTOSend.Home_Phone__pc;

			}
			else if (field == 'Mobile_Phone__pc')
			{
				phone = accEmailTOSend.Mobile_Phone__pc;

			}
			else if (field == 'Work_Phone__pc')
			{
				phone = accEmailTOSend.Work_Phone__pc;

			}
			else if (field == 'PersonEmail')
			{
				email = accEmailTOSend.PersonEmail;
				IsEmail = true;
			}
			else if (field == 'Alternate_Email__pc')
			{
				email = accEmailTOSend.Alternate_Email__pc;
				IsEmail = true;

			}
			system.debug('email - ' + email);
			
			OTPSettings__c data1 = OTPSettings__c.getValues('Member Verification');
			integer OTPExpiresAfterSeconds = integer.valueOf(data1.OTPExpirationSeconds__c);
			system.debug('OTPExpiresAfterSeconds - ' + OTPExpiresAfterSeconds);
			
			string Verified = '';
			system.debug('DencryptString--- Start');
			KeyValuePairModel newmodel = (KeyValuePairModel)JSON.deserialize(model, KeyValuePairModel.class);
			
			system.debug('decrypted date string - ' + DencryptString(newmodel.Value));
			Datetime LastOTPSent =  Datetime.valueOf(DencryptString(newmodel.Value));
			system.debug('DencryptString--- LastOTPSent' + LastOTPSent);
			string RandomNumber = DencryptString(newmodel.Text);
			system.debug('DencryptString--- RandomNumber' + RandomNumber);
			Account  acc =	GetAccount(accid);
			Long startTime = LastOTPSent.getTime();
			Long endTime = System.Now().getTime();
			Long milliseconds = endTime - startTime;
			Long seconds = milliseconds / 1000;
			Authenticated_Log__c log = new Authenticated_Log__c();
			log.SalesforceID__c = acc.Id;
			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;
			if(IsEmail)
			{
			  log.OTP_Email__c = email;
			}
			else
			{
				log.OTP_Phone__c = phone;
			}
			log.Staff_Name__c = UserInfo.getName();
			system.debug('seconds ---' + seconds);
			system.debug('OTPExpiresAfterSeconds ---' + OTPExpiresAfterSeconds);
			if(seconds >= OTPExpiresAfterSeconds)
			{
				Verified = 'Expired';
				acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
				update acc;
				log.Decision__c = 'OTP – Code Expired';
			
			}
			else if(EnteredOTP == RandomNumber)
			{
				//acc.Member_Verification_OTP_Invalid_Attempt__c = null;
				//update acc;
				log.Decision__c = 'OTP – Code valid';
				Verified = 'Valid';
			}
			else
			{
				acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
				update acc;
				log.Decision__c = 'OTP – Code Failed';
				Verified = 'Invalid';
			}
			insert log;
			return Verified;
			
		}

		
	}

 
Class:
public class CollectionsInLightningCls 
{
    @AuraEnabled
    public static Map<String, Map<String, List<String>>> getPicklistValues(String objpicklistFieldsMap)
    {
        Map<String, List<String>> objPickmap = (Map<String, List<String>>)JSON.deserialize(objpicklistFieldsMap, Map<String, List<String>>.class);
        system.debug('objpickmap ' + objPickmap);
         
        Map<String, Map<String, List<String>>> objFieldPicklistMap = new Map<String, Map<String, List<String>>>();
        List<String> sobjectslist = new List<String>(objPickmap.keySet());
        Schema.DescribeSobjectResult[] results = Schema.describeSObjects(sobjectslist);
        Map<String, List<String>> fieldOptionsMap;
        system.debug('results---' + results);
        for(Schema.DescribeSObjectResult result : results)
        {
            fieldOptionsMap = new Map<String, List<String>>();
             system.debug('result123---' + result);
            Schema.sObjectType objType = result.getSObjectType();
             
            Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
            map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
            List<String> objFieldlist = objPickmap.get(result.getName());
            system.debug('objname ' + result.getName());
            system.debug('list of fields ' + objFieldlist);
            for(String fld : objFieldlist)
            {
                system.debug('fields ' + fld);
                List<String > allOpts = new list<String>();
                list<Schema.PicklistEntry> values =
                fieldMap.get(fld).getDescribe().getPickListValues();
                 
                for (Schema.PicklistEntry a : values)
                {
                    allOpts.add(a.getValue());
                }
                fieldOptionsMap.put(fld, allOpts);
            }
            
            objFieldPicklistMap.put(result.getName(), fieldOptionsMap);
        }
        return objFieldPicklistMap;
    }
    
    @AuraEnabled
    public static list<NA_Other_Existing_Loans__c> getExistingLoans(String AssessmentId)
    {
        list<NA_Other_Existing_Loans__c> otherExistingLoans = new list<NA_Other_Existing_Loans__c>();
        otherExistingLoans = [select id, Balance__c, End_Date__c, Financial_Institution__c, Needs_Assessment__c, Rate__c, Type_of_Loan__c 
                        from NA_Other_Existing_Loans__c where Needs_Assessment__c =: AssessmentId];
                        
        return otherExistingLoans;        
    }
    
    @AuraEnabled
    public static list<NA_Membership_Referral_Questions__c> getMembershipLoans(String AssessmentId)
    {
        list<NA_Membership_Referral_Questions__c> loans = new list<NA_Membership_Referral_Questions__c>();
        loans = [select id, Age__c, Name__c, Needs_Assessment__c, Want_to_Refer_Membership__c 
                        from NA_Membership_Referral_Questions__c where Needs_Assessment__c =: AssessmentId];
                        
        return loans;        
    }
    
    @AuraEnabled
    public static list<NA_Deposit__c> GetDepositData(String AssessmentId)
    {
        list<NA_Deposit__c> deposits = new list<NA_Deposit__c>();
        deposits = [select id, Balance__c, Financial_Instituition__c, Needs_Assessment__c, Rate__c, Type__c 
                        from NA_Deposit__c where Needs_Assessment__c =: AssessmentId];
                        
        return deposits;        
    }
    
    
    @AuraEnabled    
    public static Map<String, List<KeyValuePairModelInt>> getYearPickList()
    {   
        Map<String, List<KeyValuePairModelInt>> options = new Map<String, List<KeyValuePairModelInt>>();
        KeyValuePairModelInt pair = new KeyValuePairModelInt();
        List<KeyValuePairModelInt> lstPair = new List<KeyValuePairModelInt>();
        pair.Text = '--None--';
        pair.Value = 0;
                
        lstPair.add(pair);
        
        for (Integer i = System.Today().year() + 1; i < System.Today().year() + 31; i++) 
        {
            pair = new KeyValuePairModelInt();
            pair.Text = string.valueof(i);
            pair.Value = i;
            lstPair.add(pair);            
        }
        options.put('data', lstPair);
        return options;        
    }
    
        
    public class KeyValuePairModelInt
    {
        @AuraEnabled    
        public string Text {get;set;}
        @AuraEnabled    
        public Integer Value {get;set;}
        
    } 
}

============================
Test Class:
@isTest

private class CollectionsInLightningClsTest
{
    
    static void SetUp(){
        test.StartTest();
    }

    static void TearDown(){
        test.StopTest();
    }
    
    // Test Method: getPicklistValues
    public static testmethod void Test_getPicklistValues(){
        SetUp();
        string objpicklistfieldsmap = '';
        // TODO : Change following Assert Statement
        Needs_Assesment__c NC;
        NC = new Needs_Assesment__c();
        
        NC.Home_Improvement__c = 'Prefer Not to Answer';
        NC.Home_Improvement_Timeframe__c='3-6 months';
        NC.Home_Improvement_Plan__c= 'Finance';
        NC.College__c= 'Yes';
        NC.College_Timeframe__c= '3-6 months';
        NC.College_Plan__c='Both';
        NC.Medical__c='Prefer Not to Answer';
        NC.Medical_Timeframe__c='3-6 months';
        NC.Medical_Plan__c='Both';
        NC.Purchase_RV_Boat__c='Yes';
        NC.Purchase_RV_Boat_Timeframe__c='3-6 months';
        NC.Purchase_RV_Boat_Plan__c='Savings';
        NC.Retirement_New__c='Yes';
        NC.Retirement_Timeframe__c='3-6 months';
        NC.Retirement_Plan__c='Savings';
        NC.Travel__c= 'Yes';
        NC.Travel_Timeframe__c='3-6 months';
        NC.Travel_Plan__c='Savings';
        NC.Life_Events__c='Prefer Not to Answer';
        NC.Life_Events_Timeframe__c='3-6 months';
        NC.Life_Events_Plan__c='Finance';
        NC.Other__c='Yes';
        NC.Other_Timeframe__c='3-6 months';
        NC.Other_Plan__c= 'Savings';   
        insert NC;
        
        System.Assert(CollectionsInLightningCls.getPicklistValues(objpicklistfieldsmap) != null);
        TearDown();
    }
    // Test Method: getExistingLoans
    public static testmethod void Test_getExistingLoans(){
        SetUp();
        string assessmentid = '';
        // TODO : Change following Assert Statement
        System.Assert(CollectionsInLightningCls.getExistingLoans(assessmentid) != null);
        TearDown();
    }
    // Test Method: getMembershipLoans
    public static testmethod void Test_getMembershipLoans(){
        SetUp();
        string assessmentid = '';
        // TODO : Change following Assert Statement
        System.Assert(CollectionsInLightningCls.getMembershipLoans(assessmentid) != null);
        TearDown();
    }
    // Test Method: GetDepositData
    public static testmethod void Test_GetDepositData(){
        SetUp();
        string assessmentid = '';
        // TODO : Change following Assert Statement
        System.Assert(CollectionsInLightningCls.GetDepositData(assessmentid) != null);
        TearDown();
    }
    // Test Method: getYearPickList
    public static testmethod void Test_getYearPickList(){
        SetUp();
        // TODO : Change following Assert Statement
        System.Assert(CollectionsInLightningCls.getYearPickList() != null);
        TearDown();
    }
}
trigger DedupeReminder on Account (after update) {
    for (Account acc: Trigger.New){
        Case c      = New Case();
        c.subject   ='Dedupe this Account';
        c.OwnerId   = '0057F000000tnLj';
        c.AccountId = acc.Id;
        insert c;
    }
}
trigger CaseClosedLog on Case (before insert, before update,after update) {
    
    
    
    
    if(Trigger.IsBefore)
{
    
        List<Ownership_Log__c> OwnershipLst = new List<Ownership_Log__c>();        
                
                boolean isUpdateCase = false;
        
            for(Case c : Trigger.New){
                
                system.debug(c.Owner.Name);
                if(Trigger.IsUpdate)
                {
                    
                    Case oldc = Trigger.oldMap.get( c.id );
                    
                    
                    
                    Case caseOwner  =  [select Owner.Name from  Case where Id =: c.id limit 1];
                    
                    
                    if(oldc.Status == 'Closed' && oldc.Status != c.status ){
                        List<Ownership_Log__c> listOwnershiplogs  =  [select Id,Sequence__c,End__c,Owner__c from  Ownership_Log__c 
                                where Sequence__c =: c.Ownership_Sequence__c  and Case__c =: c.id limit 1];
                        
                        if(caseOwner.Owner.Name !=  listOwnershiplogs[0].Owner__c)
                        {
                            Ownership_Log__c ownership = new Ownership_Log__c();
                         ownership.Case__c = c.id;
                         ownership.Owner__c = caseOwner.Owner.Name;
                         
                         ownership.Sequence__c = c.Ownership_Sequence__c + 1;        
                         ownership.Start__c    = system.now();
                         ownership.Type__c    = 'Owner Change';
                         OwnershipLst.add(ownership);
                        
                             insert ownership;
                        
                         
                         c.Ownership_Sequence__c = c.Ownership_Sequence__c + 1;
                         
                        }
                        
                    }
                    
                    if( oldc.OwnerId != c.OwnerId && c.status <> 'Closed')
                    {
                        
                        List<Ownership_Log__c> listOwnershiplogs  =  [select Id,Sequence__c,End__c from  Ownership_Log__c where Sequence__c =: c.Ownership_Sequence__c  and Case__c =: c.id limit 1];
                            
                            if(listOwnershiplogs[0].End__c == null)
                            {
                                 listOwnershiplogs[0].End__c = system.now();
                                 system.debug('listOwnershiplogs---' + listOwnershiplogs[0]);
                                  update listOwnershiplogs[0];
                            }                 
                        
                         Ownership_Log__c ownership = new Ownership_Log__c();
                         ownership.Case__c = c.id;
                         ownership.Owner__c = caseOwner.Owner.Name;
                         
                         ownership.Sequence__c = c.Ownership_Sequence__c + 1;        
                         ownership.Start__c    = system.now();
                         ownership.Type__c    = 'Owner Change';
                         OwnershipLst.add(ownership);
                         
                         insert ownership;
                         
                         
                        
                       
                     
                         c.Ownership_Sequence__c = c.Ownership_Sequence__c + 1;
                     
                         
                        
                         
                         
                         
                         system.debug('OwnershipLst---' + OwnershipLst);
                    }
                    system.debug('Trigger333---' + c);
                    if(c.Status == 'Closed')
                    {
                        
                         
                         if(OwnershipLst.size() > 1)
                         {
                             OwnershipLst[0].End__c = system.now();
                              update OwnershipLst[0];
                         }
                         else
                         {
                             
                             
                                     List<Ownership_Log__c> listOwnershiplogs  =  [select Id,Sequence__c,End__c from  Ownership_Log__c where Sequence__c =: c.Ownership_Sequence__c and Case__c =: c.id limit 1];
                                 if(listOwnershiplogs[0].End__c == null){
                                     listOwnershiplogs[0].End__c = system.now();
                                      update listOwnershiplogs[0];
                                 }
                             
                         }
                         isUpdateCase = true;
                         
                          
                    } 
                }
                if(Trigger.IsInsert )
                {
                    Case caseOwner  =  [select Owner.Name from  Case where Id =: c.id limit 1];
                     Ownership_Log__c ownership = new Ownership_Log__c();
                     ownership.Case__c = c.id;
                     ownership.Owner__c = caseOwner.Owner.Name;
                     ownership.Sequence__c = 1;        
                     ownership.Start__c    =  system.now();
                     ownership.Type__c    = 'Owner Change';
                     
                         c.Ownership_Sequence__c = 1;
            
                    update ownership;
            
                         
                    if(c.Status == 'Closed'){
                    
                        
                         if(OwnershipLst.size() > 1)
                         {
                             OwnershipLst[0].End__c = system.now();
                         }
                         
                         c.Ownership_Sequence__c = c.Ownership_Sequence__c + 1;
                         
                         
                            
                        
                    }
                }
                
                
            
            
            }
        
    }
    
    
        
    if(Trigger.IsAfter)
    {
        for(Case c : Trigger.New){
            Case caseOwner  =  [select Owner.Name from  Case where Id =: c.id limit 1];
            if(c.Status != 'Closed')
            {
                List<Ownership_Log__c> listOwnershiplogs  =  [select Id,Sequence__c,End__c,Owner__C from  Ownership_Log__c where Sequence__c =: c.Ownership_Sequence__c  and Case__c =: c.id limit 1];
                listOwnershiplogs[0].Owner__C = caseOwner.Owner.Name;
                Update listOwnershiplogs;
                
            }
        }
    }        
     
}


This is urgent 
public class MemberVerificationLightningController
	{


		private static Account GetAccount(string accID)
		{
			List<Account> listAccount;

			listAccount = [select Id,OTP_Code__c,OTP_Sent_On__c, Member_Verification_OTP_Invalid_Attempt__c, FirstName, LastName, home_phone__pc, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =:accID];
			if (listAccount.size() > 0)
			{
				Account acc = listAccount[0];

				return acc;
			}
			return null;

		}


		
		private static List<KeyValuePairModel> GetPhoneList_Options(List<wrapperAccount> listWrapperAccount)
		{

			List<KeyValuePairModel> options = new List<KeyValuePairModel>();

			if (listWrapperAccount != null && listWrapperAccount.size() > 0)
			{

				for (wrapperAccount a : listWrapperAccount)
				{
					if (a.fieldType == 'P')
					{
						KeyValuePairModel pair = new KeyValuePairModel();
						pair.Text = a.fieldName;
						pair.Value = a.encryptedvalue;
						options.add(pair);
					}
				}
				system.debug('Phoneoptions-----' + options);
			}
			return options;

		}

		private static List<KeyValuePairModel> GetEmailsList_Options(List<wrapperAccount> listWrapperAccount)
		{

			List<KeyValuePairModel> options = new List<KeyValuePairModel>();
			if (listWrapperAccount != null && listWrapperAccount.size() > 0)
			{

				for (wrapperAccount a : listWrapperAccount)
				{
					if (a.fieldType == 'E')
					{
						KeyValuePairModel pair = new KeyValuePairModel();
						pair.Text = a.fieldName;
						pair.Value = a.encryptedvalue;
						options.add(pair);
					}
				}
				system.debug('Emailoptions-----' + options);

			}
			return options;

		}

		@auraenabled
		public static OTPVerificationModel ListOfEmailsAndPhoneNumbers(string accid)
		{
			system.debug('accid---' + accid);
			string Brand;
			Account acc = GetAccount(accID);
			List<string> allRelatedAccounts = GetRelatedAccountsPopulated(accid, acc);
			List<wrapperAccount> listWrapperAccount = new List<wrapperAccount>();
			system.debug('allRelatedAccounts 4---' + allRelatedAccounts);
			string IsIneligibleLocal = 'false';
			string NoContactInfo = 'false';
			List<Account> listAccount;

			if (allRelatedAccounts != null && allRelatedAccounts.size() > 0)
			{

				listAccount = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID in :allRelatedAccounts];
				listWrapperAccount = new List<wrapperAccount>();
				set<string> listContacts = new set<string>();


				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Mobile_Phone__pc != null && accountLocal.Mobile_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Mobile_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();

							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Mobile_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Mobile_Phone__pc);
							accLocal.fieldName = 'Mobile_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Mobile_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Home_Phone__pc != null && accountLocal.Home_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Home_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Home_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Home_Phone__pc);
							accLocal.fieldName = 'Home_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Home_Phone__pc);
						}

					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Work_Phone__pc != null && accountLocal.Work_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Work_Phone__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Work_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Work_Phone__pc);
							accLocal.fieldName = 'Work_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Work_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.PersonEmail != null && accountLocal.PersonEmail != '')
					{
						if (!listContacts.contains(accountLocal.PersonEmail) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.PersonEmail;
							accLocal.encryptedvalue = encryptEmail(accountLocal.PersonEmail);
							accLocal.fieldName = 'PersonEmail - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.PersonEmail);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Alternate_Email__pc != null && accountLocal.Alternate_Email__pc != '')
					{
						if (!listContacts.contains(accountLocal.Alternate_Email__pc) && accountLocal.id == acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.Alternate_Email__pc;
							accLocal.encryptedvalue = encryptEmail(accountLocal.Alternate_Email__pc);
							accLocal.fieldName = 'Alternate_Email__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.Add(accountLocal.Alternate_Email__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Mobile_Phone__pc != null && accountLocal.Mobile_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Mobile_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();

							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Mobile_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Mobile_Phone__pc);
							accLocal.fieldName = 'Mobile_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Mobile_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Home_Phone__pc != null && accountLocal.Home_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Home_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Home_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Home_Phone__pc);
							accLocal.fieldName = 'Home_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Home_Phone__pc);
						}

					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Work_Phone__pc != null && accountLocal.Work_Phone__pc != '')
					{
						if (!listContacts.contains(accountLocal.Work_Phone__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'P';
							accLocal.value = accountLocal.Work_Phone__pc;
							accLocal.encryptedvalue = encryptPhone(accountLocal.Work_Phone__pc);
							accLocal.fieldName = 'Work_Phone__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.Work_Phone__pc);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.PersonEmail != null && accountLocal.PersonEmail != '')
					{
						if (!listContacts.contains(accountLocal.PersonEmail) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.PersonEmail;
							accLocal.encryptedvalue = encryptEmail(accountLocal.PersonEmail);
							accLocal.fieldName = 'PersonEmail - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.add(accountLocal.PersonEmail);
						}
					}
				}
				for (Account accountLocal : listAccount)
				{
					if (accountLocal.Alternate_Email__pc != null && accountLocal.Alternate_Email__pc != '')
					{
						if (!listContacts.contains(accountLocal.Alternate_Email__pc) && accountLocal.id != acc.id)
						{
							wrapperAccount accLocal = new wrapperAccount();
							accLocal.fieldType = 'E';
							accLocal.value = accountLocal.Alternate_Email__pc;
							accLocal.encryptedvalue = encryptEmail(accountLocal.Alternate_Email__pc);
							accLocal.fieldName = 'Alternate_Email__pc - ' + accountLocal.Id;
							listWrapperAccount.Add(accLocal);
							listContacts.Add(accountLocal.Alternate_Email__pc);
						}
					}
				}
			}


			if (listWrapperAccount.size() == 0)
			{
				SaveNoContactInfoLog(acc);

			}
			else
			{
				list<string> accids = GetAccIdsPopulated(accID, acc);
				system.debug('accids---' + accids);
				list<Account_Details__c> listAccountDetails = [select Id, Comments_Block__c,
				   Brand__c,
					Comment_Block_01__c,
									 Comment_Block_02__c,
									 Comment_Block_03__c,
									 Comment_Block_04__c,
									 Comment_Block_05__c,
									 Comment_Block_06__c,
									 Comment_Block_07__c,
									 Comment_Block_08__c,
									 Comment_Block_09__c,
									 Comment_Block_10__c,
									 Comment_Block_11__c,
									 Comment_Block_12__c,
									 Comment_Block_13__c,
									 Comment_Block_14__c,
									 Comment_Block_15__c,
									 Comment_Block_16__c,
									 Comment_Block_17__c,
									 Comment_Block_18__c,
									 Comment_Block_19__c,
									 Comment_Block_20__c



					from Account_Details__c where Id in: accids];
				list<string> wcwList = new list<string>();
				if (listAccountDetails.Size() > 0)
				{
					Brand = listAccountDetails[0].Brand__c;


					for (Account_Details__c var: listAccountDetails)
					{

						if (var.Comment_Block_01__c != NULL || var.Comment_Block_01__c != '')
						{

							wcwList.add(var.Comment_Block_01__c);
						}
						if (var.Comment_Block_02__c != NULL || var.Comment_Block_02__c != '')
						{

							wcwList.add(var.Comment_Block_02__c);
						}
						if (var.Comment_Block_03__c != NULL || var.Comment_Block_03__c != '')
						{

							wcwList.add(var.Comment_Block_03__c);
						}
						if (var.Comment_Block_04__c != NULL || var.Comment_Block_04__c != '')
						{

							wcwList.add(var.Comment_Block_04__c);
						}
						if (var.Comment_Block_05__c != NULL || var.Comment_Block_05__c != '')
						{

							wcwList.add(var.Comment_Block_05__c);
						}
						if (var.Comment_Block_06__c != NULL || var.Comment_Block_06__c != '')
						{

							wcwList.add(var.Comment_Block_06__c);
						}
						if (var.Comment_Block_07__c != NULL || var.Comment_Block_07__c != '')
						{

							wcwList.add(var.Comment_Block_07__c);
						}
						if (var.Comment_Block_08__c != NULL || var.Comment_Block_08__c != '')
						{

							wcwList.add(var.Comment_Block_08__c);
						}
						if (var.Comment_Block_09__c != NULL || var.Comment_Block_09__c != '')
						{

							wcwList.add(var.Comment_Block_09__c);
						}
						if (var.Comment_Block_10__c != NULL || var.Comment_Block_10__c != '')
						{

							wcwList.add(var.Comment_Block_10__c);
						}
						if (var.Comment_Block_11__c != NULL || var.Comment_Block_11__c != '')
						{

							wcwList.add(var.Comment_Block_11__c);
						}
						if (var.Comment_Block_12__c != NULL || var.Comment_Block_12__c != '')
						{

							wcwList.add(var.Comment_Block_12__c);
						}
						if (var.Comment_Block_13__c != NULL || var.Comment_Block_13__c != '')
						{

							wcwList.add(var.Comment_Block_13__c);
						}
						if (var.Comment_Block_14__c != NULL || var.Comment_Block_14__c != '')
						{

							wcwList.add(var.Comment_Block_14__c);
						}
						if (var.Comment_Block_15__c != NULL || var.Comment_Block_15__c != '')
						{

							wcwList.add(var.Comment_Block_15__c);
						}
						if (var.Comment_Block_16__c != NULL || var.Comment_Block_16__c != '')
						{

							wcwList.add(var.Comment_Block_16__c);
						}
						if (var.Comment_Block_17__c != NULL || var.Comment_Block_17__c != '')
						{

							wcwList.add(var.Comment_Block_17__c);
						}
						if (var.Comment_Block_18__c != NULL || var.Comment_Block_18__c != '')
						{

							wcwList.add(var.Comment_Block_18__c);
						}
						if (var.Comment_Block_19__c != NULL || var.Comment_Block_19__c != '')
						{

							wcwList.add(var.Comment_Block_19__c);
						}
						if (var.Comment_Block_20__c != NULL || var.Comment_Block_20__c != '')
						{

							wcwList.add(var.Comment_Block_20__c);
						}
					}
					if (wcwList.size() > 0)
					{
						for (string str : wcwList)
						{
							if (str != null && str.Contains('TELEPHONE/EMAIL CHANGED WITHIN 60 DAYS'))
							{

								Authenticated_Log__c log = new Authenticated_Log__c();
								log.SalesforceID__c = acc.Id;
								log.First_Name__c = acc.FirstName;
								log.Last_Name__c = acc.LastName;
								log.Staff_Name__c = UserInfo.getName();
								log.Decision__c = 'OTP – Not Eligible';
								insert log;
								acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
								update acc;
								System.Debug('not eligible---' + acc.id);

								IsIneligibleLocal = 'true';

							}
						}
					}


				}
			}
			List<KeyValuePairModel> listPhoneList = GetPhoneList_Options(listWrapperAccount);
			List<KeyValuePairModel> listEmailList = GetEmailsList_Options(listWrapperAccount);
			OTPVerificationModel obj = new OTPVerificationModel();
			obj.IsIneligible = IsIneligibleLocal;
			obj.Brand = Brand;
			obj.PhoneList_Options = GetPhoneList_Options(listWrapperAccount);

			obj.EmailsList_Options = GetEmailsList_Options(listWrapperAccount);
			system.debug('obj---' + obj);
			return obj;
		}
		@auraenabled
		  public static void DeclineOTPAtFirstStep(string accid)
		{
			Account acc = GetAccount(accid);

			Authenticated_Log__c log = new Authenticated_Log__c();
			log.SalesforceID__c = acc.Id;

			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;

			log.Staff_Name__c = UserInfo.getName();
			log.Decision__c = 'OTP – Contact Unconfirmed';
			insert log;
			acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
			update acc;
		}
		private static void SaveNoContactInfoLog(Account acc)
		{
			Authenticated_Log__c log = new Authenticated_Log__c();
			system.debug('SalesForceID =' + acc.Id);
			log.SalesforceID__c = acc.Id;

			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;
			log.Staff_Name__c = UserInfo.getName();
			System.debug('log No Contact Info ' + log);

			upsert log;
			log.Decision__c = 'OTP - No Contact Info';
			update log;
		}
		public static string encryptPhone(string value)
		{
			value = 'xxx-xxx-' + value.right(4);

			return value;
		}
		public static string encryptEmail(string value)
		{

			List<String> listStr = value.split('@');

			string finalNumber = listStr[0].substring(0, 1) + '*****' + +listStr[0].substring(listStr[0].length() - 1, listStr[0].length()) + '@' + listStr[1];
			//= listStr[0].substring
			return finalNumber;
		}

		public class wrapperAccount
		{
			public string fieldName { get; set; }
			public string fieldType { get; set; }
			public string value { get; set; }
			public string encryptedvalue { get; set; }

		}

		public class warningCodeWrapper
		{
			public string comms { get; set; }

			public warningCodeWrapper(string var)
			{
				comms = var;
			}
		}

		@auraenabled
		public static KeyValuePairModel GenerateRandomOTP(string fieldName, string BrandName, string resend, string accid)
		 {
			List<String> listStr = fieldName.split(' - ');
			string field = listStr[0];
			string accountid = listStr[1];
			string phone = '';
			string email = '';
			boolean IsEmail = false;
			Account accEmailTOSend = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =: accountid];

			if (field == 'Home_Phone__pc')

			{
				phone = accEmailTOSend.Home_Phone__pc;

			}
			else if (field == 'Mobile_Phone__pc')
			{
				phone = accEmailTOSend.Mobile_Phone__pc;

			}
			else if (field == 'Work_Phone__pc')
			{
				phone = accEmailTOSend.Work_Phone__pc;

			}
			else if (field == 'PersonEmail')
			{
				email = accEmailTOSend.PersonEmail;
				IsEmail = true;
			}
			else if (field == 'Alternate_Email__pc')
			{
				email = accEmailTOSend.Alternate_Email__pc;
				IsEmail = true;

			}

		   string RandomNumber = String.valueOf(Math.random());
			 RandomNumber= RandomNumber.substring(2,8);
			Account acc = GetAccount(accid);
			
			if(IsEmail)
			{
						
				SendOTPEmail(RandomNumber, email, BrandName, acc);

			}
			else
			{
				SendSMS(phone, string.valueof(RandomNumber), 'SMS - User', BrandName, acc);
			}
			
			system.debug('keyvaluemodel1---');
			KeyValuePairModel keyvaluemodel = new KeyValuePairModel();
			system.debug('keyvaluemodel2---' + keyvaluemodel ); 
			keyvaluemodel.Text = EncryptString(RandomNumber);
			keyvaluemodel.Value = EncryptString(string.valueof( system.now()));
			
			system.debug('keyvaluemodel3---' + keyvaluemodel );
			 Authenticated_Log__c log = new Authenticated_Log__c();
			 log.SalesforceID__c = acc.Id;
			 log.First_Name__c = acc.FirstName;
			 log.Last_Name__c = acc.LastName;
			 log.Staff_Name__c = UserInfo.getName();
			 if(IsEmail)
			 {
			   log.OTP_Email__c = email;
			 }
			 else
			 {
				 log.OTP_Phone__c = phone;
			 }
			 if(resend == 'true')
			 {

				 log.Decision__c = 'OTP – Code Resent';
			 }
			 else
			 {
				 log.Decision__c = 'OTP – Code Sent';
			 }
		   insert log;
		   system.debug('keyvaluemodel4---' + keyvaluemodel );
			return keyvaluemodel;

		 }
		@auraenabled
		public static string verifyOTP(string accid, string EnteredOTP, string fieldName, string model)
		{
			system.debug('--verify OTP start--');
			string fieldValue = fieldName;
			List<String> listStr = fieldValue.split(' - ');
			string field = listStr[0];
			string accountid = listStr[1];
			string phone = '';
			string email = '';
			boolean IsEmail = false;
			Account accEmailTOSend = [select Id, Member_Verification_OTP_Invalid_Attempt__c, Home_Phone__pc, FirstName, LastName, Mobile_Phone__pc, Work_Phone__pc, PersonEmail, Alternate_Email__pc from Account where ID =: accountid];
			system.debug('field - ' + field);
			
			if (field == 'Home_Phone__pc')

			{
				phone = accEmailTOSend.Home_Phone__pc;

			}
			else if (field == 'Mobile_Phone__pc')
			{
				phone = accEmailTOSend.Mobile_Phone__pc;

			}
			else if (field == 'Work_Phone__pc')
			{
				phone = accEmailTOSend.Work_Phone__pc;

			}
			else if (field == 'PersonEmail')
			{
				email = accEmailTOSend.PersonEmail;
				IsEmail = true;
			}
			else if (field == 'Alternate_Email__pc')
			{
				email = accEmailTOSend.Alternate_Email__pc;
				IsEmail = true;

			}
			system.debug('email - ' + email);
			
			OTPSettings__c data1 = OTPSettings__c.getValues('Member Verification');
			integer OTPExpiresAfterSeconds = integer.valueOf(data1.OTPExpirationSeconds__c);
			system.debug('OTPExpiresAfterSeconds - ' + OTPExpiresAfterSeconds);
			
			string Verified = '';
			system.debug('DencryptString--- Start');
			KeyValuePairModel newmodel = (KeyValuePairModel)JSON.deserialize(model, KeyValuePairModel.class);
			
			system.debug('decrypted date string - ' + DencryptString(newmodel.Value));
			Datetime LastOTPSent =  Datetime.valueOf(DencryptString(newmodel.Value));
			system.debug('DencryptString--- LastOTPSent' + LastOTPSent);
			string RandomNumber = DencryptString(newmodel.Text);
			system.debug('DencryptString--- RandomNumber' + RandomNumber);
			Account  acc =	GetAccount(accid);
			Long startTime = LastOTPSent.getTime();
			Long endTime = System.Now().getTime();
			Long milliseconds = endTime - startTime;
			Long seconds = milliseconds / 1000;
			Authenticated_Log__c log = new Authenticated_Log__c();
			log.SalesforceID__c = acc.Id;
			log.First_Name__c = acc.FirstName;
			log.Last_Name__c = acc.LastName;
			if(IsEmail)
			{
			  log.OTP_Email__c = email;
			}
			else
			{
				log.OTP_Phone__c = phone;
			}
			log.Staff_Name__c = UserInfo.getName();
			system.debug('seconds ---' + seconds);
			system.debug('OTPExpiresAfterSeconds ---' + OTPExpiresAfterSeconds);
			if(seconds >= OTPExpiresAfterSeconds)
			{
				Verified = 'Expired';
				acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
				update acc;
				log.Decision__c = 'OTP – Code Expired';
			
			}
			else if(EnteredOTP == RandomNumber)
			{
				//acc.Member_Verification_OTP_Invalid_Attempt__c = null;
				//update acc;
				log.Decision__c = 'OTP – Code valid';
				Verified = 'Valid';
			}
			else
			{
				acc.Member_Verification_OTP_Invalid_Attempt__c = system.now();
				update acc;
				log.Decision__c = 'OTP – Code Failed';
				Verified = 'Invalid';
			}
			insert log;
			return Verified;
			
		}

		
	}

 
trigger DedupeReminder on Account (after update) {
    for (Account acc: Trigger.New){
        Case c      = New Case();
        c.subject   ='Dedupe this Account';
        c.OwnerId   = '0057F000000tnLj';
        c.AccountId = acc.Id;
        insert c;
    }
}
 We are a charitable organization based in India and are looking for part time sales force administrators in managing our salesforce database. Let me know if anyone is interested.
Please contact me on sujal@ihrf.com and can explain the role. It's a part time role and can work from home.We are charitable organzation in Rishikesh.
Thanks,
Hello All,
I am stuck in below trailhead chanllange. Please help me.

Using the Contact standard controller, create a Visualforce page which displays a Contact's First Name, Last Name and the Email address of the Contact's Owner.The page must be named 'ContactView'.
It must reference the Contact standard controller.
It should include a bound variable that uses the standard controller to display the first name of the Contact.
It should include a bound variable that uses the standard controller to display the last name of the Contact.
It should include a bound variable that uses the standard controller to display the Contact Owner's email.

I am getting below error..
Challenge not yet complete... here's what's wrong:
The page does not include a bound first name variable for the Contact record
Please refer below screenshot for vf code.
User-added image
We have created visualforce page which will look like phone dial pad.
On text box we will fillup some phone number, and clicking on dial we need to show in softphone that who is calling.
We are just able to popup the softphone window from Dial button on visual force page, but not able to show details of caller.
Please help us how to proceed.

User-added image
  • April 14, 2015
  • Like
  • 0