You need to sign in to do that
Don't have an account?
sylar20
New items are not getting added to the list which is the part of Inner class list.
New items are not getting added to the list which is the part of Inner class list.
Apex Class :
public with sharing class Pricing_New { public Pricing2__c objPricing; public Pricing2__c objPricingNew; public list<SPackage> lstPackage {get;set;} public String strPackageNumber {get;set;} public integer intPackageNumber; public list<Service_Level__c> lstSL; public map<string,Service_Level__c> mpSL; public Pricing_New(ApexPages.StandardController stdController) { this.objPricing = (Pricing2__c)stdController.getRecord(); lstSL = [Select Name__c, Level_6_Price_Low__c, Level_6_Price_High__c, Level_6_Note__c, Level_6_Checks_Low__c, Level_6_Checks_High__c, Level_5_Price_Low__c, Level_5_Price_High__c, Level_5_Note__c, Level_5_Checks_Low__c, Level_5_Checks_High__c, Level_4_Price_Low__c, Level_4_Price_High__c, Level_4_Note__c, Level_4_Checks_Low__c, Level_4_Checks_High__c, Level_3_Price_Low__c, Level_3_Price_High__c, Level_3_Note__c, Level_3_Checks_Low__c, Level_3_Checks_High__c, Level_2_Price_Low__c, Level_2_Price_High__c, Level_2_Note__c, Level_2_Checks_Low__c, Level_2_Checks_High__c, Level_1_Price_Low__c, Level_1_Price_High__c, Level_1_Note__c, Level_1_Checks_Low__c, Level_1_Checks_High__c, COGS__c From Service_Level__c ]; mpSL = new map<string,Service_Level__c>([Select Name__c, Level_6_Price_Low__c, Level_6_Price_High__c, Level_6_Note__c, Level_6_Checks_Low__c, Level_6_Checks_High__c, Level_5_Price_Low__c, Level_5_Price_High__c, Level_5_Note__c, Level_5_Checks_Low__c, Level_5_Checks_High__c, Level_4_Price_Low__c, Level_4_Price_High__c, Level_4_Note__c, Level_4_Checks_Low__c, Level_4_Checks_High__c, Level_3_Price_Low__c, Level_3_Price_High__c, Level_3_Note__c, Level_3_Checks_Low__c, Level_3_Checks_High__c, Level_2_Price_Low__c, Level_2_Price_High__c, Level_2_Note__c, Level_2_Checks_Low__c, Level_2_Checks_High__c, Level_1_Price_Low__c, Level_1_Price_High__c, Level_1_Note__c, Level_1_Checks_Low__c, Level_1_Checks_High__c, COGS__c From Service_Level__c ]); intPackageNumber = 1; strPackageNumber = 'Package ' + intPackageNumber; objPricingNew = new Pricing2__c(); lstPackage = new list<SPackage>(); Service_Package__c objSP1 = new Service_Package__c(); list<Service> lstSer = new list<Service>(); lstSer.add(new Service('',0,0,0,0,0,0)); lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber)); } public PageReference addMorePackages() { intPackageNumber = intPackageNumber + 1; strPackageNumber = 'Package ' + intPackageNumber; Service_Package__c objSP1 = new Service_Package__c(); list<Service> lstSer = new list<Service>(); lstSer.add(new Service('',0,0,0,0,0,0)); lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber)); return null; } public PageReference addMoreServices() { String strPackageNumber = ApexPages.currentPage().getParameters().get('PkgNumber'); integer intI = Integer.valueOf(strPackageNumber); if(intI>0) { Service objSer = new Service(); objSer.strServiceName = ''; objSer.dbPrice = 0; objSer.intVolume = 0; objSer.dbCOGS = 0; objSer.dbMargin = 0; objSer.dbLow = 0; objSer.dbHigh = 0; lstPackage[intI-1].lstService.add(objSer); system.debug('llllllll'+lstPackage[intI-1].lstService.size()); } return null; } public PageReference SavePricing() { return null; } public PageReference showServiceBLP() { return null; } public List<SelectOption> getServiceNames() { List<SelectOption> options = new List<SelectOption>(); set<string> stService = new set<string>(); options.add(new SelectOption('', '-None-')); stService.add('-None-'); for(Service_Level__c sl : lstSL) { if(!stService.contains(sl.Id)) { options.add(new SelectOption(sl.Id, sl.Name__c)); stService.add(sl.Id); } } return options; } public List<SelectOption> getProfileAvailability() { List<SelectOption> options = new List<SelectOption>(); Schema.DescribeFieldResult fieldResult = Service_Package__c.Profile_Availability__c.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); options.add(new SelectOption('', '-None-')); for( Schema.PicklistEntry f : ple) { options.add(new SelectOption(f.getLabel(), f.getValue())); } system.debug('........ '+options); return options; } public class SPackage { public Service_Package__c objSP {get;set;} public double dbSumLowPrice {get;set;} public double dbSumHighPrice {get;set;} public string strLabel {get;set;} public List<Service> lstService {get;set;} public Spackage() { } public SPackage(Service_Package__c sp, double low, double high, List<Service> lstS, string strLbl) { objSP = sp; dbSumLowPrice = low; dbSumHighPrice = high; lstService = lstS; strLabel = strLbl; } } public class Service { public String strServiceName {get;set;} public double dbPrice {get;set;} public integer intVolume {get;set;} public double dbCOGS {get;set;} public double dbMargin {get;set;} public double dbLow {get;set;} public double dbHigh {get;set;} public Service() { } public Service(String SN, double price, integer vol, double cogs, double margin, double low, double high) { strServiceName = SN; dbPrice = price; intVolume = vol; dbCOGS = cogs; dbMargin = margin; dbLow = low; dbHigh = high; } } }
<apex:page standardcontroller="Pricing2__c" extensions="Pricing_New"> <apex:form > <apex:pageBlock title="Pricing" id="mainPB"> <apex:pageblockSection columns="2"> <apex:pageblocksectionitem > <apex:outputLabel value="Account" /> <apex:inputfield value="{!Pricing2__c.AccountId__c}" /> </apex:pageblocksectionitem> <apex:pageblocksectionitem > <apex:outputLabel value="Number of Checks" /> <apex:inputfield value="{!Pricing2__c.Checks__c}" onchange="showLowHighBLP()" required="true"/> </apex:pageblocksectionitem> </apex:pageblockSection> <br/> <apex:repeat value="{!lstPackage}" var="P"> <apex:pageBlock title="{!P.strLabel}" > <apex:pageBlockSection columns="2"> <apex:pageBlockSectionItem > <apex:outputLabel value="Profile Name" /> <apex:inputText value="{!P.objSP.Profile_Name__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Profile Availability" /> <apex:selectList value="{!P.objSP.Profile_Availability__c}" size="1"> <apex:selectOptions value="{!ProfileAvailability}" /> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Enable Package Pricing" /> <apex:inputCheckbox value="{!P.objSP.Enable_Package_Pricing__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Add Maiden / Alias search" /> <apex:inputCheckbox value="{!P.objSP.Add_Maiden_Alias_search__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Profile Price " /> <apex:inputText value="{!P.objSP.Profile_Price__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Maiden / Alias Price" /> <apex:inputText value="{!P.objSP.Maiden_Alias_Price__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="true"> <apex:outputLabel value="BLP Low Level" /> <apex:outputLabel value="{!P.dbSumLowPrice}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="true"> <apex:outputLabel value="BLP High Level" /> <apex:outputLabel value="{!P.dbSumHighPrice}" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> <br/> <table width="100%" style="border-collapse:collapse;" cellpadding="4"> <tr> <th width="25%" style="border-collapse:collapse;background-color:#8fc800;"> <center>Service</center> </th> <th width="15%" style="border-collapse:collapse;background-color:#8fc800;"> <center>Volume</center> </th> <th width="15%" style="border-collapse:collapse;background-color:#8fc800;"> <center>Price</center> </th> <th width="15%" style="border-collapse:collapse;background-color:#8fc800;"> <center>BLP Low Level</center> </th> <th width="15%" style="border-collapse:collapse;background-color:#8fc800;"> <center>BLP High Level</center> </th> <th width="15%" style="border-collapse:collapse;background-color:#8fc800;"> <center>Margin</center> </th> </tr> <apex:repeat value="{!P.lstService}" var="S"> <tr> <td width="25%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:selectList value="{!S.strServiceName}" size="1" onchange="showLowHighBLP()"> <apex:selectOptions value="{!ServiceNames}" /> </apex:selectList> </center> </td> <td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:inputText value="{!S.intVolume}" onchange="showLowHighBLP()" /> </center> </td> <td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:inputText value="{!S.dbPrice}" onchange="showLowHighBLP()" /> </center> </td> <td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:outputLabel value="{!S.dbLow}" /> </center> </td> <td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:outputLabel value="{!S.dbHigh}" /> </center> </td> <td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;"> <center> <apex:outputLabel value="{!S.dbMargin}" /> </center> </td> </tr> </apex:repeat> </table> <br/> <center><Button onclick="addServices('{!P.strLabel}')" >Add More Services</Button></center> </apex:pageBlock> </apex:repeat> <apex:commandButton value="Add More Package" action="{!addMorePackages}" /> <apex:pageblockButtons > <apex:commandButton value="Save Pricing" action="{!SavePricing}" /> </apex:pageblockButtons> </apex:pageBlock> <apex:actionFunction name="showServiceBLP" action="{!showServiceBLP}" rerender="mainPB" /> <apex:actionFunction name="addMoreServices" action="{!addMoreServices}" rerender="mainPB" > <apex:param name="PkgNumber" value="" /> </apex:actionFunction> </apex:form> <script> function showLowHighBLP() { showServiceBLP(); } function addServices(myPackage) { var pac = myPackage; var para = pac.substring(8); addMoreServices(para); } </script> </apex:page>
Is this when adding services? What do you see in the debug output?
Yes, the services are not getting added... there is no problem with add More Package thing...
There is no exception, checked debug log for it and I m getting a correct package number in debug log..
Thanks in advance
If you add some more debug, what size is the list before and after you have added the new service? I.e. is it zero and changes to 1?
After the follow code of contructor gets executed, its size is 1
Service_Package__c objSP1 = new Service_Package__c();
list<Service> lstSer = new list<Service>();
lstSer.add(new Service('',0,0,0,0,0,0));
lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber));
system.debug('lllll........'+lstPackage[0].lstService.size()+'......');
After execution of following addMoreServices() method for first time its size changes to 2,, then its size remains constant to 2 even after calling the addMoreServices() several time on click of button
public PageReference addMoreServices()
{
String strPackageNumber = ApexPages.currentPage().getParameters().get('PkgNumber');
integer intI = Integer.valueOf(strPackageNumber);
if(intI>0)
{
Service objSer = new Service();
objSer.strServiceName = '';
objSer.dbPrice = 0;
objSer.intVolume = 0;
objSer.dbCOGS = 0;
objSer.dbMargin = 0;
objSer.dbLow = 0;
objSer.dbHigh = 0;
lstPackage[intI-1].lstService.add(objSer);
system.debug('lllll....'+lstPackage[intI-1].lstService.size()+'.......');
}
}
Thanks in advance..
Is it a bug in Salesforce ????
Hi Bob,
Is there any alternative way to achieve this requirement ?
Thanks.
I can't see why that wouldn't work to be honest. I'd be inclined to add further debug to dump out the package id and the contents of the list before and after you add the new element, to check that you are hitting the same package each time.
Hi Bob,
I made few changes to the code, still not happening.
have attached debug at the bottom.
Thanks
Debug log :
Hi Bob,
The following method gets called every time there is a change in number of checks, volume, price Textboxes or service picklist.. will this affect the desired output ?
Thanks.
I smell bugs on the cloud