0

Im Trying to write a button that triggers the following code or page:

    <apex:page standardController="Inquery__c" recordSetVar="accvar" contentType="text/csv#filename.csv" >
"First Name","Last Name","Email","Qualification"
<apex:repeat value="{!accvar}" var="a">
<apex:outputText rendered="!NOT({!a.Downloaded__c})">
      {!a.First_Name__c}, {!a.Last_Name__c}, {!a.Email__c}, {!a.Quilification__c}
</apex:outputText>
</apex:repeat>
</apex:page>

All this is suppose to do, is save the a.First_Name__c, a.Last_Name_c, a.Email_c, a.Quilification__c Fields to a CSV File,

IF the a.Downloaded__c CHECK box is checked( i.e. TRUE).

But the code above gives me a Syntax error,

Does anyone know what wrong with the code,

Thanks

  • 2
    Is the above sytax even compiling for you :/ – Rao Jun 13 '13 at 21:37
  • With help ive changed it to the code above – user2333346 Jun 13 '13 at 21:43
  • 3
    Looks like you changed the code. Is it working for you now? Best practice is to leave the question as is and mark the answer that helped you. – Daniel Hoechst Jun 13 '13 at 21:59
1

Have you tried changing:

rendered="!NOT({!a.Downloaded__c})"

to:

rendered="{!NOT(a.Downloaded__c)}"
| improve this answer | |
  • That magically worked – user2333346 Jun 14 '13 at 14:26
1

Try this :

I modified the original code to the following:

UPDATE:

 <apex:page standardController="Inquery__c" recordSetVar="accvar" contentType="text/csv#filename.csv" >
    "First Name","Last Name","Email","Qualification"
    <apex:repeat value="{!accvar}" var="a">
          {!IF(a.Downloaded__c == TRUE,a.First_Name__c, null)}, {!IF(a.Downloaded__c == TRUE,a.Last_Name__c, null)},{!IF(a.Downloaded__c == TRUE,a.Email__c, null)}, {!IF(a.Downloaded__c == TRUE,a.Quilification__c, null)}
    </apex:repeat>

</apex:page>
| improve this answer | |
  • I cant get that to work for me – user2333346 Jun 13 '13 at 22:15
  • I used account let me modify it for your code. – Rao Jun 13 '13 at 22:16
  • It give me the following error: Error: Download_Test line 1, column 1: Content is not allowed in prolog – user2333346 Jun 13 '13 at 23:05
  • Where are you pasting the page, are you pasting in the VF page area when you are creating the page? – Rao Jun 13 '13 at 23:10
  • yes I am, is that wrong? – user2333346 Jun 13 '13 at 23:20
1

The contents of the repeat seems a bit odd to me.

Try switching it to a outputText using the rendered attribute to toggle the display.

<apex:repeat value="{!accvar}" var="a">
    <apex:outputText value="{0},{1},{2},{3}" rendered="{!a.Downloaded__c}">
        <apex:param value="{!a.First_Name__c}" />
        <apex:param value="{!a.Last_Name__c}" />
        <apex:param value="{!a.Email__c}" />
        <apex:param value="{!a.Quilification__c}" />
    </apex:outputText>
</apex:repeat>

UPDATE: To reverse the logic of the rendered attribute

You can negate the rendered logic by putting a ! within the visualforce expression syntax.

<apex:repeat value="{!accvar}" var="a">
    <apex:outputText value="{0},{1},{2},{3}" rendered="{! !a.Downloaded__c}">
        <apex:param value="{!a.First_Name__c}" />
        <apex:param value="{!a.Last_Name__c}" />
        <apex:param value="{!a.Email__c}" />
        <apex:param value="{!a.Quilification__c}" />
    </apex:outputText>
</apex:repeat>
| improve this answer | |
  • I use the repeat command to download the fields to a CSV file, – user2333346 Jun 13 '13 at 21:41
  • That was my understanding from your example. Is this working for you now or are you still getting a syntax error? If you are getting a syntax error, please include the details in your question. – Daniel Ballinger Jun 13 '13 at 22:00
  • Well basically the code above does not work when I have the Downloaded__c field unchecked. The only way I can get it to work, is to remove NOT and use the code in the opposite manner, hence save the fields when Downloaded__c is checked! so why doesn't NOT work? – user2333346 Jun 13 '13 at 22:19
  • The logic needs to be within the visualforce expression syntax {! expression}. – Daniel Ballinger Jun 13 '13 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.