• Prash2
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
Hello,

We have sControl that's used in a custom button on Account page. The sControl collects some data from the form and sends out an email. The sControl all of sudden stopped sending emails a few months ago. No changes were made to sControl itself. We need assistence from sControl expert in identifying what might have caused the issue and if any changes need to be made to sControl. Unfortunately, I never worked in sControls and could always create a new VF pge to accomplish this. However, it would be great if someone can point out if there's something wrong and can be easily adjusted. I am pasting the sControl code below. Thanks, Prashant

sControl Code
----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Product Selection</title>
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/css/assistive.css" type="text/css" media="aural,braille,embossed" rel="stylesheet" >
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script type="text/javascript" src="/js/functions.js"></script>
<script language="javascript" type="text/javascript">

function initPage() {
sforceClient.useCookies = true;
//sforceClient.registerInitCallback(setup);
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
setTimeout("setup()",50);
}

// main setup entry point
function setup() {

}


function doSendEmail()
{

//debugger;

var ToAddress ="";
var AdditionalToAddress = "{!User.Email}";



if("omar@reisys.com" != AdditionalToAddress)
{
AdditionalToAddress = 'SalesForceActionLine@genworth.com';
}

var OpportunitId="";
var locationStr="";
var newESISessionStatus="";
var InstrNotes="";
var eventIdStr = "";
var CCAddress = "";
var BCCAddress ="{!User.Email}";
var DateDisplay="";



var userFirstName = "";
var userLastName = "";
var url = "/email/author/emailauthor.jsp?rtype=003&save=1&p2=" +ToAddress + "&p24=" +AdditionalToAddress +"&p4=" + CCAddress +"&p5=" +BCCAddress
var Subject=returnConstructedEmailSubject();


var Body = returnConstructedEmailBody();
Subject = returnConstructedEmailSubject();
//alert(Subject + "\n "+Body);
url=url + "&p6=" +escape(Subject)+"&p23=" +escape(Body);
var _xml = new Sforce.XmlHttp();
_xml.req.open('POST', url,false);

_xml.req.send( Body );
var resp = _xml.req;
if(resp.statusText=='OK')
{
alert("Successfully sent the email");
jumpback("/{!Account.Id}")
}else
{
alert("The email notification failed.");
}

}


function returnConstructedEmailSubject()
{
var subjStr = "Address change request for the account {!Account.Name}";
return subjStr;
}

function returnConstructedEmailBody()
{
//alert(document.addressForm.new_street_1.value);
var openB = "<b>";
var closeB = "</b>"
var openP = "<p>";
var closeP = "</p>";
var brStr="<br>";
var orgBNumberStr = "{!Account.Branch_Org__c}";
if(orgBNumberStr != '' && orgBNumberStr != null)
{
orgBNumberStr = "{!Account.Branch_Org__c} - ";
}
var bodyStr = brStr;
bodyStr = bodyStr+"{!User.Name} has requested the following change for "+closeB+orgBNumberStr+"{!Account.Name}:"+ brStr;


bodyStr = bodyStr+brStr + returnAddressBodypart('Mailing Address :', "{!Account.BillingStreet}","{!Account.BillingCity}", "{!Account.BillingState}", "{!Account.BillingPostalCode}",
document.addressForm.new_m_street_1.value,document.addressForm.new_m_city.value,
document.addressForm.new_m_state.value, document.addressForm.new_m_zip.value);
//alert(bodyStr1);

bodyStr = bodyStr+brStr + returnAddressBodypart('Street Address :', "{!Account.ShippingStreet}","{!Account.ShippingCity}", "{!Account.ShippingState}", "{!Account.ShippingPostalCode}",
document.addressForm.new_s_street_1.value,document.addressForm.new_s_city.value,
document.addressForm.new_s_state.value, document.addressForm.new_s_zip.value);

bodyStr = bodyStr+brStr + returnPhoneBodypart('Phone & Fax :',"{!Account.Phone}",document.addressForm.new_phone.value ,"{!Account.Fax}",document.addressForm.new_fax.value);

/*bodyStr = bodyStr +brStr+""+openB+"From --";
bodyStr = bodyStr+""+closeB+""+brStr+"Street: {!Account.BillingStreet}"+brStr+"City: {!Account.BillingCity}"+brStr+"State: {!Account.BillingState}"+brStr+"Zip: {!Account.BillingPostalCode} "+brStr+"Phone: {!Account.Phone}"+brStr+"Fax: {!Account.Fax}"+brStr;
bodyStr = bodyStr +""+openB+""+brStr+"To --"+closeB+""+brStr;
bodyStr = bodyStr +"Street: "+document.addressForm.new_street_1.value +brStr+"City: "+document.addressForm.new_city.value+""+brStr+"State: "+document.addressForm.new_state.value+""+brStr+"Zip: "+document.addressForm.new_zip.value+""+brStr+"Phone: "+document.addressForm.new_phone.value+brStr+"Fax: "+document.addressForm.new_fax.value+brStr;
bodyStr = bodyStr +""+closeP;*/
//alert(bodyStr);
return bodyStr;
}


function returnAddressBodypart(addName, frStreet,frCity, frState, frZip, toStreet,toCity, toState, toZip)
{

var bodyStr = "";
bodyStr = addName + "\n";
bodyStr = bodyStr +"-----------------"+ "\n";
bodyStr = bodyStr + "From---" + "\n";
bodyStr = bodyStr + "Street: " + frStreet + "\n" ;
bodyStr = bodyStr + "City : " + frCity + "\n" ;
bodyStr = bodyStr + "State : " + frState + "\n" ;
bodyStr = bodyStr + "Zip : " + frZip + "\n" ;
bodyStr = bodyStr + "\n";

bodyStr = bodyStr + "To---" + "\n";
bodyStr = bodyStr + "Street: " + toStreet + "\n" ;
bodyStr = bodyStr + "City : " + toCity + "\n" ;
bodyStr = bodyStr + "State : " + toState + "\n" ;
bodyStr = bodyStr + "Zip : " + toZip + "\n" ;
return bodyStr;
}


function returnPhoneBodypart(addName,frPhone, toPhone, frFax, toFax)
{
var bodyStr = "";
bodyStr = addName + "\n";
bodyStr = bodyStr +"-----------------"+ "\n";
bodyStr = bodyStr + "From---" + "\n";
bodyStr = bodyStr + "Phone : " + frPhone + "\n" ;
bodyStr = bodyStr + "Fax : " + frFax + "\n" ;
bodyStr = bodyStr + "To---" + "\n";
bodyStr = bodyStr + "Phone : " + toPhone + "\n" ;
bodyStr = bodyStr + "Fax : " + toFax + "\n" ;
bodyStr = bodyStr + "\n";
return bodyStr;
}
function jumpbackToAccount()
{ jumpback("/{!Account.Id}"); }

function jumpback(retUrl)
{ window.parent.parent.location.href = retUrl; }

</script>

