function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hoomelhoomel 

IF condition apex:repeat

Hello,

 

I have run into a problem with using IF conditions in apex:repeat.

 

I have various translated description fields that are referenced in the apex:repeat. If the field for the specific language (Japanese) is empty, the standard english language needs to be used.

This is my code:

<apex:repeat value="{!Quotelist2}" var="l2">
	<tr style="font-size:80%;font-family:Arial Unicode MS;">
		<td valign="top">{!IF(10 > cnt,"0","")}{!FLOOR(cnt)}</td>
		<td valign="top">{!l2.Item__r.Item_name__c}</td>
		<td valign="top">{!IF(l2.Item__r.Short_description_japanese__c = "",l2.Item__r.Short_description_english__c,l2.Item__r.Short_description_japanese__c)}</td>
	</tr>
<apex:variable var="cnt" value="{!cnt+1}" />
</apex:repeat>

 When saving it like this in Force.com IDE, I get "Save error: Unknown property: pdfData.l2"

 

pdfData is the name of the controller, but l2 should simply be the variable the apex:repeat provides, doesn't it?

 

What am I overlooking here?

 

Thanks in advance and Best Regards,

hoomel

Best Answer chosen by Admin (Salesforce Developers) 
hoomelhoomel

This is so embarrasing ^^

 

The variable was not the problem (btw it was an l not a 1). Since I have split up the lists, I wanted to name the variables according to 1st and 2nd list.

 

But the problem was of much much simpler nature.

I had copied the IF clause from the l2-repeat to the l1-repeat (not shown here) and totally forgot to change the variable name there. The repeat variable was then l1 but I was trying to reference data from l2 o.O

 

Puja_mfsi just unintendedly put me on the right spot.

 

Thanks anyway for all the help, sorry to have wastes your time :D

All Answers

asish1989asish1989

Can you provide your apex code?

I need to know about this list Quotelist2, What are the values present in side that list ?

 

For your reference go through this link

http://boards.developerforce.com/t5/Visualforce-Development/apex-repeat-and-apex-variable/td-p/661452

sambasamba
Can you provider a developer account to me? I will check it when I have some time. Thanks, Samba
hoomelhoomel

This should be all the relevant code:

	public List<ItemSystemRelation__c> list1 = new List<ItemSystemRelation__c>();
	public List<ItemSystemRelation__c> list2 = new List<ItemSystemRelation__c>();
public List<ItemSystemRelation__c> getItems(){
		return [Select Name, Item__r.Short_description__c,Item__r.Short_description_english__c,Item__r.Short_description_japanese__c, Item__r.Serial_Number__c, Item__r.Item_Name__c FROM ItemSystemRelation__c WHERE Rental_System__c = :sys AND Item__r.Active__c = true order by Item__r.Item_Name__c];
	}	
public void populateQuoteLists(){
		Integer totalLines = 0;
		if(rental.Document_language__c == 'german' || rental.Document_language__c == null){
			for(Integer i = 0;i < getItems().size();i++){
				if(getItems().get(i).Item__r.Short_description__c != null){
					totalLines = math.round(totalLines + getItems().get(i).Item__r.Short_description__c.length()/80);
				}else{
					totalLines++;
				}
				if(totalLines < maxQuoteLines){
					list1.add(getItems().get(i));
				}else{
					list2.add(getItems().get(i));
				}
			}
		}
		if(rental.Document_language__c == 'English' || rental.Document_language__c == 'French' || rental.Document_language__c == 'Chinese' || rental.Document_language__c == 'Italian' || rental.Document_language__c == 'Japanese' || rental.Document_language__c == 'Spanish' || rental.Document_language__c == 'Turkish'){
			for(Integer i = 0;i < getItems().size();i++){
				if(getItems().get(i).Item__r.Short_description_english__c != null){
					totalLines = math.round(totalLines + getItems().get(i).Item__r.Short_description_english__c.length()/80);
				}else{
					totalLines++;
				}
				if(totalLines < maxQuoteLines){
					list1.add(getItems().get(i));
				}else{
					list2.add(getItems().get(i));
				}
			}
		}
	}
	public List<ItemSystemRelation__c> getQuoteList1(){
		populateQuoteLists();
		return list1;
	}
	public List<ItemSystemRelation__c> getQuoteList2(){
		return list2;
	}

 In this case, list1 and list2 are filled depending on the length of the descriptions. If the lines that all descriptions would need on the PDF page, a second list is displayed on the second page.

 

I hope this gives enough insight.

Puja_mfsiPuja_mfsi

Hi,

your code looks fine except the variable name which u have used for apex:repeat.

Why r u not taken variable name like "quote" or any other string,why u coose 12 as variable.

When I used "12' as a variable it gives error to me and if I replace this variable witha string it working fine.

Please repace "12" with any String.

 

Please let me know if u have any problem on same and if this post helps u give KUDOS by click on star at left.

hoomelhoomel

This is so embarrasing ^^

 

The variable was not the problem (btw it was an l not a 1). Since I have split up the lists, I wanted to name the variables according to 1st and 2nd list.

 

But the problem was of much much simpler nature.

I had copied the IF clause from the l2-repeat to the l1-repeat (not shown here) and totally forgot to change the variable name there. The repeat variable was then l1 but I was trying to reference data from l2 o.O

 

Puja_mfsi just unintendedly put me on the right spot.

 

Thanks anyway for all the help, sorry to have wastes your time :D

This was selected as the best answer