• Developer
  • NEWBIE
  • 245 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 48
    Replies
i covered 62%  help me


public class mySecondController {
    Account account;

    public Account getAccount() {
        if(account == null) account = new Account();
        return account;
    }

    public PageReference save() {
        // Add the account to the database. 
        insert account;
        // Send the user to the detail page for the new account.
        PageReference acctPage = new ApexPages.StandardController(account).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}
=======================
@isTest
private class mySecondController_Test{
  static testMethod void test_getAccount_UseCase1(){
    mySecondController obj01 = new mySecondController();
    obj01.getAccount();
  }
  static testMethod void test_save_UseCase1(){
    mySecondController obj01 = new mySecondController();
    obj01.save();
  }
}


Thanks in Advance

 
  • October 10, 2017
  • Like
  • 0
Hello dear collages, I wan to know if someone can help me to create a test class for this apex code:

public class SP_AS
{
    @AuraEnabled
    public String recentMonthEndDate;
 
    Class HistoricalData{
        @AuraEnabled
        public String asOfDate;
       
        @AuraEnabled
        public Decimal marketValue;
    }
   
    public Class ClientAccountSummary{
        @AuraEnabled
        public String clientAccountName;
       
        @AuraEnabled
        public Decimal marketValue;
       
   }
   
}

I'm very new in salesforce and I don't have idea about how to do this. Thanks in advance.
 
1. At asset creation, it should take the following value: product.pen ++ "_" ++ Account.Name (truncated to max 80 characters) ++ "_" ++ Creation Date
2.This is a standard field and should be read-only.

Could you please help me with this 

There can only be one active record of the Opportunity associated to the Account, 
please write on trigger.
public with Sharing Class test 
{
    @AuraEnabled
    public static List<Id> testmethod(String testmethod1)
    {
        List<Id> testmethodIds = new List<Id>();
        for(ILine_Item__c iLineItemReg : [SELECT Id, class__c
                                                                FROM ILine_Item__c
                                                                WHERE Inspection_Line_Item__c = :testmethod1])
        {
         testmethodIds.add(iLineItemReg.class__c);
        }
        return testmethodIds;
    }
}

 
 I want Salesforce Certified Platform Developer I - Spring '18 Release Exam Maintenance  Q and Answers..
please help me on this...Thanks in Advance.


Thanks
Gopal M.
public class sample1
{
    public String state {get;set;}
    public String city {get;set;}
    public String Village {get;set;}
  // public String city {get;set;}

    public List<SelectOption> getStates()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));        
        options.add(new SelectOption('TN','Tamil Nadu'));
        options.add(new SelectOption('KL','Kerala'));
         options.add(new SelectOption('KA','Karnataka'));
          options.add(new SelectOption('AP','Andhrapradesh'));
                 
        return options;
    } 
                     
    public List<SelectOption> getCities()
    
    {
        List<SelectOption> options = new List<SelectOption>();
        if(state == 'TN')
        {       
            options.add(new SelectOption('CHE','Chennai'));
            options.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state == 'AP')
        {       
            options.add(new SelectOption('KUR','Kurnool'));
            options.add(new SelectOption('KDP','Kadapa'));
        }
        
        else if(state == 'KL')
        {       
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        
        
        else if(state == 'KA')
        {       
            options.add(new SelectOption('BAN','Bangalore'));
            options.add(new SelectOption('My','Mysure'));
        }
        
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }      
        return options;
    }       
 //===============================================================================   
   
      public List<SelectOption> getvillages()
    {
            
   system.debug('city '+city );
    List<SelectOption> options = new List<SelectOption>();
          
          
        // options.add(new SelectOption('None','--- None ---')); 
          //List<SelectOption> options = new List<SelectOption>();
          
        if(City == 'KUR')
        {       
            options.add(new SelectOption('AL','ALur'));
            options.add(new SelectOption('AD','Adoni'));
        }
          
           else if(City == 'KDP')
        {       
            options.add(new SelectOption('A','a1'));
            options.add(new SelectOption('B','b1'));
        }
        
         else if(City == 'CHE')
        {       
            options.add(new SelectOption('c','c1'));
            options.add(new SelectOption('d','d1'));
        }
        
         else if(City == 'CBE')
        {       
            options.add(new SelectOption('e','e1'));
            options.add(new SelectOption('f','f1'));
        }
        
         else if(City == 'COA')
        {       
            options.add(new SelectOption('g','g1'));
            options.add(new SelectOption('h','h1'));
        }
        
         else if(City == 'MVL')
        {       
            options.add(new SelectOption('i','i1'));
            options.add(new SelectOption('j','j1'));
        }
        
         else if(City == 'BAN')
        {       
            options.add(new SelectOption('k','k1'));
            options.add(new SelectOption('l','l1'));
        }
        
         else if(City == 'My')
        {       
            options.add(new SelectOption('m','m1'));
            options.add(new SelectOption('n','n1'));
        }
        
          else
        {
            options.add(new SelectOption('None','--- None ---'));
        } 
          
     return options;  
    } 
}
===================================================