</head>
<body onload="javascript:initPage();" class="account editPage" >
<a name="skiplink"><img src="/s.gif" height='1' width='1'
alt="Content Starts Here" class="skiplink"></a><div class="bPageTitle">
<div class="ptBody secondaryPalette">
<div class="content"><img src="/s.gif" alt="Account" class="pageTitleIcon">
<h1 class="pageType">Account <span class="titleSeparatingColon">:</span></h1>
<h2 class="pageDescription" id="pdes" >Address Change Request</h2>
<!-- --> <br >
<!-- <div class="blank">&nbsp;</div>
-->
</div>
</div> <!-- end ptBody -->
<div class="bDescription" id="descript">Please review current information. If a change is necessary, provide the updated information in the "Update Address" section and click on "Send Email".</div>

<div id="pagebody">
<div class="hotListElement"><div class="bPageBlock secondaryPalette"><div class="pbHeader"><form id="addressForm" name="addressForm" ><TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h3>Account Inormation</h3></TD><TD class="pbButton"></TD><TD class="pbHelp"></TD></TR>
</TABLE>
</div>
<div class="pbBody">
<table class="list" border="0" cellspacing="0" cellpadding="0">

<TR>
<TD align="center" ><B>Account Name</B></TD><TD class="dataCol col02">{!Account.Name}</TD>
<TD align="center" ><B>Branch Org</B></TD><TD class="dataCol col02">{!Account.Branch_Org__c} </TD>
</TR>

</table>
</div></div>

<h3><span id="pbname"></span></h3>



<div class="hotListElement"><div class="bPageBlock secondaryPalette"><div class="pbHeader"><form id="addressForm" name="addressForm" ><TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h3>Current Address</h3></TD><TD class="pbButton"></TD><TD class="pbHelp"></TD></TR>
</TABLE>

</div>
<div class="pbBody">
<table class="list" border="0" cellspacing="0" cellpadding="0">
<TR><TD>&nbsp;</TD><TD ><B>Street Address</B></TD><TD>&nbsp;</TD><TD ><B>Mailing Address</TD></TR>
<TR>
<TD class="labelCol">Street</TD><TD class="dataCol col02">{!Account.ShippingStreet}</TD>
<TD class="labelCol">Street</TD><TD class="dataCol col02">{!Account.BillingStreet}</TD>
</TR>

<TR>
<TD class="labelCol">City</TD><TD class="dataCol col02">{!Account.ShippingCity} </TD>
<TD class="labelCol">City</TD><TD class="dataCol col02">{!Account.BillingCity} </TD>
</TR>
<TR>
<TD class="labelCol">State</TD><TD class="dataCol col02">{!Account.ShippingState}</TD>
<TD class="labelCol">State</TD><TD class="dataCol col02">{!Account.BillingState}</TD>
</TR>
<TR>
<TD class="labelCol">Zip</TD><TD class="dataCol col02">{!Account.ShippingPostalCode}</TD>
<TD class="labelCol">Zip</TD><TD class="dataCol col02">{!Account.BillingPostalCode}</TD>
</TR>
<TR>
<TD class="labelCol">Phone</TD><TD class="dataCol col02">{!Account.Phone}</TD><TD class="labelCol">&nbsp;</TD><TD class="dataCol col02">&nbsp;</TD>
</TR>
<TR>
<TD class="labelCol">Fax</TD><TD class="dataCol col02">{!Account.Fax}</TD><TD class="labelCol">&nbsp;</TD><TD class="dataCol col02">&nbsp;</TD>
</TR>
</table>
</div></div>

<br>

<div class="bPageBlock bEditBlock secondaryPalette" id="ep"><div class="pbHeader">
<TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h2 class="mainTitle">Update Address</h2></TD><TD class="pbButton"><input value="Send Email" class="btn" type="button" title="Send Email" name="send_email" onclick="return doSendEmail()" > <input value="Cancel" class="btn" type="submit" title="Cancel" name="cancel" onclick="return jumpbackToAccount()" ></TD></TR>
</TABLE>
</div>
<div class="pbBody">
<TABLE class="detailList" cellpadding="0" cellspacing="0" border="0">
<TR><TD>&nbsp;</TD><TD ><B>Street Address</B></TD><TD>&nbsp;</TD><TD ><B>Mailing Address</TD></TR>
<TR></TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_street_1">Street</label></TD><TD class="dataCol col02" width="25%"><textarea cols="25" id="new_s_street_1" maxlength="255" name="new_street_1" rows="2" tabindex="30" type="text" wrap="soft">{!Account.ShippingStreet}</textarea></TD>
<TD class="labelCol" width="25%"><label for="new_m_street_1">Street</label></TD><TD class="dataCol col02" width="25%"><textarea cols="25" id="new_m_street_1" maxlength="255" name="new_street_1" rows="2" tabindex="35" type="text" wrap="soft">{!Account.BillingStreet}</textarea></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_city">City</label></TD><TD class="dataCol col02" width="25%"><input tabindex="32" maxlength="40" type="text" id="new_s_city" size="20" name="new_city" value="{!Account.ShippingCity}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_city">City</label></TD><TD class="dataCol col02" width="25%"><input tabindex="36" maxlength="40" type="text" id="new_m_city" size="20" name="new_city" value="{!Account.BillingCity}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_state">State</label></TD><TD class="dataCol col02" width="25%"><input tabindex="33" maxlength="20" type="text" id="new_s_state" size="20" name="new_state" value="{!Account.ShippingState}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_state">State</label></TD><TD class="dataCol col02" width="25%"><input tabindex="37" maxlength="20" type="text" id="new_m_state" size="20" name="new_state" value="{!Account.BillingState}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_zip">Zip</label></TD><TD class="dataCol col02" width="25%"><input tabindex="34" maxlength="20" type="text" id="new_s_zip" size="20" name="new_zip" value="{!Account.ShippingPostalCode}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_zip">Zip</label></TD><TD class="dataCol col02" width="25%"><input tabindex="38" maxlength="20" type="text" id="new_m_zip" size="20" name="new_zip" value="{!Account.BillingPostalCode}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_phone">Phone</label></TD><TD class="dataCol col02" width="25%"><input tabindex="39" maxlength="40" type="text" id="new_phone" size="20" name="new_phone" value="{!Account.Phone}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_fax">Fax</label></TD><TD class="dataCol col02" width="25%"><input tabindex="40" maxlength="40" type="text" id="new_fax" size="20" name="new_fax" value="{!Account.Fax}"></TD>
</TR>
</TABLE>
</div>

</div>
</form>
</div>


</body>
</html>
  • March 24, 2014
  • Like
  • 1

All - Let me start by saying, I am relatively new to Visual Force(VF), who have used wrappers successfully in the past to display data in the grid. However this is the first time, I am trying to update some data from it. Any help or pointers would be greatly appreciated.

 

