You need to sign in to do that
Don't have an account?
Hugh Wheeler 8
Filtered Lookp in Visualforce Page
Hi,
I have a table on a visualforce page. The table displays columns from a custom object. One of the columns is a filtered lookup based on two of the other fields in the table.
I have an add row button that adds blank rows to the custom object in the custom controller. These objects are not saved until the user hits an update button.
The Filtered lookup displays fine on those records that have been saved, but not on the records that have not yet been saved. In the VF page however the lookup is blank until the row has been saved. This is slightly different behaviour than in a standard page which shows the correct values in the page dynamically.
Has anyone come across this before, and is there an easy way to solve it?
I have a table on a visualforce page. The table displays columns from a custom object. One of the columns is a filtered lookup based on two of the other fields in the table.
I have an add row button that adds blank rows to the custom object in the custom controller. These objects are not saved until the user hits an update button.
The Filtered lookup displays fine on those records that have been saved, but not on the records that have not yet been saved. In the VF page however the lookup is blank until the row has been saved. This is slightly different behaviour than in a standard page which shows the correct values in the page dynamically.
Has anyone come across this before, and is there an easy way to solve it?
Are you using input fields.
Can you paste the sample code here.
<apex:pageblockTable id="theTable" value="{!timetableList}" var="field" cellPadding="4" border="1" rowClasses="odd,even" styleClass="tableClass">
<apex:column style="{!if(field.isConflict,'background-color:red;', 'color:black')}"> <apex:facet name="header">Cycle Week</apex:facet> <apex:inputField value="{!field.timetable.Timetable_Period_Cycle_Week__c}"/> </apex:column>
<apex:column style="{!if(field.isConflict,'background-color:red;', 'color:black')}"> <apex:facet name="header">Day</apex:facet> <apex:inputField value="{!field.timetable.Timetable_Period_Day_Name__c}"/>
<apex:column style="{!if(field.isConflict,'background-color:red;', 'color:black')}"> <apex:facet name="header">Start Session</apex:facet> <apex:inputField value="{!field.timetable.Timetable_Start_Period__c}"/> </apex:column>
<apex:column style="{!if(field.isConflict,'background-color:red;', 'color:black')}"> <apex:facet name="header">End Session</apex:facet> <apex:inputField value="{!field.timetable.Timetable_End_Period__c}"/> </apex:column>
</apex:pageblockTable>
In bold are the fields which determine the values that should appear in the filtered lookup. In italics are the two filtered lookups.
The filter on each is:
(Class Timetable: Day NameEQUALSFirst Session ID: Day Name) AND (Class Timetable: Cycle WeekEQUALSFirst Session ID: Cycle Week)
(Class Timetable: Day NameEQUALSLast Session ID: Day Name) AND (Class Timetable: Cycle WeekEQUALSLast Session ID: Cycle Week)
-------------------------------------
The timetableList object that the table is based on is a wrapper object specified as follows:
public Class TimetableWrapper{
public Boolean isSelected{get;set;}
public Class_Timetable__c timetable{get;set;}
public String personKey {get;set;}
public String roomKey {get;set;}
public String personRoomKey {get;set;}
public Boolean isConflict {get;set;}
}
The add row to the table functionality is triggered by a command button
<apex:commandButton value="Add 1 Rows" action="{!addRow}" reRender="out">
<apex:param name="addRowNumber" value="1" assignTo="{!addRowNumber}"/>
</apex:commandButton>
The method that adds the row into the table is:
public void addRow()
{
for(Integer i=0; i<addRowNumber; i++)
{
TimetableWrapper newRow = new TimetableWrapper();
timetableList.add(newRow);
}
}
I hope this help, is I can provide any additional info, let me know.
Hi Hugh,
As you are fetching the date using custom controllers.
You need to use with sharing keyword to force the sharing rules
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_keywords_sharing.htm
Donot forget to select best answer to make our efforts visible in the developer forum.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
with sharing on the wrapper made no difference.
Hugh
See if this can help
https://www.minddigital.com/how-to-create-dynamic-dependent-picklist-of-objects-within-salesforce/
Donot forget to select best answer to make our efforts visible in the developer forum.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
I will try to play with the code.
I think you need to rerender relvant row at the onchange event of controlling lookup .you can use a actionsupport function for this purpose.
give this a try by replacing your 2 highlighted columns . Hope I understand you problem . if not apologies
public void addRow()
{
for(Integer i=0; i<addRowNumber; i++)
{
TimetableWrapper newRow = new TimetableWrapper();
Class_Timetable__c myTT = new Class_Timetable__c()
newRow.timetable = myTT;
timetableList.add(newRow);
}
}
I was repeating across a wrapper object to create my table. The rows in the table were based on the timetable variable inside the wrapper but I hadn't populated that variable with anything.
As soon as I added the two highlighted rows above the page started working perfectly.