@isTest
private class sample1_Test{
   static testMethod void test_getStates_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getStates();
  }
   static testMethod void test_getCities_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getCities();
  }
   static testMethod void test_getvillages_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getvillages();
  }
}

Thanks In advance.......

Regards 
Gopal M 
Test class ............please write.............
 public class NewRoadButtonController 
{
         public id currentRecordId{get;set;}
         public event ev{get;set;}
         public Boolean Car{get;set;}
         Private List<Event> eventList;
         public NewRoadButtonController(ApexPages.StandardController controller)
            {
               this.currentRecordId=controller.getRecord().Id;
            }

        public pagereference newRoadSafetyPage()
            {
                eventList=[select Travelling_by_Car__c,id,Subject,StartDateTime,Today_Date__c from Event where id=:ApexPages.currentPage().getParameters().get('id') LIMIT 1];
                if(eventList.size()!=0)
                {
                    if(eventList[0].Travelling_by_Car__c)
                    {
                        Road_Safety__c objrs = new Road_Safety__c();
                        objrs.Originating_Event_ID__c=eventList[0].id;
                        objrs.Originating_Event_Name__c=eventList[0].Subject;
                        objrs.Road_Safety_Check_Name__c=eventList[0].Subject+'-'+eventList[0].Today_Date__c;
                        objrs.IsChecked__c=true;
                        insert objrs;
        
                        Event eventOld = new Event();
                        eventOld.Id = ApexPages.currentPage().getParameters().get('id');
                        eventOld.Road_Safety_Check__c = objrs.Id;
                        Update eventOld; 
             
                        PageReference requestPage = new pagereference('/'+ objrs.id + '/e');
                        return requestPage;
                    }
                    else
                    {
                        PageReference pa=new pageReference('/apex/ErrorPage');
                        return pa;
                    }
                 
               }
               return null;
            }
}

============================================