Prioblem Description - For weekly time entry project, what are we trying to do is to allow user to select a week they are trying to enter the time against. I display the list of projects in a grid based on project resource assignment and the projects that are marked as "Administration" project. If they already have time entered against some day of the week for these projects, display that, else '0'. I am using wrapper to flatten the records. I am using dataTable in VF and have the columns as InputText. For some reason when I updates the data in the grid and press "Post", the controller method doesn't have the updated data. Please review saveChanges() method in my controller and VF page to see what I might be doing wrong. The debug statements in my saveChanges() loop retains the old values that were derived in getWeeklyTimeEntries() method. What I am doing wrong?

 

P.S. In other examples that I found, users seem to declare the variable to use in dataTable as PRIVATE FINAL in order to retrieve and update. But as I derive this wrapper grid, I can't do that.

 

Wrapper Class -

public withsharingclass WeeklyTimeEntry_Wrapper {

public Id projectId {get;set;}

public String projectName {get;set;}

public Decimal sunday {get;set;}

public Decimal monday {get;set;}

public Decimal tuesday {get;set;}

public Decimal wednesday {get;set;}

public Decimal thursday {get;set;}

public Decimal friday {get;set;}

public Decimal saturday {get;set;}

}

 

Controller Class-

public class WeeklyTimeEntry_Controller {
private final User loggedInUser;
public String selectedWeek{get; set;}
public Date weekStartDate{get; set;}
public Date weekEndDate{get; set;} //WeekStartDate will be Sunday; and weekEndDate will be Saturday
public List<WeeklyTimeEntry_Wrapper> userWeeklyTime{get; set;} // The variable gets derived in getWeeklyTimeEntries() to display as Grid. Also, it is used to update changes in saveChanges().
//private final List<WeeklyTimeEntry_Wrapper> userWeeklyTime{get;set;}
public Map<String, Time_Record__c> postedProjectTimesMap; //The variable stores the time record that were retrieved for the user. It is used to compare with userWeeklyTime and determine Insert Vs. Updates.
public Id UserId, ContactId;
public String weekChanged{get; // *** setter is NOT being called ***
set {
weekChanged = value;
}
}

public WeeklyTimeEntry_Controller(ApexPages.StandardController stdController) {
this.loggedInUser= (User)stdController.getRecord();
UserId = loggedInUser.Id;
ContactId = [Select contactId From user WHERE Id = :UserId].ContactId;
weekChanged = 'TRUE';
}

public void saveChanges() {
system.debug('In saveChanges');
Decimal sunday = 0, monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0;
List<Time_Record__c> updateTimeRecordList = new List<Time_Record__c> ();
List<Time_Record__c> insertTimeRecordList = new List<Time_Record__c> ();
Time_Record__c updateTimeRecord;
Time_Record__c insertTimeRecord;


//Cycle through the list of updated TimeEntries
for(WeeklyTimeEntry_Wrapper updatedWeeklyTime2 : userWeeklyTime) {
system.debug('In updatedWeeklyTime2.projectName:'+ updatedWeeklyTime2.projectName);
system.debug('In updatedWeeklyTime2.projectId:'+ updatedWeeklyTime2.projectId);
system.debug('In updatedWeeklyTime2.sunday:'+ updatedWeeklyTime2.sunday);
system.debug('In updatedWeeklyTime2.monday:'+ updatedWeeklyTime2.monday);
}

} // End of saveChanges() method


public List<SelectOption> getWeeks() {
List<SelectOption> options = new List<SelectOption>();
// if (weekChanged == 'TRUE') {
// Get the weeks from the beginning of last year till this week and add it to SelectOption
Date startDate = date.newInstance(date.today().year()-1, 1, 1).toStartOfWeek();
Date endDate = startDate.addDays(6);
Date nextWeekStartDate = date.today().toStartOfWeek();
String pickListValue = string.valueOf(startDate) + ':' + string.valueOf(endDate);
String pickListLabel = 'Sunday, ' + string.valueOf(startDate);
options.add(new SelectOption(pickListValue, pickListLabel ));
selectedWeek = pickListValue;
Do {
startDate = endDate.addDays(1);
endDate = startDate.addDays(6);
pickListValue = string.valueOf(startDate) + ':' + string.valueOf(endDate);
pickListLabel = 'Sunday, ' + string.valueOf(startDate);
options.add(new SelectOption(pickListValue, pickListLabel ));
} While (nextWeekStartDate > startDate);
weekChanged = 'FALSE';
setWeek();
// }
return options;
}

public void setWeek() {
Integer li_splitDate;
this.selectedWeek = selectedWeek;
li_splitDate = selectedWeek.indexOf(':',0);
weekStartDate = Date.valueOf(selectedWeek.substring(0, li_splitDate));
weekEndDate = Date.valueOf(selectedWeek.substring(li_splitDate+1, selectedWeek.length()));
getWeeklyTimeEntries();
}

public List<WeeklyTimeEntry_Wrapper> getWeeklyTimeEntries() {
List<Team_Member__c> assignedProjects = [Select t.team_member__c, t.Contractor__c, t.Project__c, t.Project__r.Name, t.Project__r.Project_Status__c from Team_Member__c t Where t.Project__r.Project_Status__c IN ('Active','Complete') AND ((t.Contractor__c = :ContactId AND t.Contractor__c != null) OR (t.team_member__c = :UserId AND t.team_member__c != NULL))];
postedProjectTimesMap = new Map<String, Time_Record__c> ([Select t.Project__r.Name, t.name, t.Team_Member__c, t.Contractor__c, t.Hours__c, t.Id, t.Project__c, t.Start_Date__c from Time_Record__c t WHERE ((t.Contractor__c = :ContactId AND t.Contractor__c != null) OR (t.Team_Member__c = :UserId AND t.Team_Member__c != null))AND t.Start_Date__c >= :weekStartDate AND t.Start_Date__c <= :weekEndDate ORDER BY t.Project__r.Name, t.Start_Date__c]); //AND t.Start_Date__c >= 2011-11-17 AND t.Start_Date__c <= 2012-02-17];
String lastProjectInLoop = '';
Id lastProjectIdInLoop;
Decimal sunday = 0, monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0;
WeeklyTimeEntry_Wrapper weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
Map<String, WeeklyTimeEntry_Wrapper> weeklyTimeEntriesMap = new Map<String, WeeklyTimeEntry_Wrapper> ();
List<Time_Record__c> postedProjectTimes = postedProjectTimesMap.Values();

//Loop through posted Project Time to see if there's already entered time against it.
for (Time_Record__c postedProjectTime : postedProjectTimes) {
Date dateToCompareWithPostedTime = postedProjectTime.Start_Date__c.toStartOfWeek();
// If processing project is different than in previous iteration, add the values to the wrapper and reset the wrapper.
if (lastProjectInLoop != postedProjectTime.Project__r.Name && lastProjectInLoop != '') {
weeklyTimeEntry.projectId = lastProjectIdInLoop;
weeklyTimeEntry.projectName = lastProjectInLoop;
weeklyTimeEntry.sunday = sunday;
weeklyTimeEntry.monday = monday;
weeklyTimeEntry.tuesday = tuesday;
weeklyTimeEntry.wednesday = wednesday;
weeklyTimeEntry.thursday = thursday;
weeklyTimeEntry.friday = friday;
weeklyTimeEntry.saturday = saturday;
weeklyTimeEntriesMap.put(weeklyTimeEntry.projectId, weeklyTimeEntry);
//Reset the variables
weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
sunday = 0;
monday = 0;
tuesday = 0;
wednesday = 0;
thursday = 0;
friday = 0;
saturday = 0;
}

// Loop throgh 7 days, see which one matches "postedProjectTime.Start_Date__c" and update the weeklyTimeEntry.Day time accordingly.
for (Integer dayNumber = 1; dayNumber < 8; dayNumber++) {
if (dateToCompareWithPostedTime == postedProjectTime.Start_Date__c) {
if (dayNumber == 1) { //Sunday
sunday = postedProjectTime.hours__c;
} else if (dayNumber == 2) { //Monday
monday= postedProjectTime.hours__c;
} else if (dayNumber == 3) { //Tuesday
tuesday = postedProjectTime.hours__c;
} else if (dayNumber == 4) { //Wednesday
wednesday = postedProjectTime.hours__c;
} else if (dayNumber == 5) { //Thursday
thursday = postedProjectTime.hours__c;
} else if (dayNumber == 6) { //Friday
friday = postedProjectTime.hours__c;
} else if (dayNumber == 7) { //Saturday
saturday = postedProjectTime.hours__c;
}
}
dateToCompareWithPostedTime = dateToCompareWithPostedTime.addDays(1);
}
lastProjectInLoop = postedProjectTime.Project__r.Name;
lastProjectIdInLoop = postedProjectTime.Project__c;
}

// Get all the projects where this contact is assigned as team-member and instantiate weekly time entry for it.
for (Team_Member__c teamMemberProject : assignedProjects) {
//Check if the processing project has entry in TimeEntry map. If it does NOT, add it.
if (!weeklyTimeEntriesMap.containsKey(teamMemberProject.Project__r.Name)) {
weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
weeklyTimeEntry.projectId = teamMemberProject.Project__c;
weeklyTimeEntry.projectName = teamMemberProject.Project__r.Name;
weeklyTimeEntry.sunday = 0;
weeklyTimeEntry.monday = 0;
weeklyTimeEntry.tuesday = 0;
weeklyTimeEntry.wednesday = 0;
weeklyTimeEntry.thursday = 0;
weeklyTimeEntry.friday = 0;
weeklyTimeEntry.saturday = 0;

weeklyTimeEntriesMap.put(weeklyTimeEntry.projectId, weeklyTimeEntry);
}
}
//The list of TimeEntry is now ready, assign it to list so it can be used to retrieve the grid
userWeeklyTime = weeklyTimeEntriesMap.Values();
RETURN userWeeklyTime;

}

 

Visual Force -

<apex:page standardController="user" extensions="WeeklyTimeEntry_Controller" >

<apex:form id="tLineEntryForm">
<apex:pageBlock id="tEntryWeekSelectionPageBlock">
<apex:actionRegion >
<apex:pageBlockSection id="selectedWeek" title="Project List for {!$User.FirstName} {!$User.LastName}" columns="2" collapsible="false">
<apex:pageBlockSectionItem id="selectedWeek">
<apex:outputLabel for="selectedWeek">Week Beginning</apex:outputLabel>
<apex:panelGroup >
<apex:selectList value="{!selectedWeek}" multiselect="false" size="1" onchange="weekSelectedJS">
<apex:selectOptions value="{!Weeks}"/>
</apex:selectList>
</apex:panelGroup>
</apex:pageBlockSectionItem>
<apex:commandButton value="Go" action="{!setWeek}" rerender="timeEntrySection" >
<apex:param name="weekChanged" value="TRUE" assignTo="{!weekChanged}"/>
</apex:commandButton>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageBlockSection id="timeEntrySection" title="Time Entry for {!$User.FirstName} {!$User.LastName} Dates Between {!weekStartDate} and {!weekEndDate}" columns="8" collapsible="false">
<apex:dataTable value="{!userWeeklyTime}" var="dtWeeklyTime" id="theTable" rowClasses="odd,even" styleClass="tableClass">

<apex:column >
<apex:facet name="header">Project</apex:facet>
<apex:facet name="footer">Total</apex:facet>
<apex:outputText value="{!dtWeeklyTime.projectName}" />
</apex:column>
<apex:column >
<apex:facet name="header">Sunday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.sunday}" disabled="FALSE"/>
</apex:column>
<apex:column >
<apex:facet name="header">Monday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.monday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Tuesday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.tuesday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Wenesday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.wednesday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Thursday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.thursday}" />
</apex:column>
<apex:column >
<apex:facet name="header">Friday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.friday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Saturday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.saturday}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlockSection>
<apex:actionRegion >
<apex:commandButton value="Post" action="{!saveChanges}" rerender="timeEntrySection" immediate="false"/>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>

  • February 24, 2012
  • Like
  • 0

