You need to sign in to do that
Don't have an account?
MrHammy
missing something in my if statement
still learning and getting better but why is the if statment not working in this controller? ( know that data is the same, just need it to work at all . i get Error: MultiRow Compile Error: expecting right curly bracket, found 'if' at line 16 column 2
public class MultiRow { public List<multiRowContact> Contacts { get; set; } String chainname = ApexPages.currentPage().getParameters().get('name') ; String prog = ApexPages.currentPage().getParameters().get('pg') ; public MultiRow() { LoadData(); } if(prog == 'WM Synergy'){ string filter = '0128000000020mOAAQ'; //'WM Synergy } else { string filter = '0128000000020mOAAQ'; //'WM Synergy } public PageReference Save() { for (multiRowContact MRC : Contacts) { MRC.Save(); } LoadData(); return null; } private void LoadData() { Contacts = new List<multiRowContact>(); for (List<erp_data__c> cs : [SELECT name, Account__c ,Acct_RT_Name__c, Chain__c,Id, Program__c, RecordTypeId ,updatechain__c , updatetowhat__c FROM ERP_Data__c WHERE Chain__c = :chainname and RecordTypeId = :filter limit 125]) { for (erp_data__c c : cs) { multiRowContact MRC = new multiRowContact(); MRC.ID = c.ID; MRC.Checked = true; MRC.Name = c.Name; MRC.Program = c.Program__c; MRC.account = c.Account__c ; MRC.updatetowhat = c.updatetowhat__c; Contacts.add(MRC); } } } private class multiRowContact { String prog = ApexPages.currentPage().getParameters().get('pg') ; String idx = ApexPages.currentPage().getParameters().get('idx') ; public String ID { get; set; } public String Name { get; set; } public String Account { get; set; } public String updatetowhat{ get; set; } public String Program { get; set; } public Boolean Checked { get; set; } public void Save() { if (Checked) { System.debug('Saving...ID: ' + ID); erp_data__c c = [SELECT c.updatetowhat__c FROM erp_data__c c WHERE c.ID = :ID LIMIT 1]; c.updatetowhat__c = prog; update c; Participating_Branch_Locations__c newpbl = new Participating_Branch_Locations__c (Account__c = Account ,Distributor_Program__c = idx); try { insert newpbl; } catch (DmlException e) { // Process exception here } } } } }
All Answers
Your IF statement isn't in a function, so it will not compile. Move the declaration to the class level, and the initialization to the constructor. In general, you should always be initializing within the constructor, not in the declaration area. Here's a basic restructuring that will work:
now the variable is just empty, i have updated to this filling out some of the other else if items but its just returning nothing. if i declare the filter variable it works fin but no luck with the if