global class RoadsafetyEventNotificationBatchSchedule implements Schedulable 
{
        global void execute(SchedulableContext sc) 
    {
        RoadsafetyEventNotificationBatch batch=new RoadsafetyEventNotificationBatch();
        Database.executeBatch(batch);  
    }
    public static void scheduler()
    {
      RoadsafetyEventNotificationBatchSchedule m = new RoadsafetyEventNotificationBatchSchedule();
      String sch ='0 0 * * * ?';
      String jobID1 = system.schedule('Push Notification Job1', sch, m);
      String sch1 ='0 5 * * * ?';
      String jobID2 = system.schedule('Push Notification Job2', sch1, m);
      String sch2 ='0 10 * * * ?';
      String jobID3 = system.schedule('Push Notification Job3', sch2, m);
      String sch3 ='0 15 * * * ?';
      String jobID4 = system.schedule('Push Notification Job4', sch3, m);
      String sch4 ='0 20 * * * ?';
      String jobID5 = system.schedule('Push Notification Job5', sch4, m);
      String sch5 ='0 25 * * * ?';
      String jobID6 = system.schedule('Push Notification Job6', sch5, m);
      String sch6 ='0 30 * * * ?';
      String jobID7 = system.schedule('Push Notification Job7', sch6, m);
      String sch7 ='0 35 * * * ?';
      String jobID8 = system.schedule('Push Notification Job8', sch7, m);
      String sch8 ='0 40 * * * ?';
      String jobID9 = system.schedule('Push Notification Job9', sch8, m);
      String sch9 ='0 45 * * * ?';
      String jobID10 = system.schedule('Push Notification Job10', sch9, m);
      String sch10 ='0 50 * * * ?';
      String jobID11 = system.schedule('Push Notification Job11', sch10, m);
      String sch11 ='0 55 * * * ?';
      String jobID12 = system.schedule('Push Notification Job12', sch11, m);
    
    }




Thanks in advance
Please create a Custom List View Button "New Case" that will pre-populate the Contact, Account, Email, based on the current logged in User if the User is external (community profile) and use the standard functionality if he is not
The contact field should be updated with $User.ContactID if the Record Type is Case from Communities.

By using Through Global Actions Only...Not java script, no url..

Thanks & Regrsds
Gopal M.
AND(
   $Profile.Name <> "System Administrator",
  ISCHANGED(StageName),
  ISPICKVAL(StageName, "Closed Lost"),
  ISPICKVAL(Loss_Reason__c, "")
)
please help this issue ?

PLEASE
trigger Example on Product2 (before insert,before update,after insert,after update) {

        System.debug('Inside Trigger ** -->');

        Product2TriggerHelper helper = new Product2TriggerHelper();
        if(!System.label.SYS_RunAPTS_ProductTrigger.equalsIgnoreCase('NO')){
            if (Trigger.isInsert && Trigger.isAfter) {
                 try{
                    
                    helper.onAfterInsert(Trigger.New);
                 }catch(Exception ex){
                     system.debug('Exception exists while inserting PriceListItem' + ex.getMessage());
                 }
            }
            if (Trigger.isUpdate && Trigger.isAfter) {
                try{

                    helper.onAfterUpdate(Trigger.New);
                 }catch(Exception ex){
                     system.debug('Exception exists while inserting PriceListItem' + ex.getMessage());
                 }
            }
        }
    }

Thanks in advance.
public static void sendEmail(String messageBody,String sSubject){
           
       try{
        
        String sRecipantName = UserInfo.getUserEmail();
        String[] sendingTo = new String[]{sRecipantName};
        Messaging.SingleEmailMessage oMail = new Messaging.SingleEmailMessage();
        String sBody = messageBody ;
        oMail.setHtmlBody(sBody);
        oMail.setSubject(sSubject);
        oMail.setBccSender(false);
        oMail.setSenderDisplayName('noreply@salesforce.com');
        oMail.setSaveAsActivity(false);
        oMail.setToAddresses(sendingTo);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { oMail });
       
        }catch(Exception ex){
            system.debug('Exception while Sending Mail ' + ex.getMessage());
        }

    }

}
 
please  help me , in development filed dependences is working fine, but when moving in to onther sandbox its not working .
when select  on open option there is no drop down list. when i am select on closed showing optins .
trigger contactnumberchange on Contact (before insert,before update) { 
    List<account> li=new list<Account>();  
    List<Id> ids = new List<Id>();  
    for(Contact c: trigger.new)  
        ids.add(c.AccountId);  
    Map<Id, Account> accountMap = new Map<Id, Account>([Select Id, Phone From Account Where Id In :ids]); 
 
    for(Contact c: trigger.new) 
    { 
        Account a = accountMap.get(c.AccountId); 
        if(a != null) 
        { 
            a.Phone= c.MobilePhone; 

            li.add(a); 
        } 
    } 
    update li;  
}
hi everyone,
can we use rollup fileds and formulae fileds in validation rules? do we face any while using them in validation rules 
Trailhead Project: Improve Data Quality for a Cleaning Supply App / (2) Create a Formula Field