I have two VF pages with two separate controllers. In the first page/controller, I build the list of Ids that I want to pass to the second page/controller.

 

I tried using the URL query string but my list contains hundreds of Ids and the URL gets really long, so some of it gets chopped off when it hits the 2nd page. I also looked into possibility of using "pgRef.getParameters().put('OrgIdsStringList', AccountIds);" but apparently we can only set the string parameters and not the List<Id>.

 

What's the best way to pass the List of data from one VF page to another?

 

Thanks!,

Prash....

 

 

  • September 21, 2011
  • Like
  • 0
Hello,

We have sControl that's used in a custom button on Account page. The sControl collects some data from the form and sends out an email. The sControl all of sudden stopped sending emails a few months ago. No changes were made to sControl itself. We need assistence from sControl expert in identifying what might have caused the issue and if any changes need to be made to sControl. Unfortunately, I never worked in sControls and could always create a new VF pge to accomplish this. However, it would be great if someone can point out if there's something wrong and can be easily adjusted. I am pasting the sControl code below. Thanks, Prashant

sControl Code
----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Product Selection</title>
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/css/assistive.css" type="text/css" media="aural,braille,embossed" rel="stylesheet" >
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script type="text/javascript" src="/js/functions.js"></script>
<script language="javascript" type="text/javascript">

function initPage() {
sforceClient.useCookies = true;
//sforceClient.registerInitCallback(setup);
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
setTimeout("setup()",50);
}

// main setup entry point
function setup() {

}


