You need to sign in to do that
Don't have an account?
Alejandro Hartoch
apex class classic to lighting
Apologies if my question my be so dumb but my programming skills are really limited and I'm on a hurry for a PoC.
I have the apex class below which was developed for Classic. I would like to make it work with lighting and I'm not sure if the only thing I need to replace are the url's. I have created a developer account for my PoC and everytime I launch the class I'm redirected to Classic.
In addition if anyone can tell where to being looking in the documentation to simply launch to new customer record form, or what are the redirect URLS?
Thanks,
Alex
I have the apex class below which was developed for Classic. I would like to make it work with lighting and I'm not sure if the only thing I need to replace are the url's. I have created a developer account for my PoC and everytime I launch the class I'm redirected to Classic.
public class LookupByUrlParamController { String accountName; String accountNumber; String phone; String website; String email; String socialhandle; public LookupByUrlParamController () { } public String redirectToAccount() { Account account; Map<String,String> params = ApexPages.currentPage().getParameters(); if(params.size() > 0) { accountName = params.get('account_name'); accountNumber = params.get('account_number'); phone = params.get('phone'); website = params.get('website'); email = params.get('email'); socialhandle = params.get('SocialHandle'); } try { if(accountName != null) { account = [select ID from Account where name = :accountName limit 1]; } } catch (System.queryException e) {//no entry found for lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } try { if(accountNumber != null) { account = [select ID from Account where AccountNumber = :accountNumber limit 1]; } } catch (System.queryException e) {//no entry found for lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } try { if(phone != null) { String npa; String nnx; String extension; // Added logic for NA phone numbers if (phone.length() == 10) { npa = phone.substring(0,3); nnx = phone.substring(3,6); extension = phone.substring(6,10); phone = '(' + npa + ') ' + nnx + '-' + extension; } account = [select ID from Account where phone = :phone limit 1]; } } catch (System.queryException e) {//no entry found for lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } try { if(website != null) { account = [select ID from Account where website = :website limit 1]; } } catch (System.queryException e) {//no entry found for lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } try { if(email != null) { account = [select ID from Account where email__c = :email limit 1]; } } catch (System.queryException e) {//no entry found for lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } try { if(socialhandle != null) { account = [select ID from Account where SocialHandle__c = :socialhandle limit 1]; } } catch (System.queryException e) {//no entry found for twitter handle lookup item, display empty account page return 'https://na7.salesforce.com/001/e'; } String accountUrl; if(account != null) { accountUrl = '/' + account.Id; } else { accountUrl = '/'; } return accountUrl; } public static testMethod void testLookupByUrlParamAccount() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.accountName = 'Avaya'; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, '/001A0000007UkkFIAS'); } public static testMethod void testLookupByUrlParamInvalidAccount() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.accountName = ''; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, 'https://na7.salesforce.com/001/e'); } public static testMethod void testLookupByUrlParamPhone() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.phone = '1234'; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, '/001A0000007UkkFIAS'); } public static testMethod void testLookupByUrlParamWherePhoneNumberIs10Chars() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.phone = '1234567891'; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, 'https://na7.salesforce.com/001/e');//no record found } public static testMethod void testLookupByUrlParamInvalidPhoneNumber() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.phone = ''; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, '/001A0000015EKVPIA4'); } public static testMethod void testLookupByUrlParamAccountNumber() { LookupByUrlParamController controller = new LookupByUrlParamController(); controller.accountNumber = '4321'; String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, '/001A0000007UkkFIAS'); } public static testMethod void testLookupByUrlParam() { LookupByUrlParamController controller = new LookupByUrlParamController(); String redirectUrl = controller.redirectToAccount(); System.assertEquals(redirectUrl, '/'); } }
In addition if anyone can tell where to being looking in the documentation to simply launch to new customer record form, or what are the redirect URLS?
Thanks,
Alex
I see that you have posted a controller. You must change your VF page primarily. New property for VF <apex:page> tag lightningStyleSheets="[false|true]" will supposedly be the single thing you need to do to convert VF pages to SLDS type styles
I recommend reviewing the following resources to make the conversion
What is suggested approach to transfer VF pages to be lightning ready
Migrating Visualforce Pages to Lightning
Develop Visualforce Pages for Lightning Experience
Let me know if it helps
thanks for the response! I will start investigating with all the information you have provided.
Regards,
Alex