You need to sign in to do that
Don't have an account?
cloudtrip
NEED HELP PLEASE - to deploy to production by tomorrow please help - currently at 65%
Here is the start of my class method:
___________________________________________________________________
public class TradeCalendarController { // Set class variable public Trade_Calender__c nitch; public Trade_Events__c trade; //set List variables Trade_Events__c[] recList; Trade_Events__c[] recDelete; //STANDARD CONTROLLER SECTION public TradeCalendarController(Trade_Calender__c item){ this.nitch = item; } public String getParam(String name) { return ApexPages.currentPage().getParameters().get(name); } public TradeCalendarController(ApexPages.StandardController stdController) { this.nitch = (Trade_Calender__c)stdController.getRecord(); recList = [ Select Trade_Calender__c, Name, Account__c, Year__c, Category__c, Vendor__c, Period__c, New_Pack__c, Promo_Price__c, Merch_Type__c, More_than_1_event_in_period__c, Event_start_in_prior_period__c, Events_del__c From Trade_Events__c WHERE Trade_Calender__c = :nitch.id order by Pack__c, period__c]; if(recList.size()==0){ newRow(); } } // returns Record information public Trade_Events__c[] getRecList() { return recList; } // Inserts all changes into records public pagereference saveChanges() { update nitch; try { upsert recList; } catch (DMLException e){ ApexPages.addMessages(e); return null; } // after save refreshes data on page recList = [ Select Trade_Calender__c, Name, Account__c, Year__c, Category__c, Vendor__c, Period__c, New_Pack__c, Promo_Price__c, Merch_Type__c, More_than_1_event_in_period__c, Event_start_in_prior_period__c, Events_del__c From Trade_Events__c WHERE Trade_Calender__c = :nitch.id order by Pack__c, period__c]; getRecList(); return null; } // Inserts a new row public pagereference newRow() { Trade_Events__c d = new Trade_Events__c(); for(Trade_Calender__c trade:[Select id, name, account__c, Year__c from Trade_Calender__c where id = :nitch.id]){ d.Account__c = trade.account__c; d.Name = trade.name; d.Year__c = trade.Year__c; d.Trade_Calender__c = nitch.id; recList.add(d); } return null; } // clones a row public PageReference cl() { String delid = getParam('delid'); Trade_Events__c d = new Trade_Events__c(); for(Trade_Events__c trade:[Select id, Pack__c, Vendor__c, Merch_Type__c, Promo_Price__c, Category__c, name, account__c, Year__c from Trade_Events__c where Trade_Calender__c=:nitch.id and ID=:delid]){ d.Account__c = trade.account__c; d.Name = trade.name; d.Year__c = trade.Year__c; d.Trade_Calender__c = nitch.id; d.New_Pack__c = trade.Pack__c; d.Merch_Type__c = trade.Merch_Type__c; d.Pack__c ='a0y40000000LzEK'; d.Promo_Price__c = trade.Promo_Price__c; d.Category__c = trade.Category__c; d.Vendor__c = trade.Vendor__c; recList.add(d); } return null; } // delete row public PageReference del() { try { String delid = getParam('delid'); Trade_Events__c event = [SELECT Id FROM Trade_Events__c WHERE ID=:delid]; DELETE event; } catch (Exception e) { ApexPages.addMessages(e); } // after del refreshes the data on page recList = [ Select Trade_Calender__c, Name, Account__c, Year__c, Category__c, Vendor__c, Period__c, New_Pack__c, Promo_Price__c, Merch_Type__c, More_than_1_event_in_period__c, Event_start_in_prior_period__c, Events_del__c From Trade_Events__c WHERE Trade_Calender__c = :nitch.id order by Pack__c, period__c]; getRecList(); return null; } }
Here is my test method and cant figure out why it wont pass....
If you could tell us what error you are getting, it will speed up a response...
and also please post code using the code block function in the forum. I makes it 100x easier to read.
Here is the correct debug and coverage log, sorry I am working on several test methods:
Hope that helps, any assistance is greatly appreciated.
You're never setting the Cost_Share_Management__c field.
Does anyone have any ideas?
You post right above it made it sound like your situation was resolved........
Also you said you posted the "wrong one". In order to help we need accurate information...
Everything posted below is correct, I removed the incorrect information. Sorry for the confusion.
In your test case you are not setting the parameter for delid which is causing all your select statements that use IN :delid to return no rows.
in your test, after you set the pagereference add the line:
I did add the following but my code is still at 63%
system.currentPageReference().getParameters().put('delid', tc.Id);
Look at the debug log....
1. Are the Select statements still returning 0 rows?
2. System.debug the delID and see what it is using for that value
3. Is nischID being set properly, system.debug that as well since you are pulling records based on both.
post up the new debug log (with both IDs printed out and the section of your code where you placed the new line please.
Does this help?
Yes and you have a lot going on here....
Without being able to talk through it I cannot get my head around it as I am a do and fix kind of person....but
This is causing you some trouble here. You are specifying an ID for a new record and you cannot do that as it is assigned upon insert...
Also, the select statements where you used ID In :nisch.id and id In :delID are still returning 0 rows. I am not sure if it is due to the errors above since you were unable to insert the record or not.
Also, where you set the parameter, the current page reference is set to the pagereference right above it, what about the other two page references in the 2 lines above that, do they need the delID set?
Troubleshoot one item at a time. I would do it like this:
1. Fix the insert record so that it actually gets inserted
2. Set the correct parameters for each pager reference
3. Find out what the nisch.id and delID are when the select statement actually gets called and make sure they are what you want.
there may be more going on here so once you get those fixed, we can see what else needs updated.
If you make Transactions with the financial instruments offered on this Website, you might incur substantial losses or even lose everything in your Account.
https://vfxalert.com/mobile?utm_campaign=SEO&utm_source=forums&utm_content=vfxalert_mobile/