You need to sign in to do that
Don't have an account?
Sjaleel
Condtional Button
Dear Developers,
Is there a way to make a button conditional, that is the button command would be only executable depending on the value of a certain field in the object.
For eg.
If the status in the page is approved , the button would be excutable that would deirect to an email page that is.
Can anyone help me on this?
Regards and thanks in advance
Problem must be here :
Conditions must not be matching...So alert will help you to know that code in coming in if condition or not..Also use toLowerCase and match the conditions.
All Answers
you can do like this
<apex:commandButton value="Delete" disabled="{!if((status == 'approved') ,'false','true')}" action="{!DeleteShipDetail}" immediate="true" id="btndel" rerender="ShipmentDetailList" status="deleteStatus" >
u can disable the button like above or u can hide the button by using the style property...
its not a comman button in VF page, but a custom button on the objects page.
Thanks and regards
You can do something like this :
<apex:commandButton value="SendMail" rendered="{!if((status == 'approved') ,true,false)}" action="{!YourEmailRedirectMethod}" >
Sorry we posted at the same time so was not able to see your latest comment. Now to disable the button : I don't think so we can do this. But somehow possible if you can create a hompagecomponent which will run a script which in end will hide the button.
Or you can write a JS on your custom button on object which will give a error alert if your conditions are not fulfilled.
Add if condition in the custom button javascript code.
For ex:
if('{!CustomObject.status}' == 'Approved')
{
//add the functionality that should execute if the above condition is true
}
Let me know if it did not work.
it didnt work
it gives an error " A problem with the Onclick Java Scrpt for this button was encountered Unexpected token }
if('{!CustomObject.status}' == 'Approved')
{
/apex/MaintenanceReserveInvoice?id={!CustomObject.Id}
}
Thanks anr regards
Try this :
The button is not working, no error messages neither any results!
Thanks and Regards
Problem must be here :
Conditions must not be matching...So alert will help you to know that code in coming in if condition or not..Also use toLowerCase and match the conditions.
Thanks alot worked like a charm
^__^
Regards
SAj