Issue: Followed steps as per - Create a Formula but unable to complete the challenge
Error: Step not yet complete... here's what's wrong:
Formula in custom field 'Account Annual Revenue' is not correct. Check the instructions.

Any suggestions to fix this would be greatly appreciated.

Thanks
 
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;
			
		}

		
	}

 
I'd like to build a custom component where I can upload and display an image on a custom object 'Certificate__c'.
Can anyone guide me on how to achieve this?
  • December 11, 2017
  • Like
  • 0
Hi all,
Could you pls share the Best practices for web services in salesforce.



Thanks ,
ug.
  • October 13, 2017
  • Like
  • 0
i covered 62%  help me


public class mySecondController {
    Account account;

    public Account getAccount() {
        if(account == null) account = new Account();
        return account;
    }

    public PageReference save() {
        // Add the account to the database. 
        insert account;
        // Send the user to the detail page for the new account.
        PageReference acctPage = new ApexPages.StandardController(account).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}
=======================
@isTest
private class mySecondController_Test{
  static testMethod void test_getAccount_UseCase1(){
    mySecondController obj01 = new mySecondController();
    obj01.getAccount();
  }
  static testMethod void test_save_UseCase1(){
    mySecondController obj01 = new mySecondController();
    obj01.save();
  }
}


Thanks in Advance

 
  • October 10, 2017
  • Like
  • 0
public class sample1
{
    public String state {get;set;}
    public String city {get;set;}
    public String Village {get;set;}
  // public String city {get;set;}

    public List<SelectOption> getStates()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));        
        options.add(new SelectOption('TN','Tamil Nadu'));
        options.add(new SelectOption('KL','Kerala'));
         options.add(new SelectOption('KA','Karnataka'));
          options.add(new SelectOption('AP','Andhrapradesh'));
                 
        return options;
    } 
                     
    public List<SelectOption> getCities()
    
    {
        List<SelectOption> options = new List<SelectOption>();
        if(state == 'TN')
        {       
            options.add(new SelectOption('CHE','Chennai'));
            options.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state == 'AP')
        {       
            options.add(new SelectOption('KUR','Kurnool'));
            options.add(new SelectOption('KDP','Kadapa'));
        }
        
        else if(state == 'KL')
        {       
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        
        
        else if(state == 'KA')
        {       
            options.add(new SelectOption('BAN','Bangalore'));
            options.add(new SelectOption('My','Mysure'));
        }
        
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }      
        return options;
    }       
 //===============================================================================   
   
      public List<SelectOption> getvillages()
    {
            
   system.debug('city '+city );
    List<SelectOption> options = new List<SelectOption>();
          
          
        // options.add(new SelectOption('None','--- None ---')); 
          //List<SelectOption> options = new List<SelectOption>();
          
        if(City == 'KUR')
        {       
            options.add(new SelectOption('AL','ALur'));
            options.add(new SelectOption('AD','Adoni'));
        }
          
           else if(City == 'KDP')
        {       
            options.add(new SelectOption('A','a1'));
            options.add(new SelectOption('B','b1'));
        }
        
         else if(City == 'CHE')
        {       
            options.add(new SelectOption('c','c1'));
            options.add(new SelectOption('d','d1'));
        }
        
         else if(City == 'CBE')
        {       
            options.add(new SelectOption('e','e1'));
            options.add(new SelectOption('f','f1'));
        }
        
         else if(City == 'COA')
        {       
            options.add(new SelectOption('g','g1'));
            options.add(new SelectOption('h','h1'));
        }
        
         else if(City == 'MVL')
        {       
            options.add(new SelectOption('i','i1'));
            options.add(new SelectOption('j','j1'));
        }
        
         else if(City == 'BAN')
        {       
            options.add(new SelectOption('k','k1'));
            options.add(new SelectOption('l','l1'));
        }
        
         else if(City == 'My')
        {       
            options.add(new SelectOption('m','m1'));
            options.add(new SelectOption('n','n1'));
        }
        
          else
        {
            options.add(new SelectOption('None','--- None ---'));
        } 
          
     return options;  
    } 
}
===================================================