function doSendEmail()
{

//debugger;

var ToAddress ="";
var AdditionalToAddress = "{!User.Email}";



if("omar@reisys.com" != AdditionalToAddress)
{
AdditionalToAddress = 'SalesForceActionLine@genworth.com';
}

var OpportunitId="";
var locationStr="";
var newESISessionStatus="";
var InstrNotes="";
var eventIdStr = "";
var CCAddress = "";
var BCCAddress ="{!User.Email}";
var DateDisplay="";



var userFirstName = "";
var userLastName = "";
var url = "/email/author/emailauthor.jsp?rtype=003&save=1&p2=" +ToAddress + "&p24=" +AdditionalToAddress +"&p4=" + CCAddress +"&p5=" +BCCAddress
var Subject=returnConstructedEmailSubject();


var Body = returnConstructedEmailBody();
Subject = returnConstructedEmailSubject();
//alert(Subject + "\n "+Body);
url=url + "&p6=" +escape(Subject)+"&p23=" +escape(Body);
var _xml = new Sforce.XmlHttp();
_xml.req.open('POST', url,false);

_xml.req.send( Body );
var resp = _xml.req;
if(resp.statusText=='OK')
{
alert("Successfully sent the email");
jumpback("/{!Account.Id}")
}else
{
alert("The email notification failed.");
}

}


function returnConstructedEmailSubject()
{
var subjStr = "Address change request for the account {!Account.Name}";
return subjStr;
}

function returnConstructedEmailBody()
{
//alert(document.addressForm.new_street_1.value);
var openB = "<b>";
var closeB = "</b>"
var openP = "<p>";
var closeP = "</p>";
var brStr="<br>";
var orgBNumberStr = "{!Account.Branch_Org__c}";
if(orgBNumberStr != '' && orgBNumberStr != null)
{
orgBNumberStr = "{!Account.Branch_Org__c} - ";
}
var bodyStr = brStr;
bodyStr = bodyStr+"{!User.Name} has requested the following change for "+closeB+orgBNumberStr+"{!Account.Name}:"+ brStr;


bodyStr = bodyStr+brStr + returnAddressBodypart('Mailing Address :', "{!Account.BillingStreet}","{!Account.BillingCity}", "{!Account.BillingState}", "{!Account.BillingPostalCode}",
document.addressForm.new_m_street_1.value,document.addressForm.new_m_city.value,
document.addressForm.new_m_state.value, document.addressForm.new_m_zip.value);
//alert(bodyStr1);

bodyStr = bodyStr+brStr + returnAddressBodypart('Street Address :', "{!Account.ShippingStreet}","{!Account.ShippingCity}", "{!Account.ShippingState}", "{!Account.ShippingPostalCode}",
document.addressForm.new_s_street_1.value,document.addressForm.new_s_city.value,
document.addressForm.new_s_state.value, document.addressForm.new_s_zip.value);

bodyStr = bodyStr+brStr + returnPhoneBodypart('Phone & Fax :',"{!Account.Phone}",document.addressForm.new_phone.value ,"{!Account.Fax}",document.addressForm.new_fax.value);

/*bodyStr = bodyStr +brStr+""+openB+"From --";
bodyStr = bodyStr+""+closeB+""+brStr+"Street: {!Account.BillingStreet}"+brStr+"City: {!Account.BillingCity}"+brStr+"State: {!Account.BillingState}"+brStr+"Zip: {!Account.BillingPostalCode} "+brStr+"Phone: {!Account.Phone}"+brStr+"Fax: {!Account.Fax}"+brStr;
bodyStr = bodyStr +""+openB+""+brStr+"To --"+closeB+""+brStr;
bodyStr = bodyStr +"Street: "+document.addressForm.new_street_1.value +brStr+"City: "+document.addressForm.new_city.value+""+brStr+"State: "+document.addressForm.new_state.value+""+brStr+"Zip: "+document.addressForm.new_zip.value+""+brStr+"Phone: "+document.addressForm.new_phone.value+brStr+"Fax: "+document.addressForm.new_fax.value+brStr;
bodyStr = bodyStr +""+closeP;*/
//alert(bodyStr);
return bodyStr;
}


function returnAddressBodypart(addName, frStreet,frCity, frState, frZip, toStreet,toCity, toState, toZip)
{

var bodyStr = "";
bodyStr = addName + "\n";
bodyStr = bodyStr +"-----------------"+ "\n";
bodyStr = bodyStr + "From---" + "\n";
bodyStr = bodyStr + "Street: " + frStreet + "\n" ;
bodyStr = bodyStr + "City : " + frCity + "\n" ;
bodyStr = bodyStr + "State : " + frState + "\n" ;
bodyStr = bodyStr + "Zip : " + frZip + "\n" ;
bodyStr = bodyStr + "\n";

bodyStr = bodyStr + "To---" + "\n";
bodyStr = bodyStr + "Street: " + toStreet + "\n" ;
bodyStr = bodyStr + "City : " + toCity + "\n" ;
bodyStr = bodyStr + "State : " + toState + "\n" ;
bodyStr = bodyStr + "Zip : " + toZip + "\n" ;
return bodyStr;
}


function returnPhoneBodypart(addName,frPhone, toPhone, frFax, toFax)
{
var bodyStr = "";
bodyStr = addName + "\n";
bodyStr = bodyStr +"-----------------"+ "\n";
bodyStr = bodyStr + "From---" + "\n";
bodyStr = bodyStr + "Phone : " + frPhone + "\n" ;
bodyStr = bodyStr + "Fax : " + frFax + "\n" ;
bodyStr = bodyStr + "To---" + "\n";
bodyStr = bodyStr + "Phone : " + toPhone + "\n" ;
bodyStr = bodyStr + "Fax : " + toFax + "\n" ;
bodyStr = bodyStr + "\n";
return bodyStr;
}
function jumpbackToAccount()
{ jumpback("/{!Account.Id}"); }

function jumpback(retUrl)
{ window.parent.parent.location.href = retUrl; }

</script>

</head>
<body onload="javascript:initPage();" class="account editPage" >
<a name="skiplink"><img src="/s.gif" height='1' width='1'
alt="Content Starts Here" class="skiplink"></a><div class="bPageTitle">
<div class="ptBody secondaryPalette">
<div class="content"><img src="/s.gif" alt="Account" class="pageTitleIcon">
<h1 class="pageType">Account <span class="titleSeparatingColon">:</span></h1>
<h2 class="pageDescription" id="pdes" >Address Change Request</h2>
<!-- --> <br >
<!-- <div class="blank">&nbsp;</div>
-->
</div>
</div> <!-- end ptBody -->
<div class="bDescription" id="descript">Please review current information. If a change is necessary, provide the updated information in the "Update Address" section and click on "Send Email".</div>

<div id="pagebody">
<div class="hotListElement"><div class="bPageBlock secondaryPalette"><div class="pbHeader"><form id="addressForm" name="addressForm" ><TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h3>Account Inormation</h3></TD><TD class="pbButton"></TD><TD class="pbHelp"></TD></TR>
</TABLE>
</div>
<div class="pbBody">
<table class="list" border="0" cellspacing="0" cellpadding="0">

