1

I have to append a text PUNS to a date field (weird customer requirement!) if a custom field "Material Group" material_group__c in Object Order Line has certain values A, AB, C.. Since changing this on UI seems to be the best idea, so I tried as the following....

       <apex:column title="Estimated Delivery Date">
                     <apex:facet name="header">EDD</apex:facet>              
                     <apex:outputText value="PUNS-{0, date, MM'/'d'/'yyyy}" rendered="if(p.material_group__c = 'A', 'AB', 'C')">
                     <apex:outputText value="{0, date, MM'/'d'/'yyyy}" rendered="if(NOT((p.material_group__c = 'A', 'AB', 'C'))">
                     <apex:param value="{!p.planned_ship_date__c}" /> 
                    </apex:outputText>     
                 </apex:column>  

Logic is append a text if it belongs to a series of vlaues else display normal date. Even though the group is correct, it's not working. I guess I'm lacking correct syntax.

Please guide. Thanks.

  • when you say A, AB, C do you mean A (or) AB (or) c if so I would use if(OR(p.material_group__c = 'A', p.material_group__c ='AB', p.material_group__c ='C')) – Rao Oct 13 '14 at 15:32
  • Yes, I meant A (or) AB (or) c .I have around 10 such groups. Let me try your method – MnZ Oct 13 '14 at 15:39
  • Hi @rao. I tried "IF(OR(p.material_group__c = 'A', p.material_group__c ='AB', p.material_group__c ='C')) ">. Didn't work – MnZ Oct 13 '14 at 15:45
2

Following is the answer

 <apex:outputText value="{!IF(OR(p.gew_material_group__c = 'N2',p.gew_material_group__c = 'P2'),'Week Of-{0, date, MM/d/yyyy}','{0, date, MM/d/yyyy}')}">

Posted as an idea from @neff.

1

When I use the following code :

<apex:page standardController="account">          
<apex:outputText value="PUNS-{0, date, MM'/'d'/'yyyy}">
<apex:param value="{!Account.createddate}"/> 
</apex:outputtext>
</apex:page>

I see the output on my vf page as :

PUNS- 09/22/2014

1) Are you seeing

PUNS-{0, date, MM'/'d'/'yyyy}

IF yes :

The reason is your param is enclosed only for the 2nd output text val, so you are seeing a basic text

FIX:

    <apex:outputText value="PUNS-{0, date, MM'/'d'/'yyyy}" rendered="if(p.material_group__c = 'A', 'AB', 'C')">
   <!-- Display todaysdate-->
    <apex:param value="{!Now}" />
    </apex:ouputText>

IF above is not true ( ie ) NO :

Check your renedered logic ( I would take the rendered attribute off the second outputtext and check if the date value is rendering fine, if it does you will have to look at why the render is not working)

enter image description here

Update:

Your syntax:

<apex:outputText value="{!IF(OR(p.material_group__c = 'N2')),'Week Of-{0, date, MM'/'d'/'yyyy}','{0, date, MM'/'d'/'yyyy}'}">

Corrected syntax: You closed the IF loop after the OR it has to be {!IF( condition, value1, value2)}

  • I see no text. Do I need to have another param ? I removed the rendered part, text correctly gets appended. I guess the condition statement syntax is incorrect. – MnZ Oct 13 '14 at 16:07
  • It is rendered that is causing the issue then. Did you try IF(NOT(OR(p.material_group__c = 'A', p.material_group__c ='AB', p.material_group__c ='C'))) " on the rendered logic for the outputtext? – Rao Oct 13 '14 at 16:10
  • As far as I know, rendered either displays the value or hides it. I'm unable to display another value if the condition is false. I wanted to achieve this in visualforce. I can do that on controller using flag but better if it was on vf. – MnZ Oct 13 '14 at 16:14
  • Yes rao I did try the not condition also – MnZ Oct 13 '14 at 16:14
  • Let me try the if condition inside value – MnZ Oct 13 '14 at 16:17

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.