@isTest
private class sample1_Test{
   static testMethod void test_getStates_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getStates();
  }
   static testMethod void test_getCities_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getCities();
  }
   static testMethod void test_getvillages_UseCase1(){
    sample1 obj01 = new sample1();
    obj01.state = 'test data';
    obj01.city = 'test data';
    obj01.Village = 'test data';
    obj01.getvillages();
  }
}

Thanks In advance.......

Regards 
Gopal M 
how can i create test class for below code,
 
public static void updateOLIWhenTermMonthsChanged(List<Opportunity> newList, Map<Id, Opportunity> oldMap) {

        Set<Id> setOppId = new Set<Id>();
        Map<Id,OpportunityLineItem> map_OppLineItem = new Map<Id,OpportunityLineItem>();

        for (opportunity opp : newList) {
            if (opp.Term_Estimate_Months__c != oldMap.get(opp.Id).Term_Estimate_Months__c) {
                setOppId.add(opp.id);
            }
        }

        if(!setOppId.isEmpty()) {
            List<OpportunityLineItem> oppLineItems = [Select Id,OpportunityId from OpportunityLineItem where OpportunityId IN:setOppId];
            // we're updating OLIs to trigger rollup for commission values
            if (!oppLineItems.isEmpty()) {
                update oppLineItems;
            }
        }


 
Can anyone help me with test class for below trigger?

Trigger AutoforwardOpp on Opportunity(after insert, after update)
{
    List <PartnerNetworkRecordConnection> prncList;
    List <PartnerNetworkConnection> connectionList;
    Map <ID, PartnerNetworkConnection> connMap;
    Map <ID, ID> oppIdvsAccountIdMap;
    Map<ID, Account> accountWithContactMap;
    
    ID cid;
    String status;
    String connName;

    if(Trigger.isafter  && (Trigger.isInsert || Trigger.isUpdate)){
            
        connectionList = new List<PartnerNetworkConnection>();
        prncList = new List<PartnerNetworkRecordConnection>();
        
        //This would ideally return multiple active Connections if they exist hence its best you use a
        //criteria to ensure only the appropriate connection record is returned.
        connMap = new Map<ID, PartnerNetworkConnection>(
            [Select ID, ConnectionStatus, ConnectionName
             From PartnerNetworkConnection
             Where ConnectionStatus = 'Accepted']);
        
        //get connection details        
        for(ID connId :connMap.keySet()){
            cid = connMap.get(connId).ID;
            status = connMap.get(connId).ConnectionStatus;
            connName = connMap.get(connId).ConnectionName;
        }
        
        //Populate a map of Opp Ids and associated Account Ids
        oppIdvsAccountIdMap = new Map<ID, ID>();
        for(Opportunity oppRecord :Trigger.new){
        
            if(oppRecord.Name.contains('US')|| oppRecord.Name.contains('VSI')){
                    //System.debug('Opp Id: ' + oppRecord.ID + '-> Account Id: ' + oppRecord.AccountId);
                    oppIdvsAccountIdMap.put(oppRecord.ID, oppRecord.AccountId);
            }
        }
        
        //Get associated Accounts and Contacts for every US opportunity if they exist
        if(oppIdvsAccountIdMap.keySet().size() > 0){
        
            accountWithContactMap = new Map<ID, Account>(
                [Select ID, Name,
                    (Select ID, Name, Account.Id From Account.Contacts)
                 From Account
                 Where ID IN :oppIdvsAccountIdMap.values()]);

            //Create PartnerNetworkRecordConnections for sharing the records
            for(ID oppId : oppIdvsAccountIdMap.keySet()){
            
                ID accountId = oppIdvsAccountIdMap.get(oppId);
                
                //Share Opportunity
                prncList.add(new PartnerNetworkRecordConnection(
                    ConnectionId = cid,
                     LocalRecordId = oppId,
                    SendClosedTasks = true,
                    SendOpenTasks = true,
                    SendEmails = true));
                
                //Share Account
                if(oppIdvsAccountIdMap.get(oppId) != null){
                
                    prncList.add(new PartnerNetworkRecordConnection(
                        ConnectionId = cid,
                        LocalRecordId = accountId,
                        SendClosedTasks = true,
                        SendOpenTasks = true,
                        SendEmails = true));
                }
                
                //Share associated Contacts
                if(accountWithContactMap.get(accountId).Contacts != null){
                                   
                    for(Contact contact :accountWithContactMap.get(accountId).Contacts){
                    
                        prncList.add(new PartnerNetworkRecordConnection(
                            ConnectionId = cid,
                            LocalRecordId = contact.ID,
                         // ParentRecordId = Contact.AccountId,
                            SendClosedTasks = true,
                            SendOpenTasks = true,
                            SendEmails = true));
                    }
                }
            }//for
            
            //Insert record connections
            if(!prncList.isEmpty()){
            
                try{
                    insert prncList;
                }
                catch(System.Dmlexception dmlExceptionInstance){
                    System.debug('Record Share Error:' + dmlExceptionInstance.getMessage());
                }
            }
        }//if
    }
}
I have a few changes in the Sandbox to see how they would work in production.  These involves new fields and associated validation rules and nothing else.  What is the quickest and easiest way to get these changes only published into production environment?
Hi,

I am trying to write a test class. My current code coverage is 64%(22 lines covered out of 32 lines).
But I am getting error while running test class as:
 
Methods defined as TestMethod do not support Web service callouts

Below is my class:
 
global with sharing class invokeEILService {
    webservice static void retrievePOD(string RowId){
        Case caseRec = [Select Id, Con_Note__r.Name, Con_Note__r.Due_Delivery_Date__c from Case WHERE Id=:RowId];
        RetrievePODImageRequestEIL3.Case_x newCase= new RetrievePODImageRequestEIL3.Case_x();
        RetrievePODImageRequestEIL3.MetaData[] mDataList = new List<RetrievePODImageRequestEIL3.MetaData>();
        RetrievePODImageRequestEIL3.MetaData mData = new RetrievePODImageRequestEIL3.MetaData();
        List<Attachment> attList = new List<Attachment>();
        mData.Key = 'deliveryDate';
        mData.Value = string.valueof(caseRec.Con_Note__r.Due_Delivery_Date__c);
        newCase.ID= RowId;
        newCase.ImageType = 'pod';
        newCase.BusinessUnit = 'ipec';
        newCase.ConNote = caseRec.Con_Note__r.Name;
        mDataList.add(mData);
        newCase.MetaData=mDataList;
        
        String username= 'salesforce_uat';
        String password= 'salesforce_uat';
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'Basic '+ EncodingUtil.base64Encode(headerValue);
        
        RetrievePODImageRequestEIL3.aSalesforce_ws_provider_PODRequest_receivePODImageRequest_Port podReq = new RetrievePODImageRequestEIL3.aSalesforce_ws_provider_PODRequest_receivePODImageRequest_Port();
        podReq.inputHttpHeaders_x = new Map<String, String>();
        podReq.inputHttpHeaders_x.put('Authorization',authorizationHeader);
        RetrievePODImageRequestEIL3.Case2 res = podReq.getPODImage(newCase);
        if(res.ErrorCode=='SUCCESS'){
            if(res.Attachment.size()>0){
                for(integer i=0; i<res.Attachment.size();i++){
                Attachment attFile = new Attachment();
                attFile.ParentId = RowId;
                attFile.Body = EncodingUtil.base64Decode(res.Attachment[i].Body);
                attFile.Name = res.Attachment[i].Name;
                attFile.ContentType = res.Attachment[i].ContentType;
                attList.add(attFile);
                }
                try{
                insert attList;
                }catch(Exception e){
                   system.debug('Exception-->'+e);
               }
                System.debug('Inserted Attachment');
            }
        }else
            System.debug('Error invoking Service');
    }
}

Below is my test class:
 
@isTest(SeeAllData=true)
Public class invokeEILService_Test{
    static testMethod void retrievePODMeth() {
        
    case c = UnitTestHelper.getCaseInstance();
    insert c;
        
    system.assert(c.Id!=null);
    invokeEILService invoke = new invokeEILService();
    invokeEILService.retrievePOD(c.Id);
    }
}

I did googling also but didn't get what should do for getting my test class pass.

Kindly help me

Thanks & Regards,
Harjeet
Created one component dropped it into page. woking fine in builder as well as after preview.
But after publishing that page, the component is not visible to the user

 
hello all,
Can anyone help me in fixing this test class. I tried and written some portion , but its not showing any thing , although it is not solved , so am sharing my controller, for which i want the test class. 
plz share if any one could solve. 

Regard Aurora,


Below is the controller .
public with sharing class ctrl_outsidemenu {

   Public String Dishname { get; set;}
   Public Double Price { get; set;}
   Public Integer qty { get; set;}
   Public String remarks { get; set;}
   Public id  oid { get; set;}
    
    public ctrl_outsidemenu(ApexPages.StandardController controller) {
    			Menu__c m = new Menu__c();
    }
    
    String s = 'Food';
    public String getString() {
        return s;
    }
            
    public void setString(String s) {
        this.s = s;
    }
    
    public PageReference csave(){
    
       try{
       oid = ApexPages.currentPage().getParameters().get('id');
       Menu__c m = new Menu__c();
       m.Dish_Name__c =Dishname;
       m.Price__c =Price;
       m.Category__c = s;
       m.SubCategory__c ='Extra';
       m.Status__c ='Not available';
       insert m;
       
       
       OLI__c oli = new OLI__c();
       oli.Menu__c = m.id;
       oli.Order__c = oid;
       oli.Qty__c = qty;
       oli.Remarks__c = remarks;
       insert oli;
       }
       catch(Exception e){
         ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL,e.getmessage());
         ApexPages.addMessage(myMsg);
       }
      PageReference retURL = new PageReference('/'+oid);
      retURL.setRedirect(true);
      return retURL;
    }
    public PageReference ccancel(){
    
      oid = ApexPages.currentPage().getParameters().get('id');
      PageReference retURL = new PageReference('/'+oid);
      retURL.setRedirect(true);
      return retURL;
    }
}

 
Hi All,

My Requirement is by using record types, Can we restrict the fields in different page layouts.

For Example: Object Name : Employee
Record types: 1. Teaching
                        2. Non Teaching
For Teaching : Field : Name
                                   No
                                   Department
                                   Subjects 
For Non Teaching: Field : Name
                                          No

Shold be there. Can someone help me how to implement this using configuration ?
 
How to make visible product object for community user? 
Hello dear collages, I wan to know if someone can help me to create a test class for this apex code:

public class SP_AS
{
    @AuraEnabled
    public String recentMonthEndDate;
 
    Class HistoricalData{
        @AuraEnabled
        public String asOfDate;
       
        @AuraEnabled
        public Decimal marketValue;
    }
   
    public Class ClientAccountSummary{
        @AuraEnabled
        public String clientAccountName;
       
        @AuraEnabled
        public Decimal marketValue;
       
   }
   
}

I'm very new in salesforce and I don't have idea about how to do this. Thanks in advance.