<TR>
<TD align="center" ><B>Account Name</B></TD><TD class="dataCol col02">{!Account.Name}</TD>
<TD align="center" ><B>Branch Org</B></TD><TD class="dataCol col02">{!Account.Branch_Org__c} </TD>
</TR>

</table>
</div></div>

<h3><span id="pbname"></span></h3>



<div class="hotListElement"><div class="bPageBlock secondaryPalette"><div class="pbHeader"><form id="addressForm" name="addressForm" ><TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h3>Current Address</h3></TD><TD class="pbButton"></TD><TD class="pbHelp"></TD></TR>
</TABLE>

</div>
<div class="pbBody">
<table class="list" border="0" cellspacing="0" cellpadding="0">
<TR><TD>&nbsp;</TD><TD ><B>Street Address</B></TD><TD>&nbsp;</TD><TD ><B>Mailing Address</TD></TR>
<TR>
<TD class="labelCol">Street</TD><TD class="dataCol col02">{!Account.ShippingStreet}</TD>
<TD class="labelCol">Street</TD><TD class="dataCol col02">{!Account.BillingStreet}</TD>
</TR>

<TR>
<TD class="labelCol">City</TD><TD class="dataCol col02">{!Account.ShippingCity} </TD>
<TD class="labelCol">City</TD><TD class="dataCol col02">{!Account.BillingCity} </TD>
</TR>
<TR>
<TD class="labelCol">State</TD><TD class="dataCol col02">{!Account.ShippingState}</TD>
<TD class="labelCol">State</TD><TD class="dataCol col02">{!Account.BillingState}</TD>
</TR>
<TR>
<TD class="labelCol">Zip</TD><TD class="dataCol col02">{!Account.ShippingPostalCode}</TD>
<TD class="labelCol">Zip</TD><TD class="dataCol col02">{!Account.BillingPostalCode}</TD>
</TR>
<TR>
<TD class="labelCol">Phone</TD><TD class="dataCol col02">{!Account.Phone}</TD><TD class="labelCol">&nbsp;</TD><TD class="dataCol col02">&nbsp;</TD>
</TR>
<TR>
<TD class="labelCol">Fax</TD><TD class="dataCol col02">{!Account.Fax}</TD><TD class="labelCol">&nbsp;</TD><TD class="dataCol col02">&nbsp;</TD>
</TR>
</table>
</div></div>

<br>

<div class="bPageBlock bEditBlock secondaryPalette" id="ep"><div class="pbHeader">
<TABLE cellpadding="0" cellspacing="0" border="0"><TR><TD class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"><h2 class="mainTitle">Update Address</h2></TD><TD class="pbButton"><input value="Send Email" class="btn" type="button" title="Send Email" name="send_email" onclick="return doSendEmail()" > <input value="Cancel" class="btn" type="submit" title="Cancel" name="cancel" onclick="return jumpbackToAccount()" ></TD></TR>
</TABLE>
</div>
<div class="pbBody">
<TABLE class="detailList" cellpadding="0" cellspacing="0" border="0">
<TR><TD>&nbsp;</TD><TD ><B>Street Address</B></TD><TD>&nbsp;</TD><TD ><B>Mailing Address</TD></TR>
<TR></TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_street_1">Street</label></TD><TD class="dataCol col02" width="25%"><textarea cols="25" id="new_s_street_1" maxlength="255" name="new_street_1" rows="2" tabindex="30" type="text" wrap="soft">{!Account.ShippingStreet}</textarea></TD>
<TD class="labelCol" width="25%"><label for="new_m_street_1">Street</label></TD><TD class="dataCol col02" width="25%"><textarea cols="25" id="new_m_street_1" maxlength="255" name="new_street_1" rows="2" tabindex="35" type="text" wrap="soft">{!Account.BillingStreet}</textarea></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_city">City</label></TD><TD class="dataCol col02" width="25%"><input tabindex="32" maxlength="40" type="text" id="new_s_city" size="20" name="new_city" value="{!Account.ShippingCity}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_city">City</label></TD><TD class="dataCol col02" width="25%"><input tabindex="36" maxlength="40" type="text" id="new_m_city" size="20" name="new_city" value="{!Account.BillingCity}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_state">State</label></TD><TD class="dataCol col02" width="25%"><input tabindex="33" maxlength="20" type="text" id="new_s_state" size="20" name="new_state" value="{!Account.ShippingState}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_state">State</label></TD><TD class="dataCol col02" width="25%"><input tabindex="37" maxlength="20" type="text" id="new_m_state" size="20" name="new_state" value="{!Account.BillingState}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_s_zip">Zip</label></TD><TD class="dataCol col02" width="25%"><input tabindex="34" maxlength="20" type="text" id="new_s_zip" size="20" name="new_zip" value="{!Account.ShippingPostalCode}"></TD>
<TD class="labelCol" width="25%"><label for="new_m_zip">Zip</label></TD><TD class="dataCol col02" width="25%"><input tabindex="38" maxlength="20" type="text" id="new_m_zip" size="20" name="new_zip" value="{!Account.BillingPostalCode}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_phone">Phone</label></TD><TD class="dataCol col02" width="25%"><input tabindex="39" maxlength="40" type="text" id="new_phone" size="20" name="new_phone" value="{!Account.Phone}"></TD>
</TR>
<TR>
<TD class="labelCol" width="25%"><label for="new_fax">Fax</label></TD><TD class="dataCol col02" width="25%"><input tabindex="40" maxlength="40" type="text" id="new_fax" size="20" name="new_fax" value="{!Account.Fax}"></TD>
</TR>
</TABLE>
</div>

</div>
</form>
</div>


</body>
</html>
  • March 24, 2014
  • Like
  • 1
If I create an application that I want my customers to login to access their records, how must they be licensed to have this access?

Hi! I'm looking for some info about "Batchable instance is too big" exception and I couldn't find nothing... Anyone have a clue about why this exception is triggered?

 

Thanks a lot! 

All - Let me start by saying, I am relatively new to Visual Force(VF), who have used wrappers successfully in the past to display data in the grid. However this is the first time, I am trying to update some data from it. Any help or pointers would be greatly appreciated.

 

Prioblem Description - For weekly time entry project, what are we trying to do is to allow user to select a week they are trying to enter the time against. I display the list of projects in a grid based on project resource assignment and the projects that are marked as "Administration" project. If they already have time entered against some day of the week for these projects, display that, else '0'. I am using wrapper to flatten the records. I am using dataTable in VF and have the columns as InputText. For some reason when I updates the data in the grid and press "Post", the controller method doesn't have the updated data. Please review saveChanges() method in my controller and VF page to see what I might be doing wrong. The debug statements in my saveChanges() loop retains the old values that were derived in getWeeklyTimeEntries() method. What I am doing wrong?

 

P.S. In other examples that I found, users seem to declare the variable to use in dataTable as PRIVATE FINAL in order to retrieve and update. But as I derive this wrapper grid, I can't do that.

 

Wrapper Class -

