I’m not sure how to do this, and can use some advice.
I created a custom button on a standard page layout, and when the user clicks it, I want to check if the user has contacts in this object.
If he doesn’t, I want to display an alert- “please add contacts” and and return him to his current STANDARD page. Otherwise, I want him to get to a new VF page that is already written.
I’m not sure how to do this…
HALP!
Code:
<apex:page standardController="MY_List__c" extensions="MYListExtension" >
<apex:form >
<script>
var hasContact = {!totalContacts};
if(hasContact == 0 ){
alert('Please add contacts!');
window.location ="/" + {"!theListId"};
}
else{
window.location = "/MYListSend?id=" + {"!theListId"};
}
</script>
</apex:form>
</apex:page>
Try this out:
The apex class:
And the visualforce page: