You need to sign in to do that
Don't have an account?
Madeline Little
Visualforce Internal Server Error with custom controller
Hello, I've been googling around for the solution to this problem and most of what I'm getting is that there are frequently bugs in salesforce as a whole that causes internal server errors, but I wanted to ask if it was a problem with my code before I give up on this solution. The error message is below:
I'm currently trying to code a visualforce page with a button that will execute some code and display the output in a table. Here is the controller:
I've had to comment some things out to prevent compiletime errors from cropping up, but again, I'm not sure if the internal server error is a runtime error or a salesforce bug. I've been removing or commented out pieces of code in an attempt to fix the error, but nothing has worked yet. Is there anything glaringly wrong with this? Thanks.
I'm currently trying to code a visualforce page with a button that will execute some code and display the output in a table. Here is the controller:
public class GuideAssign { //define variables public Guide_n__c[] guides; public Tour__c[] tours { get; set; } public Tour__c[] toursForDisplay { get; set; } public Availability__c[] assignavails; public Tour__c ticket; public Integer needed; public Integer rand; //private boolean busseason; //determine season from day public void assignTours(){ //do more tickets need to be assigned? needed = tours.size(); if(needed > 0){ //if yes for(Integer i = 0; i < tours.size(); i++){ //determine if ticket is for today ticket = tours[i]; //if yes if(ticket.Event_Date__c == date.today()){ //get guides with no assignments during that time slot and whose assignments end before and start after that time slot by the overlap amount assignavails = [SELECT A_Date__c,Guide__c,Time_End__c,Time_Start__c FROM Availability__c WHERE A_Date__c = :ticket.Event_Date__c AND Time_Start__c > :ticket.Event_Time__c AND RandAlgoData__c = :true]; //randomly select a guide rand = Math.mod(Math.round(Math.random()*1000), needed); //assign the guide to a ticket ticket.Guide__c = assignavails.get(rand).Guide__c; //send the guide and the office a notification and email }else{ //else //get guides with no assignments during that time slot and whose assignments end before and start after that time slot by the overlap amount assignavails = [SELECT A_Date__c,Guide__c,Time_End__c,Time_Start__c FROM Availability__c WHERE A_Date__c = :ticket.Event_Date__c AND Time_Start__c > :ticket.Event_Time__c AND RandAlgoData__c = :true]; //randomly select a guide rand = Math.mod(Math.round(Math.random()*1000), needed); //assign the guide to a ticket ticket.Guide__c = assignavails.get(rand).Guide__c; } //reset variables needed = needed - 1; assignavails = null; rand = null; } } } public GuideAssign(){ tours = [SELECT Duration__c,Event_Date__c,Event_Time__c,Guide__c FROM Tour__c WHERE Guide__c = null]; toursForDisplay = [SELECT Duration__c,Event_Date__c,Event_Time__c,Guide__c FROM Tour__c WHERE Guide__c = :null LIMIT 500]; //guides = [SELECT Name,LBG__c,LBG_Licence_Type__c,LBG_Max_Daily_Resvs__c,LBG_Max_Overlap__c,LBG_Min_Overlap__c,LBG_Reservation_Type__c FROM Guide_n__c]; //assignTours(); } }And the visualforce page:
<apex:page controller="GuideAssign"> <apex:pageBlock> <apex:pageBlockSection> <apex:form> <!--<apex:commandButton action="{!assignTours}"/>--> </apex:form> </apex:pageBlockSection> <apex:pageBlockTable value="{!toursForDisplay}" var="t"> <apex:column value="{!t.Event_Date__c}"/> <apex:column value="{!t.Event_Time__c}"/> <apex:column value="{!t.Duration__c}"/> <apex:column value="{!t.Guide__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
I've had to comment some things out to prevent compiletime errors from cropping up, but again, I'm not sure if the internal server error is a runtime error or a salesforce bug. I've been removing or commented out pieces of code in an attempt to fix the error, but nothing has worked yet. Is there anything glaringly wrong with this? Thanks.