public withsharingclass WeeklyTimeEntry_Wrapper {

public Id projectId {get;set;}

public String projectName {get;set;}

public Decimal sunday {get;set;}

public Decimal monday {get;set;}

public Decimal tuesday {get;set;}

public Decimal wednesday {get;set;}

public Decimal thursday {get;set;}

public Decimal friday {get;set;}

public Decimal saturday {get;set;}

}

 

Controller Class-

public class WeeklyTimeEntry_Controller {
private final User loggedInUser;
public String selectedWeek{get; set;}
public Date weekStartDate{get; set;}
public Date weekEndDate{get; set;} //WeekStartDate will be Sunday; and weekEndDate will be Saturday
public List<WeeklyTimeEntry_Wrapper> userWeeklyTime{get; set;} // The variable gets derived in getWeeklyTimeEntries() to display as Grid. Also, it is used to update changes in saveChanges().
//private final List<WeeklyTimeEntry_Wrapper> userWeeklyTime{get;set;}
public Map<String, Time_Record__c> postedProjectTimesMap; //The variable stores the time record that were retrieved for the user. It is used to compare with userWeeklyTime and determine Insert Vs. Updates.
public Id UserId, ContactId;
public String weekChanged{get; // *** setter is NOT being called ***
set {
weekChanged = value;
}
}

public WeeklyTimeEntry_Controller(ApexPages.StandardController stdController) {
this.loggedInUser= (User)stdController.getRecord();
UserId = loggedInUser.Id;
ContactId = [Select contactId From user WHERE Id = :UserId].ContactId;
weekChanged = 'TRUE';
}

public void saveChanges() {
system.debug('In saveChanges');
Decimal sunday = 0, monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0;
List<Time_Record__c> updateTimeRecordList = new List<Time_Record__c> ();
List<Time_Record__c> insertTimeRecordList = new List<Time_Record__c> ();
Time_Record__c updateTimeRecord;
Time_Record__c insertTimeRecord;


//Cycle through the list of updated TimeEntries
for(WeeklyTimeEntry_Wrapper updatedWeeklyTime2 : userWeeklyTime) {
system.debug('In updatedWeeklyTime2.projectName:'+ updatedWeeklyTime2.projectName);
system.debug('In updatedWeeklyTime2.projectId:'+ updatedWeeklyTime2.projectId);
system.debug('In updatedWeeklyTime2.sunday:'+ updatedWeeklyTime2.sunday);
system.debug('In updatedWeeklyTime2.monday:'+ updatedWeeklyTime2.monday);
}

} // End of saveChanges() method


public List<SelectOption> getWeeks() {
List<SelectOption> options = new List<SelectOption>();
// if (weekChanged == 'TRUE') {
// Get the weeks from the beginning of last year till this week and add it to SelectOption
Date startDate = date.newInstance(date.today().year()-1, 1, 1).toStartOfWeek();
Date endDate = startDate.addDays(6);
Date nextWeekStartDate = date.today().toStartOfWeek();
String pickListValue = string.valueOf(startDate) + ':' + string.valueOf(endDate);
String pickListLabel = 'Sunday, ' + string.valueOf(startDate);
options.add(new SelectOption(pickListValue, pickListLabel ));
selectedWeek = pickListValue;
Do {
startDate = endDate.addDays(1);
endDate = startDate.addDays(6);
pickListValue = string.valueOf(startDate) + ':' + string.valueOf(endDate);
pickListLabel = 'Sunday, ' + string.valueOf(startDate);
options.add(new SelectOption(pickListValue, pickListLabel ));
} While (nextWeekStartDate > startDate);
weekChanged = 'FALSE';
setWeek();
// }
return options;
}

public void setWeek() {
Integer li_splitDate;
this.selectedWeek = selectedWeek;
li_splitDate = selectedWeek.indexOf(':',0);
weekStartDate = Date.valueOf(selectedWeek.substring(0, li_splitDate));
weekEndDate = Date.valueOf(selectedWeek.substring(li_splitDate+1, selectedWeek.length()));
getWeeklyTimeEntries();
}

public List<WeeklyTimeEntry_Wrapper> getWeeklyTimeEntries() {
List<Team_Member__c> assignedProjects = [Select t.team_member__c, t.Contractor__c, t.Project__c, t.Project__r.Name, t.Project__r.Project_Status__c from Team_Member__c t Where t.Project__r.Project_Status__c IN ('Active','Complete') AND ((t.Contractor__c = :ContactId AND t.Contractor__c != null) OR (t.team_member__c = :UserId AND t.team_member__c != NULL))];
postedProjectTimesMap = new Map<String, Time_Record__c> ([Select t.Project__r.Name, t.name, t.Team_Member__c, t.Contractor__c, t.Hours__c, t.Id, t.Project__c, t.Start_Date__c from Time_Record__c t WHERE ((t.Contractor__c = :ContactId AND t.Contractor__c != null) OR (t.Team_Member__c = :UserId AND t.Team_Member__c != null))AND t.Start_Date__c >= :weekStartDate AND t.Start_Date__c <= :weekEndDate ORDER BY t.Project__r.Name, t.Start_Date__c]); //AND t.Start_Date__c >= 2011-11-17 AND t.Start_Date__c <= 2012-02-17];
String lastProjectInLoop = '';
Id lastProjectIdInLoop;
Decimal sunday = 0, monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0;
WeeklyTimeEntry_Wrapper weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
Map<String, WeeklyTimeEntry_Wrapper> weeklyTimeEntriesMap = new Map<String, WeeklyTimeEntry_Wrapper> ();
List<Time_Record__c> postedProjectTimes = postedProjectTimesMap.Values();

//Loop through posted Project Time to see if there's already entered time against it.
for (Time_Record__c postedProjectTime : postedProjectTimes) {
Date dateToCompareWithPostedTime = postedProjectTime.Start_Date__c.toStartOfWeek();
// If processing project is different than in previous iteration, add the values to the wrapper and reset the wrapper.
if (lastProjectInLoop != postedProjectTime.Project__r.Name && lastProjectInLoop != '') {
weeklyTimeEntry.projectId = lastProjectIdInLoop;
weeklyTimeEntry.projectName = lastProjectInLoop;
weeklyTimeEntry.sunday = sunday;
weeklyTimeEntry.monday = monday;
weeklyTimeEntry.tuesday = tuesday;
weeklyTimeEntry.wednesday = wednesday;
weeklyTimeEntry.thursday = thursday;
weeklyTimeEntry.friday = friday;
weeklyTimeEntry.saturday = saturday;
weeklyTimeEntriesMap.put(weeklyTimeEntry.projectId, weeklyTimeEntry);
//Reset the variables
weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
sunday = 0;
monday = 0;
tuesday = 0;
wednesday = 0;
thursday = 0;
friday = 0;
saturday = 0;
}

// Loop throgh 7 days, see which one matches "postedProjectTime.Start_Date__c" and update the weeklyTimeEntry.Day time accordingly.
for (Integer dayNumber = 1; dayNumber < 8; dayNumber++) {
if (dateToCompareWithPostedTime == postedProjectTime.Start_Date__c) {
if (dayNumber == 1) { //Sunday
sunday = postedProjectTime.hours__c;
} else if (dayNumber == 2) { //Monday
monday= postedProjectTime.hours__c;
} else if (dayNumber == 3) { //Tuesday
tuesday = postedProjectTime.hours__c;
} else if (dayNumber == 4) { //Wednesday
wednesday = postedProjectTime.hours__c;
} else if (dayNumber == 5) { //Thursday
thursday = postedProjectTime.hours__c;
} else if (dayNumber == 6) { //Friday
friday = postedProjectTime.hours__c;
} else if (dayNumber == 7) { //Saturday
saturday = postedProjectTime.hours__c;
}
}
dateToCompareWithPostedTime = dateToCompareWithPostedTime.addDays(1);
}
lastProjectInLoop = postedProjectTime.Project__r.Name;
lastProjectIdInLoop = postedProjectTime.Project__c;
}

// Get all the projects where this contact is assigned as team-member and instantiate weekly time entry for it.
for (Team_Member__c teamMemberProject : assignedProjects) {
//Check if the processing project has entry in TimeEntry map. If it does NOT, add it.
if (!weeklyTimeEntriesMap.containsKey(teamMemberProject.Project__r.Name)) {
weeklyTimeEntry = new WeeklyTimeEntry_Wrapper();
weeklyTimeEntry.projectId = teamMemberProject.Project__c;
weeklyTimeEntry.projectName = teamMemberProject.Project__r.Name;
weeklyTimeEntry.sunday = 0;
weeklyTimeEntry.monday = 0;
weeklyTimeEntry.tuesday = 0;
weeklyTimeEntry.wednesday = 0;
weeklyTimeEntry.thursday = 0;
weeklyTimeEntry.friday = 0;
weeklyTimeEntry.saturday = 0;

weeklyTimeEntriesMap.put(weeklyTimeEntry.projectId, weeklyTimeEntry);
}
}
//The list of TimeEntry is now ready, assign it to list so it can be used to retrieve the grid
userWeeklyTime = weeklyTimeEntriesMap.Values();
RETURN userWeeklyTime;

}

 

Visual Force -

<apex:page standardController="user" extensions="WeeklyTimeEntry_Controller" >

<apex:form id="tLineEntryForm">
<apex:pageBlock id="tEntryWeekSelectionPageBlock">
<apex:actionRegion >
<apex:pageBlockSection id="selectedWeek" title="Project List for {!$User.FirstName} {!$User.LastName}" columns="2" collapsible="false">
<apex:pageBlockSectionItem id="selectedWeek">
<apex:outputLabel for="selectedWeek">Week Beginning</apex:outputLabel>
<apex:panelGroup >
<apex:selectList value="{!selectedWeek}" multiselect="false" size="1" onchange="weekSelectedJS">
<apex:selectOptions value="{!Weeks}"/>
</apex:selectList>
</apex:panelGroup>
</apex:pageBlockSectionItem>
<apex:commandButton value="Go" action="{!setWeek}" rerender="timeEntrySection" >
<apex:param name="weekChanged" value="TRUE" assignTo="{!weekChanged}"/>
</apex:commandButton>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageBlockSection id="timeEntrySection" title="Time Entry for {!$User.FirstName} {!$User.LastName} Dates Between {!weekStartDate} and {!weekEndDate}" columns="8" collapsible="false">
<apex:dataTable value="{!userWeeklyTime}" var="dtWeeklyTime" id="theTable" rowClasses="odd,even" styleClass="tableClass">

<apex:column >
<apex:facet name="header">Project</apex:facet>
<apex:facet name="footer">Total</apex:facet>
<apex:outputText value="{!dtWeeklyTime.projectName}" />
</apex:column>
<apex:column >
<apex:facet name="header">Sunday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.sunday}" disabled="FALSE"/>
</apex:column>
<apex:column >
<apex:facet name="header">Monday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.monday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Tuesday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.tuesday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Wenesday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.wednesday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Thursday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.thursday}" />
</apex:column>
<apex:column >
<apex:facet name="header">Friday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.friday}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Saturday</apex:facet>
<apex:inputText value="{!dtWeeklyTime.saturday}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlockSection>
<apex:actionRegion >
<apex:commandButton value="Post" action="{!saveChanges}" rerender="timeEntrySection" immediate="false"/>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>

  • February 24, 2012
  • Like
  • 0

