You need to sign in to do that
Don't have an account?
WEN JIE
How can I get only one record from apex:repeat
Hi,
I use <apex:repeat> in my visualforce email template. And the value for this tag is a list. But actually, I just only want to get one record from this list, maybe first one or last one.
So, does anyone know how to achieve this?
Thank you!
There are a couple of attributes on the repeat tag that should help:
(1) rows - specifies the maximum number of rows to output - so if you set it to 1, you will just get the first
(2) first - this specifies the row to start at, so if you set it to the number of rows - 1, you will just get the last. Of course, you need a way to know how many are in the repeat in the first place.
However, it might be easier to have a controller method that returns the record that you need to process.
All Answers
There are a couple of attributes on the repeat tag that should help:
(1) rows - specifies the maximum number of rows to output - so if you set it to 1, you will just get the first
(2) first - this specifies the row to start at, so if you set it to the number of rows - 1, you will just get the last. Of course, you need a way to know how many are in the repeat in the first place.
However, it might be easier to have a controller method that returns the record that you need to process.
Thank you!
Hi,
One more thing about vf email template.
I create a component before. In my component controller I need a record id to query detial info for one record. So I add an attribute in this component.
Then I add this component in my emailTemplate's <message:attachment> renderas as PDF file. And give an id for this component.({!relatedTo.Id}).
I test this in one production environment(P A). And it works well. The controller can get the id which I set in attribute.
But when I run this function on another production environment (P B) I get the following message:
List has no rows for assignment to SObject: []
I think the controller didn't get the reocrd id then can't finish the query SOQL.
But I don't know why the same code in P A works well but in P B can't work.
The P A is a free instance.
The P B is our production environment and we buy many system license. Except this, I can't find anyother differences.
Thank you!
What type of record is this? Free licenses don't have access to a lot of the standard objects.
Hi,
I check the license but not free license, we try another way to achieve our requirement. And I will do some further research with previous way.
Thanks for your help!