-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
6Questions
-
1Replies
on sfdc application, tabs are not visible
Tabs are not visible
same user having PROD and Sandbox credentials,
but user is able to see all tabs in sandbox and not able to see all tabs in PROD,only able to see 4 tabs.
the profile level having all tab permissions.
please find the attachment and do the needful.
same user having PROD and Sandbox credentials,
but user is able to see all tabs in sandbox and not able to see all tabs in PROD,only able to see 4 tabs.
the profile level having all tab permissions.
please find the attachment and do the needful.
- Ramesh Guduru
- January 07, 2016
- Like
- 0
Tabs are not visible PROD
Tabs are not visible
same user having PROD and Sandbox credentials,
but user is able to see all tabs in sandbox and not able to see all tabs in PROD,only able to see 4 tabs.
the profile level having all tab permissions.
please find the attachment and do the needful.
Thanks
Ramesh
same user having PROD and Sandbox credentials,
but user is able to see all tabs in sandbox and not able to see all tabs in PROD,only able to see 4 tabs.
the profile level having all tab permissions.
please find the attachment and do the needful.
Thanks
Ramesh
- Ramesh Guduru
- January 07, 2016
- Like
- 0
OppLineItemControllerExtension1 --test class failed
I am new to salesforce,could you please assist me,i am getting errror while running these below test class.
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-
OppLineItemControllerExtension.cls
test class name:-TestOppLineItemControllerExtension.cls
i have attached both class & test class
PFA.
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-
OppLineItemControllerExtension.cls
test class name:-TestOppLineItemControllerExtension.cls
i have attached both class & test class
PFA.
/********************************************************************** Name: OppLineItemControllerExtension1 ====================================================== ***********************************************************************/ public with sharing class OppLineItemControllerExtension { public OppLineItemControllerExtension(ApexPages.StandardController controller) { } public Integer count = 1; public void Add() { count = count+1; addMore(); } public void Add3() { count = count+3; addMore(); } public void addMore() { // innerClass objInnerClass = new innerClass(count); OcrWrapper objInnerClass = new OcrWrapper(nextIdent++,LOBNames()); wrappers.add(objInnerClass); // system.debug('lstInner---->'+); } public PageReference quicksave() { return null; } public string selLOB{get; set;} public Integer oliIdentity{get; set;} public string selFamily {get; set;} public String selService {get; set;} public OpportunityLineItem oli {get; set;} public string accountName {get; set;} public Opportunity opp{get; set;} public static string oppName {get; set;} public static string oppCurrencyIsoCode {get; set;} public ID product {get; set;} Map <String, Map <String, Map <ID, String>>> LOBServicesMap = new Map <String, Map <String, Map <ID, String>>> (); String LOBName = '', Family = ''; List<SelectOption> LOBoptions = new List<SelectOption>(); // new list for holding all of the picklist items public Boolean displayOLIDetails {get; set;} public List<OcrWrapper> wrappers{get;set;} public static Integer toDelIdent {get; set;} public static Integer toClone {get; set;} public static Integer addCount {get; set;} private Integer nextIdent=1; public Boolean isLOBChanged = false; public String SerFamily {get; set;} public void changeLOB () { selFamily = '-None-'; for(OcrWrapper ocrWr : Wrappers) { if(ocrWr.ident == oliIdentity) { //selFamily = ocrWr.family; //ocrwr.family = ''; ocrwr.serviceLine = ''; ocrWr.lob= ocrwr.ocr.Line_of_Business__c;// = selLOB; selLOB = ocrWr.lob; // ocrwr.subServiceSelectOption.clear(); ocrwr.subServiceSelectOption.add(new SelectOption('','-None-')); ocrwr.familySelectOption = ServiceFamilies(); } } } // Method which is used to collect Service picklist values public void changeFamily() { // system.debug('----------ServiceField---------'+oliIdentity); selFamily = '-None-'; for(OcrWrapper ocrWr : Wrappers) { if(ocrWr.ident == oliIdentity) { selFamily = ocrWr.family; ocrWr.subServiceSelectOption = ServiceOfferings(); } } } // Method which is used to collect Sub-Service picklist values public void ChangeSubService() { for(OcrWrapper ocrWr : Wrappers) { if(ocrWr.ident == oliIdentity) { ocrWr.serviceLine = ocrWr.serviceLine; system.debug('----------ocrWr.serviceLine---------'+ocrWr.serviceLine); } } } public OppLineItemControllerExtension() { selLOB = '-None-'; selFamily = '-None-'; if ((ApexPages.currentPage().getParameters().get('opp_id') != null)&&(ApexPages.currentPage().getParameters().get('opp_id').length() > 0)) { System.debug ('*****Opp in URL: '+ ApexPages.currentPage().getParameters().get('opp_id').length()); this.oli = new OpportunityLineItem(); oli.OpportunityId = ApexPages.currentPage().getParameters().get('opp_id'); opp = [select Name, Account.name, CurrencyIsoCode,IsClosed ,ServiceEdit__c,Opportunity_Owner_Country__c,OwnerID,Client_Sub_Type__c from Opportunity where id=:oli.OpportunityId]; accountName = opp.Account.Name; oppName = opp.Name; oppCurrencyIsoCode = opp.CurrencyIsoCode; for (pricebookentry pbe : [SELECT product2.recordtype.name, product2.family, product2.Sub_Service__c, product2Id from pricebookentry where pricebook2.name like 'OPP%' and isActive = TRUE and pricebookentry.CurrencyIsoCode =: oppCurrencyIsoCode order by product2.recordtype.name, product2.family, product2.Sub_Service__c]) { if (LOBName != pbe.product2.recordtype.name) { LOBName = pbe.product2.recordtype.name; System.debug('LOB NAME::::'+LOBName); LOBServicesMap.put (LOBName, new Map <String, Map <ID, String>> ()); } if (Family != pbe.product2.family) { Family = pbe.product2.family; LOBServicesMap.get (LOBName).put (Family, new Map <ID, String> ()); } LOBServicesMap.get (LOBName).get (Family).put (pbe.id, pbe.product2.Sub_Service__c); } displayOLIDetails = true; } //PU:03/04/2011 - When the Opportunity Id is null the below error message has to be displayed. else { displayOLIDetails = false; ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.Error, Label.oppLI_ErrMsgOppRequired)); } wrappers=new List<OcrWrapper>(); for (Integer idx=0; idx<1; idx++) { List<selectOption> opt = LOBNames(); wrappers.add(new OcrWrapper(nextIdent+1,opt)); } } public List<SelectOption> LOBNames() { List<SelectOption> LOSoptions = new List<SelectOption>(); // new list for holding all of the picklist items // LOBoptions.clear(); LOBoptions.add(new SelectOption('-None-','-None-')); //add the first option of '-None-' List<String> LOBNamesList = new List<String>(); for (String LOBName : LOBServicesMap.keySet()) { LOBNamesList.add(LOBName); } if(LOBNamesList.size() > 0) LOBNamesList.sort(); for (String LOBName : LOBNamesList) { LOBoptions.add (new SelectOption (LOBName, LOBName)); } return LOBoptions; } public List<SelectOption> ServiceFamilies() { List<SelectOption> LOSoptions = new List<SelectOption>(); // new list for holding all of the picklist items // LOSoptions.clear (); selService = null; LOSoptions.add(new SelectOption('','-None-')); //add the first option of '-None-' List<String> LOSoptionsList = new List<String>(); if ((selLOB != null) && (selLOB != '-None-') && (selLOB != '')) { for (String family : LOBServicesMap.get(selLOB).keySet()) { LOSoptionsList.add(family); } } if(LOSoptionsList.size() > 0) LOSoptionsList.sort(); for (String family : LOSoptionsList) { LOSoptions.add(new SelectOption (family, family)); } return LOSoptions; // returns all unique picklist options for Family } public List<SelectOption> ServiceOfferings() { List<SelectOption> serviceOptions = new List<SelectOption>(); // serviceOptions.clear (); serviceOptions.add(new SelectOption('','-None-')); List<String> serviceOptionsList = new List<String>(); List<SelectOption> TempserviceOptions = new List<SelectOption>(); //Adding Sub Services to a list to sort System.debug('selLOB----$$$$'+selLOB);System.debug('selFamily----$$$$'+selFamily); if ((selFamily != null) && (selFamily != '-None-') && (selFamily != '')) { Map <ID, String> serviceMap = LOBServicesMap.get(selLOB).get (selFamily); system.debug('serviceMap$$$'+serviceMap); if(serviceMap.size() > 0) for (ID service : serviceMap.keySet()) { TempserviceOptions.add(new SelectOption(service, serviceMap.get (service))); serviceOptionsList.add(serviceMap.get (service)); } } //Sort the Sub Services if(serviceOptionsList.size() > 0) serviceOptionsList.sort(); //Adding the SubServices into a selectOption list after sorting for(String str: serviceOptionsList) { for(Selectoption selectOpt : TempserviceOptions) { if(selectOpt.getLabel().equals(str)) serviceOptions.add(new SelectOption(selectOpt.getValue(),selectOpt.getLabel())); } } return serviceOptions; } public PageReference save() { List<OpportunityLineItem> finalOliList = new List<OpportunityLineItem>(); Boolean isError = false; for(OcrWrapper oliwr : Wrappers) { if(oliwr.lob == null) { ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, Label.OppProd_ErrMsgSelectionsRequired)); isError = true; } if(oliwr.family == null) { ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, Label.OppProd_ErrMsgSelectionsRequired)); isError = true; } if(oliwr.serviceline == null) { ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, Label.OppProd_ErrMsgSelectionsRequired)); isError = true; } if(oliwr.ocr.UnitPrice > oliwr.ocr.Total_Client_Spend__c) { oliwr.ocr.UnitPrice.addError('Please enter a value less than Total Client Spend'); isError = true; } if(oliwr.ocr.Gross_Profit_Percent__c < 0 || oliwr.ocr.Gross_Profit_Percent__c > 100 ) { oliwr.ocr.Gross_Profit_Percent__c.addError('Please enter a valid percentage (0-100)'); isError = true; } if(oliwr.ocr.New_Business_Percent__c < 0 || oliwr.ocr.New_Business_Percent__c > 100 ) { oliwr.ocr.New_Business_Percent__c.addError('Please enter a valid percentage (0-100)'); isError = true; } // if(oliwr.ocr.Service_Owner__c == null) { // oliwr.ocr.Service_Owner__c= UserInfo.getUserId(); //} if(isError == True) continue; OpportunityLineItem oliInst = new OpportunityLineItem( OpportunityId = opp.Id, PricebookEntryId = oliwr.serviceLine, Quantity =1,UnitPrice = oliwr.ocr.UnitPrice, Total_Client_Spend__c = oliwr.ocr.Total_Client_Spend__c, Country__c = oliwr.ocr.Country__c, New_Engagement__c = oliwr.ocr.New_Engagement__c, Engagement_Details__c = oliwr.ocr.Engagement_Details__c, Business_unit__c= oliwr.ocr.Business_Unit__c, Gross_Profit_Percent__c = oliwr.ocr.Gross_Profit_Percent__c, Total_Gross_Profit_Dollar__c = oliwr.ocr.Total_Gross_Profit_Dollar__c, Service_Offering__c = oliwr.ocr.Service_Offering__c, // Service_Owner__c = oliwr.ocr.Service_Owner__c, Line_of_Business__c = oliwr.ocr.Line_of_Business__c, IBM_Line_of_Business__c = oliwr.ocr.IBM_Line_of_Business__c, New_Business_Percent__c = oliwr.ocr.New_Business_Percent__c, Occupation_Category__c = oliwr.ocr.Occupation_Category__c, Client_Direct_Contribution_Margin_CDCM__c = oliwr.ocr.Client_Direct_Contribution_Margin_CDCM__c, Job_Title__c = oliwr.ocr.Job_Title__c, Client_Location_Type__c = oliwr.ocr.Client_Location_Type__c, OnSite__C = oliwr.ocr.OnSite__C, X30_Day_Associate_Actual__c = oliwr.ocr.X30_Day_Associate_Actual__c, X30_Day_Associate_Need__c = oliwr.ocr.X30_Day_Associate_Need__c, X60_Day_Associate_Actual__c =oliwr.ocr.X60_Day_Associate_Actual__c, X60_Day_Associate_Need__c = oliwr.ocr.X60_Day_Associate_Need__c, X90_Day_Associate_Actual__c = oliwr.ocr.X90_Day_Associate_Actual__c, X90_Day_Associate_Need__c = oliwr.ocr.X90_Day_Associate_Need__c, Perm_Placement_Fee__c = oliwr.ocr.Perm_Placement_Fee__c, Perm_Placement_Position_Salary__c = oliwr.ocr.Perm_Placement_Position_Salary__c, New_LOB_Opportunity__c = oliwr.ocr.New_LOB_Opportunity__c, Potential_of_Associates__c = oliwr.ocr.Potential_of_Associates__c ); finalOliList.add(oliInst); } if(finalOliList.size()>0 && isError == false) { try { if(finalOliList.size() > 0) insert finalOliList; } catch (DMLException de) { ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, 'DML Error: '+ de.getMessage ())); return null; } return new ApexPages.Standardcontroller (opp).view (); } return null; } public PageReference cancel() { return new ApexPages.Standardcontroller (opp).view (); } //Wrapper class which is used to store list of Opportunity Line Items public class OcrWrapper { public OpportunityLineItem ocr {get;set;} public Integer ident {get;set;} public String lob {get;set;} public String family {get;set;} public String serviceLine {get;set;} public List<SelectOption> lOBSelectOption{get;set;} public List<SelectOption> familySelectOption{get;set;} public List<SelectOption> subServiceSelectOption{get;set;} //Constructor which is used to initialize variables public OCrWrapper(Integer inIdent,List<SelectOption> lobOptions) { System.debug('!!!!!!!!INSIDE ocrWrapper Funtion!!!!!!!'); ident=inIdent; lob=''; family=''; serviceLine = ''; lOBSelectOption = new List<SelectOption>(); familySelectOption = new List<SelectOption>(); familySelectOption.add(new SelectOption('','-None-')); subServiceSelectOption = new List<SelectOption>(); subServiceSelectOption.add(new SelectOption('','-None-')); ocr=new OpportunityLineItem ( // Total_Client_Spend__c = 0, // unitPrice = 0, // Service_Owner__c = UserInfo.getUserId() // Gross_Profit_Percent__c = 0, // Total_Gross_Profit_Dollar__c = 0, // New_Business_Percent__c = 0 ); lOBSelectOption = lobOptions; System.debug('!!!!!!!!NEW ROW OCR!!!!!!!'+ocr); } //Construtor which is used to add initialize rows for cloning public ocrWrapper(Integer inIdent,OcrWrapper cloneRow) { ident=inIdent; lOBSelectOption = cloneRow.lOBSelectOption; familySelectOption = cloneRow.familySelectOption; subServiceSelectOption = cloneRow.subServiceSelectOption; lob = cloneRow.lob; family = cloneRow.family; serviceLine = cloneRow.serviceLine; ocr=new OpportunityLineItem ( //Total_Client_Spend__c = 0, //unitPrice = 0, //Service_Owner__c = cloneRow.ocr.Service_Owner__c, Business_Unit__c = cloneRow.ocr.Business_Unit__c, Service_Offering__c =cloneRow.ocr.Service_Offering__c, Line_of_Business__c = cloneRow.ocr.Line_of_Business__c //Gross_Profit_Percent__c = 0,Total_Gross_Profit_Dollar__c = 0, //New_Business_Percent__c = 0 ); } } //end of Wrapper class //method which is used to add row(s) public void addRows() { System.debug('!!!!!!!!INSIDE ADD ROW!!!!!!!'); for (Integer idx=0; idx<addCount; idx++) { System.debug('!!!!!!!!INSIDE FOR LOOP!!!!!!!'); wrappers.add(new OcrWrapper(nextIdent++,LOBNames())); } } //Method which is used to delete a particular row in the page public void delWrapper() { Integer toDelPos=-1; for (Integer idx=0; idx<wrappers.size(); idx++) { if (wrappers[idx].ident==toDelIdent) { // wrappers[idx].ocr.Total_Client_Spend__c = 0; // wrappers[idx].ocr.UnitPrice = 0; // wrappers[idx].ocr.Gross_Profit_Percent__c = 0; // wrappers[idx].ocr.Total_Gross_Profit_Dollar__c = 0; //wrappers[idx].ocr.New_Business_Percent__c = 0; toDelPos=idx; } } if (-1!=toDelPos) { wrappers.remove(toDelPos); } } //Method which is used to clone the row public void cloning() { for (Integer idx=0; idx<wrappers.size(); idx++) { if (wrappers[idx].ident==toClone) { OcrWrapper wr = wrappers[idx]; wrappers.add(new OcrWrapper(nextIdent++,wr)); } } } public Boolean getSMBProfiles() { List<Profile> Prof; Prof = [Select id from Profile where Name='System Administrator' or Name = 'Sales Manager - MP NA' or Name = 'Sales Pro - MP NA' or Name = 'L2 SMB Support']; for(Profile p :Prof) { if (UserInfo.getProfileId()== p.Id) return true; } return false; } public Boolean getEuropeProfiles() { List<Profile> Prof; Prof = [Select id from Profile where Name='System Administrator' or Name = 'Sales Manager - Europe' or Name = 'Sales Pro - Europe' or Name = 'L2 Support']; for(Profile p :Prof) { if (UserInfo.getProfileId()== p.Id) return true; } return false; } } // End of the main class *********** test class name:- TestOppLineItemControllerExtension.cls ***************************************** /*Class Name: TestOppLineItemControllerExtension.cls Original Author: Deepak Padhye Original Creation Date: 03/03/2010 Original Release: Purpose: Test Class for OppLineItemControllerExtension.cls Ticket#: Changes: PU 02/14/2011: Ticket#220959 - Completely refactored the test class to improve the code coverage and efficiency. Changes: PU 03/04/2011: Ticket#223609- Added a new test method testOppIdNUll. */ @isTest private class TestOppLineItemControllerExtension { /* Input: No input variables Process: Inserts an opportunity record. Output: Returns a single opportunity record Changes: None */ Static opportunity test1; Static opportunity opp2; static Opportunity createTestdata() { Account acc = new Account (name = 'TestOppLineItemAccount',BillingCity = 'TestOppLineItemCity', BillingCountry ='TestOppLineItemCountry', BillingStreet ='TestOppLineItemStreet',phone='1111', BillingPostalCode ='76768'); insert acc; Pricebook2 pr = new Pricebook2(); pr.name = 'test'; pr.isactive = true; insert pr; opportunity opp = new Opportunity(Name='Test Opp',Pricebook2Id=pr.Id, Opportunity_Type__c='Parent', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco'); insert opp; system.debug(opp.Id); opp.name= 'Plan1'; update opp; /*opportunity opp3 = new Opportunity(Name='Test Opp',Opportunity_Type__c='Child', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco'); insert opp3;*/ opp2 = new Opportunity(Name='Test Opp',Parent_Opportunity__c=opp.Id,Opportunity_Type__c='Child', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco'); insert opp2; opp2.Name = 'test2'; update opp2; test1 = [Select o.Type, o.Pricebook2Id, o.OwnerId, o.Oppotunity_Designation__c, o.Active_Latent__c, o.Solution_Type__c, o.Opportunity_Short_Description__c, o.Opportunity_ID__c, o.NextStep, o.New_Business_Percent__c, o.Name, o.Local_Client__c, o.Local_Client_Short_Name__c, o.IsWon, o.IsDeleted, o.IsClosed, o.Id, o.HasOpportunityLineItem, o.CreatedById, o.Amount, o.AccountId From Opportunity o WHERE o.Id = :opp.Id]; return test1; } static testMethod void testInsertOLI() { createTestdata(); test.startTest(); ApexPages.StandardController sc = new ApexPages.StandardController (test1); OppLineItemControllerExtension str1 = new OppLineItemControllerExtension (sc); str1.LOBNames(); ApexPages.currentPage().getParameters().put('opp_id',test1.Id); OppLineItemControllerExtension str = new OppLineItemControllerExtension (); str.Add(); str.Add3(); str.ServiceFamilies(); str.changeLOB (); str.changeFamily(); str.ChangeSubService(); str.quicksave(); //str.ServiceSubServices(); str.ServiceOfferings(); try{ str.save(); }catch(exception e){} str.addRows(); str.cancel(); str.delWrapper(); str.cloning(); test.stopTest(); } static testMethod void testOppIdNull() { // Set the current page to OpportunityLineItemEdit VF Page PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit'); Test.setCurrentPage(servicesPage); //Create an object of the OppLineItemControllerExtension class OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension (); //Test the error message for(ApexPages.Message m : ApexPages.getMessages()) { if(m.getDetail() == Label.oppLI_ErrMsgOppRequired) system.assert(true); } } Process: Set the current page to OpportunityLineItemEdit and created an object of the Controller class.Invoked the cancel method and tested the url of the page it navigates to. Output: It navigates to the opp detail page. Changes: None */ static testMethod void testcancelMethod() { //Create test data Opportunity opp = new opportunity(); opp = createTestData(); Test.startTest(); // Set the current page to OpportunityLineItemEdit VF Page PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit?opp_id='+opp.id); Test.setCurrentPage(servicesPage); //Create an object of the OppLineItemControllerExtension class OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension (); //Invoke the cancel method and verify the url of the page it navigates to String nextpage = oliCE.cancel().getUrl(); PageReference p = new ApexPages.Standardcontroller (opp).view (); Test.stopTest(); system.assertequals(p.getUrl(),nextpage); } /* Input: No input variables Process: Set the current page to OpportunityLineItemEdit and created an object of the Controller class.Populate all the fields on the Vf page.Re- populate the Line Of business and invoke the changeLOB method. Now the value of the service line would be "None" since the LOB has changed and the value of sub-service would be "null" since the value of the service line is None. Output: The values of the serviceline and sub-service are refreshed Changes: None */ static testMethod void testChangeLOB() { //Create test data Opportunity opp = new opportunity(); opp = createTestData(); Test.startTest(); // Set the current page to OpportunityLineItemEdit VF Page PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit?opp_id='+opp.id); Test.setCurrentPage(servicesPage); Test.stopTest(); //Create an object of the OppLineItemControllerExtension class OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension (); //Populate the values of LOB, Service Line and Sub-service //oliCE.selLOB = oliCE.getLOBNames()[1].getValue(); //oliCE.selFamily = oliCE.getServiceFamilies()[1].getValue(); //oliCE.selService = oliCE.getServiceOfferings()[1].getValue(); Test.startTest(); //The values of service Line and sub-service are not null system.assertnotEquals(null, oliCE.selFamily); system.assertEquals(null, oliCE.selService); //re-populate the value of LOB and invoke the changeLOB method // oliCE.selLOB = oliCE.getLOBNames()[2].getValue(); oliCE.changeLOB(); //Retrieve the values of service line and sub-service // oliCE.getServiceFamilies(); // oliCE.getServiceOfferings(); // The service line will be none because the LOB has changed system.assertEquals('-None-', oliCE.selFamily); // The sub-service will be null because the service line is NONE system.assertEquals(null, oliCE.selService); //Test.stopTest(); } }
- Ramesh Guduru
- December 10, 2015
- Like
- 0
TestClientHelper -test class failed
I am new to salesforce,could you please assist me,i am getting errror while running these below test class.
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-ClientHelper
test class name:-TestClientHelper
i have attached both class & test class
PFA.
Thanks
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-ClientHelper
test class name:-TestClientHelper
i have attached both class & test class
PFA.
Thanks
class name:-ClientHelper ************************** /********************************************************************** /** * Class Name ClientHelper * @Author Sivarajan (Siva) * @Version 1.0 * @Creation Date 05/25/2011 * @Release * @Purpose * i) Reassigning the client Ownership to "MPG ADMIN" Once a client is inserted * ii) Adding Owner to Client team *Goutham Tatineni 6/25/2012 : Made an enhancment to not include Data manager User in the client team. ***********************************************************************/ public without sharing class ClientHelper { /** Instance for TeamAssignmentController */ static TeamAssignmentController assignmentObj; /** * Method which is used to initiate Data stewardship process like * Changing ownership to "MPG ADMIN", Adding the client owner to client team, * * @param 01 * List of new Accounts to be inserted/updated * @param 02 * Map of new Accounts to be inserted/updated * @param 03 * true if trigger event is 'Insert' * */ public static void automateDSProcess(List<Account> newAccounts, Map<Id,Account> newAccountMap, boolean isInsert) { /** If trigger event is insertion then call the * addClientTeamMember method */ if(isInsert == true) { addClientTeamMember(newAccounts,newAccountMap); } } /** * Method which is used for Changing ownership to "MPG ADMIN" and * Adding the client owner to client team, * * @param 01 * List of new Accounts to be inserted/updated * @param 02 * Map of new Accounts to be inserted/updated */ public static void addClientTeamMember(List<Account> newAccounts, Map<Id,Account> newAccountMap) { /* List which has Accounts to reassign */ List<Account> reassignAccsList = new List<Account>(); /* Map which is used to store user details */ Map<Id,User> usersMap = new Map<Id,User>(); /* List to store client owner Ids */ List<Id> ownerIds = new List<Id>(); /** List of Account Ids where the Account owner needs * to add to client team */ List<Account> accIdsToReassign = new List<Account>(); /* to get Id of MPG admin user */ User MpgAdmin = getMPGADMINDetails(); for (Account acc : newAccounts) { Account account = new Account(Id = acc.Id,OwnerId = MpgAdmin.Id); reassignAccsList.add(account); ownerIds.add(acc.OwnerId); } /** call the method getOwners to get the owner information like profile, * status(Active/inActive)and Id */ usersMap = getOwners(OwnerIds); /* Reassigning client ownership to "MPG ADMIN" */ if (reassignAccsList.size() > 0) { assignmentObj = new TeamAssignmentController(); update reassignAccsList; } /** * Adding the user to Client team After a client is created. * Clients which owned by "System Admin(L3)" won't be added to client team */ for (Account reAssignedAcc : newAccounts) { /* Adding to client team if a user is active and not related to L3 */ if (MpgAdmin != null && usersMap.get(reAssignedAcc.OwnerId).ProfileId != MpgAdmin.ProfileId && usersMap.get(reAssignedAcc.OwnerId).ProfileId != '00e30000001YDfG' && usersMap.get(reAssignedAcc.OwnerId).IsActive == true) { addAccountTeamMember(reAssignedAcc.Id,reAssignedAcc.OwnerId); } } } /* Method which is used to get information of the MPG ADMIN user */ public static User getMPGADMINDetails() { User MpgAdmin = [select Id,ProfileId from User where firstname =: 'MPG' and lastname =: 'ADMIN']; return MpgAdmin; } /* Method which is used to get owner details */ public static Map<Id,User> getOwners(List<Id> accOwnerIds) { Map<Id,User> usersMap = new Map<Id,User>([select Id,Name,ProfileId, IsActive from user where Id in: accOwnerIds]); return usersMap; } /* Method which is used to add the Team member to the client team */ public static void addAccountTeamMember(Id accId,Id userId) { assignmentObj.createNewAssignmentNewAssignment( new AccountTeamMember(AccountId = accId,TeamMemberRole = 'Client Representative - Sales', UserId = userId)); } } // End of Class ******************************** Test class name :-TestClientHelper /** * Class Name TestClientHelper * @Author Sivarajan (Siva) * @Version 1.0 * @Creation Date 05/31/2011 * @Release ----- * @Purpose * Test Class for ClientHelper Apex class * ***********************************************************************/ @isTest private class TestClientHelper{ private static Account AccforDSAutomation =null; private static Account AccforDSAutomation1 =null; private static Account newUltAccforDSAutomation = null; private static Account ultAccforDSAutomation = null; private static List<User> usrList = new List<User>(); private static List<Account> accountList = new List<Account>(); private static Profile ClientTeamMgrProfile; private static Profile SystemAdmin; private static List<Opportunity> optyAccforDSAutomation= new List<Opportunity>(); /* Method which is used to get profiles data*/ public static void getProfile() { if (ClientTeamMgrProfile == null) { ClientTeamMgrProfile = [select id from profile where name='Sales Manager']; } if (SystemAdmin == null) { SystemAdmin = [select id from profile where name='System Administrator']; } } /* Method which is used to get users data*/ public static void getUsers() { usrList = new List<User>(); //SD: The environment is dynamic String[] environment = Userinfo.getUserName().split('@'); for (integer i=0;i<2;i++) { User u = new User(); u.FirstName=i+'DSTestFirstName1'; u.Lastname=i+'DSTestlastname1'; u.alias = 'Tst'; u.email=i+ 'DSTestFirstName1.DSTestlastname1@mpg.com'; if(i == 0) u.profileid = ClientTeamMgrProfile.Id; if(i == 1) u.profileid = SystemAdmin.Id; u.username= u.FirstName+u.Lastname+'@'+environment[1]; u.emailencodingkey='UTF-8'; u.languagelocalekey='en_US'; u.localesidkey='en_US'; u.timezonesidkey='America/Los_Angeles'; // u.LOB_Region__c = 'MP - NA'; u.Country ='USA'; u.CompanyName = 'Manpower'; u.Brand__c = 'ManpowerGroup'; u.Region__c = 'Corporate'; u.Sub_Region__c = 'Corporate'; usrList.add(u); } if(usrList.size()> 0) //Test.startTest(); insert usrList; //Test.stopTest(); } /* Method which is used to insert sample Accounts */ public static void getAccounts() { if (ultAccforDSAutomation== null) { ultAccforDSAutomation= new Account(name = 'ultAccforDSAutomation', BillingCity ='ultAccforDSAutomationTestCity', BillingCountry ='ultAccforDSAutomationCountry', BillingStreet ='ultAccforDSAutomationSt', BillingPostalCode ='536768', phone = '010101'); // Test.startTest(); insert ultAccforDSAutomation; //Test.stopTest(); } if (AccforDSAutomation== null) { AccforDSAutomation = new Account(name = 'AccforDSAutomation', BillingCity = 'DSAutomationTestCity', BillingCountry ='DSAutomationTestCountry', BillingStreet ='DSAutomationSt', BillingPostalCode ='536767', Ultimate_Parent_Client__c = ultAccforDSAutomation.Id, phone = '020202', OwnerId = usrList[0].Id); accountList.add(AccforDSAutomation ); } if (AccforDSAutomation1== null) { AccforDSAutomation1= new Account(name = 'AccforDSAutomation1', BillingCity = 'AccforDSAutomation1TestCity', BillingCountry ='AccforDSAutomation1TestCountry', BillingStreet ='AccforDSAutomation1St', BillingPostalCode ='536876', phone = '010101', OwnerId = usrList[1].Id); accountList.add(AccforDSAutomation1); } if(accountList.size() > 0) { // Test.startTest(); insert accountList; //Test.stopTest(); } } /* Test method to cover the code for the method of * Apex class 'ClientHelper' : * Method "addClientTeamMember" * */ static testmethod void clientHelperTestmethod() { getProfile(); getUsers(); getAccounts(); /*Checking whether the Ownership of Account is reassigned to "MPG ADMIN".*/ System.assertEquals([select Id,Owner.Name from Account where Id =: AccforDSAutomation.Id].Owner.Name,'MPG ADMIN'); List<AccountTeamMember> ATM = [Select AccountId,id,UserId,TeamMemberRole, Account.Name From AccountTeamMember where AccountId =: AccforDSAutomation.Id]; /* Checking whether the client Owner(Non System Admin) is added to Client team. */ System.assertEquals(ATM.size() > 0, true); List<AccountTeamMember> ATM1 = [Select AccountId,id,UserId,TeamMemberRole, Account.Name From AccountTeamMember where AccountId =: AccforDSAutomation1.Id]; /* Checking whether the client Owner(System Admin - L3) is not added to Client team. */ System.assertEquals(ATM1.size() == 0, true); /* Checking the role of the inserted client team member. */ System.assertEquals(ATM[0].TeamMemberRole, 'Client Representative - Sales'); Client_Financials__c cf = new Client_Financials__c(); cf.Client__c = ATM[0].AccountId; //Test.startTest(); insert cf; //Test.stopTest(); ClientTeamAssignmentHelper cs = new ClientTeamAssignmentHelper(); cs.newAccountTeamMembers(ATM1); cs.createClientFinancialShareList(ATM); cs.deleteAccountTeamMembers(ATM); cs.deleteClientFinancialShare(ATM); } } //End of test class
- Ramesh Guduru
- December 10, 2015
- Like
- 0
profile not visible while creating new user
I have 2 users in one profile, User 1 with Role : ' GLOBAL_HQ', & User 2 with Role : MP NA Manpower'
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
- Ramesh Guduru
- December 10, 2015
- Like
- 1
Too many SOQL queries: 101 -System.LimitException:
I am new to salesforce,could you please assist me,i am getting errror while running these below test class.
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-UpdateAccounts
test class name:-TestUpdateAccounts
i have attached both class & test class
PFA.
Thanks
(error message :-System.LimitException: Too many SOQL queries: 101)
class name:-UpdateAccounts
test class name:-TestUpdateAccounts
i have attached both class & test class
PFA.
Thanks
class name:-UpdateAccounts ************************** /*Class Name: UpdateAccounts.cls Original Author: Prathyusha Uppada, NRC Original Creation Date: 11/16/2010 Original Release: 2.3 Purpose: The class methods are invoked by the AccountMasterTrigger.trigger. Whenever the Ultimate_Parent_Client__c of a subsidiary Client or the Type of an Ultimate Parent Client is updated the TYPE of all the subsidiary clients should be updated to its Ultimate Parent's TYPE. Ticket#: 207999 Changes: PU: 01/19/2011:Defect# 218746- Udpated the updateAccountType method to be invoked by the AccountMasterTrigger.trigger on after insert as well. PU: 03/04/2011:Ticket#219268- When the Sub-Type of an Ultimate parent is updated the sub-type on the corresponding child clients should be updated as well. Ticket#: 251052 Enhancment - Updated the code so that Strategic client start date and end date will be cascade in the hierarchy. */ public with sharing class UpdateAccounts { /* Input: We pass in the new and old values of the trigger. Process: Retrieve all the Subsidary clients whose UltimateParent or its ultimateParent's Type has changed and update the Type Output: N/A Changes: */ public static void updateAccountType(Map<Id,Account> mapOfNewAccounts,Map<Id,Account> mapOfOldAccounts,List<Account> accsList) { Set<Id> ultimateParentIds = new Set<Id>(); Set<Id> subsidiaryClientUPIds= new Set<Id>(); Set<Id> subsidiaryClientIds= new Set<Id>(); Map<Id,Account> mapOfUParents; List<Account> accsToUpdate = new List<Account>(); Map<Id,Integer> mapOfaccsToUpdate = new Map<Id,Integer>(); boolean isFlagged = true; Integer i=0; //Flag is validated to ensure that the trigger is executed only once if(isFlagged == true) { //Loop through the list of Accounts being updated and add all the ultimate parent Clients to ultimateParentIds List // and all the subsidiaryClient Ids and their UltimateParent Ids to subsidiaryClientIds and subsidiaryClientUPIds respectively for(Account a : accsList) { //PU: 01/19/11- Updated the if condition to execute the below code only when this method is invoked as part of the update trigger, //Since we need to update the Type of all child clients only when the Type of its UP is changed and not when a new Uparent is created. if((a.Ultimate_Parent__c == true)&& (mapOfOldAccounts!=null)) { if((mapOfOldAccounts.get(a.ID).Type != mapOfNewAccounts.get(a.ID).Type) || (mapOfOldAccounts.get(a.ID).Strategic_Client_Start_Date__c != mapOfNewAccounts.get(a.ID).Strategic_Client_Start_Date__c ) || (mapOfOldAccounts.get(a.ID).Strategic_Client_End_Date__c!= mapOfNewAccounts.get(a.ID).Strategic_Client_End_Date__c ) || (mapOfOldAccounts.get(a.ID).MP_US_National_Accounts__c != mapOfNewAccounts.get(a.ID).MP_US_National_Accounts__c)) { //List of UltimateParents whose Type has changed. ultimateParentIds.add(a.ID); } } else { //List of Subsidiary Clients and its corresponding UltimateParentids subsidiaryClientIds.add(a.Id); subsidiaryClientUPIds.add(a.Ultimate_Parent_Client__c); } } //Retrieve all the Subsidiary clients for the UltimateParents whose Type has changed // and add them to the accsToUpdate list if(ultimateParentIds.size() > 0) { for(Account acc1 : [Select Type,MP_US_National_Accounts__c,Strategic_Client_Start_Date__c ,Strategic_Client_End_Date__c, Id , Ultimate_Parent_Client__c,Ultimate_Parent__c From Account Where Ultimate_Parent_Client__c in: ultimateParentIds ]) { // Check to see that the client has not been added to the accsToUpdate list if(!mapOfaccsToUpdate.ContainsKey(acc1.Id)) { acc1.Type = mapOfNewAccounts.get(acc1.Ultimate_Parent_Client__c).Type; acc1.Strategic_Client_Start_Date__c = mapOfNewAccounts.get(acc1.Ultimate_Parent_Client__c).Strategic_Client_Start_Date__c; acc1.Strategic_Client_End_Date__c = mapOfNewAccounts.get(acc1.Ultimate_Parent_Client__c).Strategic_Client_End_Date__c; acc1.MP_US_National_Accounts__c = mapOfNewAccounts.get(acc1.Ultimate_Parent_Client__c).MP_US_National_Accounts__c; accsToUpdate.add(acc1); mapOfaccsToUpdate.put(acc1.Id,i+1); } } } if(subsidiaryClientUPIds.size() > 0) { //Retrieve UltimateParentids for all the Subsidiary clients whose Ultimate_parent_client__c has changed mapOfUParents = new Map<Id,Account>([Select Id ,MP_US_National_Accounts__c,Sub_Type__c,Strategic_Client_End_Date__c,Strategic_Client_Start_Date__c, Type From Account Where Id in: subsidiaryClientUPIds ]); //Iterate over all the Subsidiary clientsand update the Type field for(Account acc2 : [Select Id,Sub_type__c,MP_US_National_Accounts__c,Strategic_Client_End_Date__c,Strategic_Client_Start_Date__c,Ultimate_Parent_Client__c,Type From Account Where Id in: subsidiaryClientIds]) { // Update the Sub_Type__c field for all the subsidiary clients that satisfies //the below condition if((!mapOfaccsToUpdate.containsKey(acc2.Id))&& (mapOfUParents.containsKey(acc2.Ultimate_Parent_Client__c))&& (acc2.Type != mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Type || (acc2.Strategic_Client_Start_Date__c != null && mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_Start_Date__c != null && acc2.Strategic_Client_Start_Date__c != mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_Start_Date__c ) || (acc2.Strategic_Client_End_Date__c != null && mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_End_Date__c != null && acc2.Strategic_Client_End_Date__c != mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_End_Date__c ) || (acc2.MP_US_National_Accounts__c != null && mapOfUParents.get(acc2.Ultimate_Parent_Client__c).MP_US_National_Accounts__c != null && acc2.MP_US_National_Accounts__c != mapOfUParents.get(acc2.Ultimate_Parent_Client__c).MP_US_National_Accounts__c ) )) { acc2.type = mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Type; acc2.Strategic_Client_Start_Date__c = mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_Start_Date__c ; acc2.Strategic_Client_End_Date__c = mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Strategic_Client_End_Date__c ; acc2.MP_US_National_Accounts__c = mapOfUParents.get(acc2.Ultimate_Parent_Client__c).MP_US_National_Accounts__c ; accsToUpdate.add(acc2); mapOfaccsToUpdate.put(acc2.Id,i+1); } } } // Update the list of clients if(accsToUpdate.size()> 0) try{ update accsToUpdate; } catch(exception e){ System.debug(''); } isFlagged = false; } } /* Input: We pass in the new and old values of the trigger. Process: Retrieve all the Subsidary clients whose UltimateParent or its ultimateParent's Type has changed and update the Sub-Type Output: N/A Changes: */ public static void updateAccountSubType(Map<Id,Account> mapOfNewAccounts,Map<Id,Account> mapOfOldAccounts,List<Account> accsList) { Set<Id> ultimateParentIds = new Set<Id>(); Set<Id> subsidiaryClientUPIds= new Set<Id>(); Set<Id> subsidiaryClientIds= new Set<Id>(); Map<Id,Account> mapOfUParents; List<Account> accsToUpdate = new List<Account>(); Map<Id,Integer> mapOfaccsToUpdate = new Map<Id,Integer>(); boolean isFlagged = true; Integer i=0; //Flag is validated to ensure that the trigger is executed only once if(isFlagged == true) { //Loop through the list of Accounts being updated and add all the ultimate parent Clients to ultimateParentIds List // and all the subsidiaryClient Ids and their UltimateParent Ids to subsidiaryClientIds and subsidiaryClientUPIds respectively for(Account a : accsList) { //Update the Sub_Type__c of all child clients only when the Sub_Type__c of its UP is changed and not when a new Uparent is created. if((a.Ultimate_Parent__c == true)&& (mapOfOldAccounts!=null)) { if(mapOfOldAccounts.get(a.ID).Sub_Type__c != mapOfNewAccounts.get(a.ID).Sub_Type__c) { //List of UltimateParents whose Sub_Type__c has changed. ultimateParentIds.add(a.ID); } } else { //List of Subsidiary Clients and its corresponding UltimateParentids subsidiaryClientIds.add(a.Id); subsidiaryClientUPIds.add(a.Ultimate_Parent_Client__c); } } //Retrieve all the Subsidiary clients for the UltimateParents whose Sub_Type__c has changed // and add them to the accsToUpdate list if(ultimateParentIds.size() > 0) { for(Account acc1 : [Select Sub_Type__c, Id , Ultimate_Parent_Client__c,Ultimate_Parent__c From Account Where Ultimate_Parent_Client__c in: ultimateParentIds ]) { // Check to see that the client has not been added to the accsToUpdate list if(!mapOfaccsToUpdate.ContainsKey(acc1.Id)) { acc1.Sub_Type__c = mapOfNewAccounts.get(acc1.Ultimate_Parent_Client__c).Sub_Type__c; accsToUpdate.add(acc1); mapOfaccsToUpdate.put(acc1.Id,i+1); } } } if(subsidiaryClientUPIds.size() > 0) { //Retrieve UltimateParentids for all the Subsidiary clients whose Ultimate_parent_client__c has changed mapOfUParents = new Map<Id,Account>([Select Id , Sub_Type__c From Account Where Id in: subsidiaryClientUPIds ]); //Iterate over all the Subsidiary clientsand update the Sub_Type__c field for(Account acc2 : [Select Id,Ultimate_Parent_Client__c,Sub_Type__c From Account Where Id in: subsidiaryClientIds ]) { // Update the Sub_Type__c field for all the subsidiary clients that satisfies //the below condition if((!mapOfaccsToUpdate.containsKey(acc2.Id))&& (mapOfUParents.containsKey(acc2.Ultimate_Parent_Client__c))&& (acc2.Sub_Type__c != mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Sub_Type__c)) { acc2.Sub_Type__c = mapOfUParents.get(acc2.Ultimate_Parent_Client__c).Sub_Type__c; accsToUpdate.add(acc2); mapOfaccsToUpdate.put(acc2.Id,i+1); } } } // Update the list of clients if(accsToUpdate.size()> 0) try{ update accsToUpdate; } catch(exception e){ System.debug(''); } isFlagged = false; } } } ******************** ***************************** test class name:-TestUpdateAccounts *************************** /**Class Name: TestUpdateAccounts.cls Original Author: Prathyusha Uppada, NRC Original Creation Date: 11/16/2010 Original Release: 2.3 Purpose: TestClass for UpdateAccounts.cls Ticket#: 207999 Changes: PU: 01/19/2011:Defect# 218746- Modified the test method childTypeNotEqualsUParentTypeOnInsert so that the AccountMasterTrigger is fired on after insert as well. Before this change in the test data since I am not populating the Client_short_name__c there is a work flow to update the Client shortname which triggers the AccountMasterTrigger on after Update, but if the ClientShortName is pre-populated,the workflow does not update the Clientshortname field resulting in not firing the after update trigger. PU: 03/04/2011:Ticket#219268- When the Sub-Type of an Ultimate parent is updated the sub-type on the corresponding child clients should be updated as well. */ @isTest private class TestUpdateAccounts { /* Input: No input variables Process: 1. Inserted 2 Ultimate Parent Accounts whose Type is 'Other Key Account' and 40 child Accounts whose Ultimate Parent Client is UParent 1. 2. Then we make the following modifications: - Modify the Type of UParent1 to Global Account. - Modify the Ultimate_Parent_Client of the first 20 child clients to UParent2. 3. On Update AccountMasterTrigger.trigger is fired. Output: Validate the Type field on Clients. For the first 20 clients The TYPE should be 'Other Key Account' and the next 20 clients the Type should be 'Global Account' Changes: */ static testMethod void bulkUpdateUPTypeAndUPClient() { List<Account> childAcclist = new List<Account>(); List<Account> ultimateAccountList = new List<Account>(); // Insert 2 Ultimate Parent Accounts whose Type is 'Other Key Account' for(Integer i=0;i<2;i++) { Account uacc= new Account(); uacc.Name='TestUpdateAccounts ultimateAccount'+i; uacc.BillingStreet='TestUpdateAccounts'+i+'Street'; uacc.Client_Short_Name__c ='CTypeUp'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.phone='111111'; uacc.BillingCountry='US'; uacc.BillingCity='TestUpdateAccounts'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Other Key Account'; ultimateAccountList.add(uacc); } insert ultimateAccountList; // Insert child Accounts whose UParent is Uparent1 for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChanged Child'+i; acc.BillingStreet='UPTypeAndUPClientIsChanged Child Street' + i; acc.Client_Short_Name__c ='test1'; acc.BillingState='WI'; acc.phone='111111'; acc.BillingPostalCode='5322'+i; acc.BillingCountry='US'; acc.BillingCity='UPTypeAndUPClientIsChanged City'+i; acc.Ultimate_Parent_Client__c = ultimateAccountList[0].Id; childAcclist.add(acc); } test.startTest(); insert childAcclist; test.stopTest(); List<Account> updateClients = new List<Account>(); //Modify the Type of UParent1 to Global Account and add them to updateClients List. Account updateUPAccount = [SELECT TYPE FROM Account WHERE ID =: ultimateAccountList[0].Id ORDER BY ID]; updateUPAccount.TYPE = 'Global Account'; updateClients.add(updateUPAccount); //Modify the Ultimate_Parent_Client of the first 20 child clients to UParent2 //and add them to updateClients List. for(Account a : [SELECT ID,TYPE,Ultimate_Parent_Client__c FROM Account WHERE ID =: childAcclist ORDER BY ID LIMIT 20] ) { a.Ultimate_Parent_Client__c = ultimateAccountList[1].Id; updateClients.add(a); } //Update the Accounts List update updateClients; //Retrieve all the child accounts and verify the Type // List<Account> accList = [SELECT TYPE FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=0;i<20;i++) System.assertEquals(updateClients[i].Type,'Other Key Account'); for(Integer i=20;i<40;i++) System.assertEquals(updateClients[i].Type,'Global Account'); } /* Input: No input variables Process: 1. Insert an Ultimate Parent Account whose Type is 'Other Key Account' 2.Insert 40 child Accounts whose Ultimate Parent Account equals the above UP and Type is 'Strategic Account' Output: Validate the Type field on Clients. The TYPE of the child accounts should be 'Other Key Account'. Changes: PU 01/19/11 - Updated the test data to populate the ClientshortName field. */ static testMethod void childTypeNotEqualsUParentTypeOnInsert() { List<Account> childAcclist = new List<Account>(); // Insert an Ultimate Parent Accounts whose Type is 'Other Key Account' Account uacc= new Account(); uacc.Name='childTypeNEUParentTypeOnInsert'; uacc.BillingStreet='childTypeNEUParentTypeOnInsertStreet'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.phone='111111'; uacc.BillingCountry='US'; uacc.BillingCity='childTypeNEUParentTypeOnInsertCity'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Other Key Account'; insert uacc; test.startTest(); // Insert child Accounts whose UParent is uacc for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChangedChild'+i; acc.Client_Short_Name__c =('UPTypeAndUPClientIsChangedChild'+i).substring(0,8); acc.BillingStreet='UPTypeAndUPClientIsChangedChildStreet' + i; acc.BillingState='WI'; acc.BillingPostalCode='5322'+i; acc.BillingCountry='US'; acc.phone='111111'; acc.BillingCity='UPTypeAndUPClientIsChangedCity'+i; acc.Ultimate_Parent_Client__c = uacc.Id; acc.Type = 'Strategic Account'; acc.Sub_Type__c ='Corporate'; childAcclist.add(acc); } insert childAcclist; // List<Account> accList = [SELECT TYPE FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=20;i<40;i++) System.assertEquals(childAcclist[i].Type,'Other Key Account'); test.stopTest(); } /* Input: No input variables Process: 1. Insert an Ultimate Parent Account whose Type is 'Other Key Account' 2.Insert 40 child Accounts whose Type is 'Strategic Account'and Ultimate Parent Account equals the above UP Output: Validate the Type field on Clients. The TYPE of the child accounts should be 'Other Key Account'. Changes: */ static testMethod void childTypeNotEqualsUParentTypeOnUpdate() { List<Account> childAcclist = new List<Account>(); List<Account> ultimateAccountList = new List<Account>(); // Insert an Ultimate Parent Accounts whose Type is 'Other Key Account' Account uacc= new Account(); uacc.Name='childTypeNEUParentTypeOnUpdate'; uacc.BillingStreet='childTypeNEUParentTypeOnUpdateStreet'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.phone='111111'; uacc.BillingCountry='US'; uacc.BillingCity='childTypeNEUParentTypeOnUpdateCity'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Other Key Account'; insert uacc; // Insert child Accounts whose UParent is uacc.ID for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChanged Child'+i; acc.BillingStreet='UPTypeAndUPClientIsChangedChildStreet' + i; acc.BillingState='WI'; acc.phone='111111'; acc.BillingPostalCode='5322'+i; acc.BillingCountry='US'; acc.BillingCity='UPTypeAndUPClientIsChanged City'+i; acc.Ultimate_Parent_Client__c =uacc.Id; childAcclist.add(acc); } test.startTest(); insert childAcclist; List<Account> updateClients = new List<Account>(); //Modify the Type from Other Key Account to Strategic Account' //and update the updateClients List. for(Account a : [SELECT ID,TYPE,Ultimate_Parent_Client__c FROM Account WHERE ID =: childAcclist ORDER BY ID LIMIT 20] ) { a.Type = 'Strategic Account'; a.Sub_Type__c = 'National'; updateClients.add(a); } update updateClients; //Retrieve all the child accounts and verify the Type // List<Account> accList = [SELECT TYPE FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=0;i<40;i++) System.assertEquals(updateClients[i].Type,'Other Key Account'); test.stopTest(); } /* Input: No input variables Process: 1. Inserted 2 Ultimate Parent Accounts whose Type is 'Strategic' and SubType is "Corporate" and 40 child Accounts whose Ultimate Parent Client is UParent 1. 2. Then we make the following modifications: - Modify the sub-Type of UParent1 to "International". - Modify the Ultimate_Parent_Client of the first 20 child clients to UParent2. 3. On Update AccountMasterTrigger.trigger is fired. Output: Validate the Type field on Clients. For the first 20 clients The SUB-TYPE should be 'Corporate' and the next 20 clients the Sub-Type should be 'International' Changes: */ static testMethod void bulkUpdateUPSubTypeAndUPClient() { List<Account> childAcclist = new List<Account>(); List<Account> ultimateAccountList = new List<Account>(); // Insert 2 Ultimate Parent Accounts whose Sub-Type is 'Corporate' for(Integer i=0;i<2;i++) { Account uacc= new Account(); uacc.Name='TestUpdateAccounts ultimateAccount'+i; uacc.BillingStreet='TestUpdateAccounts'+i+'Street'; uacc.Client_Short_Name__c ='CTypeUp'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.BillingCountry='US'; uacc.phone='111111'; uacc.BillingCity='TestUpdateAccounts'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Strategic Account'; uacc.Sub_Type__c = 'Corporate'; ultimateAccountList.add(uacc); } insert ultimateAccountList; // Insert child Accounts whose UParent is Uparent1 for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChanged Child'+i; acc.BillingStreet='UPTypeAndUPClientIsChanged Child Street' + i; acc.Client_Short_Name__c ='test1'; acc.BillingState='WI'; acc.BillingPostalCode='5322'+i; acc.BillingCountry='US'; acc.phone='111111'; acc.BillingCity='UPTypeAndUPClientIsChanged City'+i; acc.Ultimate_Parent_Client__c = ultimateAccountList[0].Id; childAcclist.add(acc); } test.startTest(); insert childAcclist; List<Account> updateClients = new List<Account>(); //Modify the SubType of UParent1 to "International" and add them to updateClients List. Account updateUPAccount = [SELECT TYPE FROM Account WHERE ID =: ultimateAccountList[0].Id ORDER BY ID]; updateUPAccount.Sub_Type__c = 'International'; updateClients.add(updateUPAccount); //Modify the Ultimate_Parent_Client of the first 20 child clients to UParent2 //and add them to updateClients List. for(Account a : [SELECT ID,Sub_Type__c,Ultimate_Parent_Client__c FROM Account WHERE ID =: childAcclist ORDER BY ID LIMIT 20] ) { a.Ultimate_Parent_Client__c = ultimateAccountList[1].Id; updateClients.add(a); } //Update the Accounts List update updateClients; //Retrieve all the child accounts and verify the Sub-Type // List<Account> accList = [SELECT Sub_Type__c FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=0;i<20;i++) System.assertEquals(updateClients[i].Sub_Type__c,'Corporate'); for(Integer i=20;i<40;i++) System.assertEquals(updateClients[i].Sub_Type__c,'International'); test.stopTest(); } /* Input: No input variables Process: 1. Insert an Ultimate Parent Account whose Type is 'Strategic Account' and Sub Type is "Corporate" 2.Insert 40 child Accounts whose Ultimate Parent Account equals the above UP, Type is 'Global Account' and SubType = 'International' Output: Validate the SubType field on child Clients. The Sub-TYPE of the child accounts should be 'Corporate'. */ static testMethod void childSubTypeNotEqualsUParentSubTypeOnInsert() { List<Account> childAcclist = new List<Account>(); // Insert an Ultimate Parent Accounts whose Type is 'Strategic' and Sub-Type is 'Corporate' Account uacc= new Account(); uacc.Name='childTypeNEUParentTypeOnInsert'; uacc.BillingStreet='childTypeNEUParentTypeOnInsertStreet'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.BillingCountry='US'; uacc.phone='111111'; uacc.BillingCity='childTypeNEUParentTypeOnInsertCity'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Strategic Account'; uacc.Sub_Type__c = 'Corporate'; insert uacc; test.startTest(); // Insert child Accounts whose UParent is uacc for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChangedChild'+i; acc.Client_Short_Name__c =('UPTypeAndUPClientIsChangedChild'+i).substring(0,8); acc.BillingStreet='UPTypeAndUPClientIsChangedChildStreet' + i; acc.BillingState='WI'; acc.BillingPostalCode='5322'+i; acc.phone='111111'; acc.BillingCountry='US'; acc.BillingCity='UPTypeAndUPClientIsChangedCity'+i; acc.Ultimate_Parent_Client__c = uacc.Id; acc.Type = 'Global Account'; acc.Sub_Type__c = 'International'; childAcclist.add(acc); } insert childAcclist; // List<Account> accList = [SELECT TYPE,Sub_Type__c FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=20;i<40;i++) System.assertEquals(childAcclist[i].Sub_Type__c,'Corporate'); test.stopTest(); } /* Input: No input variables Process: 1. Insert an Ultimate Parent Account whose Type is 'Other Key Account' 2.Insert 40 child Accounts whose Ultimate Parent Account equals the above UP 3. Update the Type ='Strategic Account'and Sub-Type = 'National' on the child accounts Output: Validate the Type field on Clients. The Sub-TYPE of the child accounts should be null. Changes: */ static testMethod void childSubTypeNotEqualsUParentSubTypeOnUpdate() { List<Account> childAcclist = new List<Account>(); List<Account> ultimateAccountList = new List<Account>(); // Insert an Ultimate Parent Accounts whose Type is 'Other Key Account' Account uacc= new Account(); uacc.Name='childTypeNEUParentTypeOnUpdate'; uacc.BillingStreet='childTypeNEUParentTypeOnUpdateStreet'; uacc.BillingState='CA'; uacc.BillingPostalCode='12345'; uacc.phone='111111'; uacc.BillingCountry='US'; uacc.BillingCity='childTypeNEUParentTypeOnUpdateCity'; uacc.Ultimate_Parent__c = true; uacc.Type = 'Strategic Account'; uacc.Sub_Type__c = 'Corporate'; insert uacc; test.startTest(); // Insert child Accounts whose UParent is uacc.ID for(Integer i=0;i<40;i++) { Account acc = new Account(); acc.Name='UPTypeAndUPClientIsChanged Child'+i; acc.BillingStreet='UPTypeAndUPClientIsChangedChildStreet' + i; acc.BillingState='WI'; acc.BillingPostalCode='5322'+i; acc.phone='111111'; acc.BillingCountry='US'; acc.BillingCity='UPTypeAndUPClientIsChanged City'+i; acc.Ultimate_Parent_Client__c =uacc.Id; childAcclist.add(acc); } insert childAcclist; List<Account> updateClients = new List<Account>(); //Update the Type from Other Key Account to Strategic Account and Sub-Type to 'National'' for(Account a : [SELECT ID,TYPE,Ultimate_Parent_Client__c,Sub_Type__c FROM Account WHERE ID =: childAcclist ORDER BY ID LIMIT 20] ) { a.Sub_Type__c = 'National'; updateClients.add(a); } update updateClients; //Retrieve all the child accounts and verify the Type //List<Account> accList = [SELECT TYPE,Sub_Type__c FROM Account WHERE ID in : childAcclist order by id]; for(Integer i=0;i<40;i++) System.assertEquals('Corporate',updateClients[i].Sub_Type__c); test.stopTest(); } }
- Ramesh Guduru
- December 10, 2015
- Like
- 0
profile not visible while creating new user
I have 2 users in one profile, User 1 with Role : ' GLOBAL_HQ', & User 2 with Role : MP NA Manpower'
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
- Ramesh Guduru
- December 10, 2015
- Like
- 1
profile not visible while creating new user
I have 2 users in one profile, User 1 with Role : ' GLOBAL_HQ', & User 2 with Role : MP NA Manpower'
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
When I login through user 1 I am able to see xyz profile, but I when I logging through user 2 I can’t see the xyz profile.
I do not understand, WHY I am unable to find the xyz Profile for the User 2 ? Can anyone help me please.
My profile is system admin.
- Ramesh Guduru
- December 10, 2015
- Like
- 1