Hi everyone,

 

I have a sort-of complex situation as follows. I have a custom Wrapper object, this wrapper contains a custom header object, and its corresponding header_items. The items are linked to the header in a master-child relationship (1 to many).

 

The items are stored in a map, and I have an exposed property that returns the items in this map:

private Map<Id, Item__c> mItems;

public List<Item__c> items {get { return mItems.values(); } set;}

 

We can have multiple Wrapper objects therefore I have a seperate Wrapper_Basket class that contains multiple Wrapper objects. Similar to the Wrapper item I use a map to get a quick reference using an ID.

private Map<String, Wrapper> mSOWrapper;

public List<Wrapper> wrappers{ get { return mSOWrapper.values(); } set;}

 In my Visualforce page I have the following:

 

<apex:form>
   <apex:outputPanel id="panelBasket">
       <apex:repeat value="{!basket.wrappers}" var="wrapper" >
            {!wrapper.header.ID}
	     
              <apex:repeat value="{!wrapper.items}" var="item" id="theRepeat">  
				      		 	
	               <apex:inputfield value="{!wrapper.Quantity__c}"/>
						        		
	      </apex:repeat>
       </apex:repeat>

   <apex:CommandButton value="Save" action="{!updateQuantities}"  immediate="true" />
  </apex:outputPanel>
</apex:form>

 

When I press the save button the following function gets called, which calls the update function within the wrapper objects (it works, I check debug and I see the function gets called):

 

//In controller:
public void updateQuantities(){
    basket.update();
}


//In basket class, update items and header:
public void updateBasket(){
	for(Wrapper wrapper : this.wrappers){
			update wrapper.items;
			update wrapper.header;
		} 
	}

However. This does not update the new values I enter in the quantities inputfield. I always figured Salesforce would bind the quantity__c field in my repeater and updates takes care of the rest. I believe it may be my setup thats not working.

 

Can anyone shed any light on this?

 

Best,

Frank

Hi, ForceIDE is listed in the catalog of Pulse (www.poweredbypulse.com). The ForceIDE update site recently had an upgrade and as part of that process some of the metadata became incorrectly updated. The main problem is the size of some of your artifacts does not correspond to the actual artifact sizes

 

 osgi.bundle,com.salesforce.id

 com.salesforce.ide.branding

 org.eclipse.update.feature,com.salesforce.ide.feature

 

 

We wanted to report the problem here to see if the site could please be upated. 

 

Thanks in advance!