You need to sign in to do that
Don't have an account?
Run apex code on load via javascript
Hey all, so my goal here is if they are redirected to this custom visual force page and certian ticket information is not present it redirects them to the edit page to add the apropriate information, however I cannot get the visual force page to see my functions when editing the java (see below)
Visual Force Page:
<apex:page standardcontroller="Case" extensions="EscalateTicket">
<apex:sectionHeader title="Change Status" subtitle="Please select the new status below"/><style>
textarea { width:50%; height:120%; }
</style><script>
window.onload = CheckCategories;
function CheckCategories() {if ({!CheckCats()} == false)
{alert ("Categorization Information not entered, Skipping to edit");document.location =
"{!GoToEdit}" }}
</script> <apex:form ><apex:pageblock >
<apex:pageBlockSection title="Escalation Selection" columns="1">
<apex:selectList value="{!NewAssignment}" multiselect="False" Required="True">
<apex:selectOptions value="{!Groups}"/></apex:selectList>
<apex:inputField value="{!case.Escalation_Comments__c}" Required="True"/>
</apex:pageBlockSection></apex:pageblock><
apex:commandButton action="{!Save}" value="Escalate Ticket"/></apex:form>
</apex:page>
The error message I get is "Unknown Function CheckCats Check Spelling"
The apex methods in question are below
Apex Class
public class EscalateTicket {
private final Case c;
public EscalateTicket(ApexPages.StandardController stdController) { this.c = (Case)stdController.getRecord();}
public Boolean CheckCats(){
if ((c.type == '') || (c.Sub_Category__c =='' ) || (c.reason == '')) {return False;} return true;}
public PageReference GoToEdit(){return new PageReference('/' + c.id + '/e?retURL=%2F' + c.id);}
}
You don't need the brackets after checkCats. The fact that you have included them makes the platform think that you are trying to invoke a formula type of function (like isNull() for example) that doesn't exist.
Yes,
if I do this if (!CheckCats == false) I get a javascript error as shown below
Message: 'CheckCats' is undefined
Line: 118
Char: 2
Code: 0
URI: https://c.cs3.visual.force.com/apex/EscalateTicket?scontrolCaching=1&id=500Q0000001IrJa
if I do this if ({!CheckCats} == false) I get the save error below from salesforce
Save error: Unknown property 'CaseStandardController.CheckCats' Salesforce Sandbox/src/pages EscalateTicket.page line 0 1263852967942 3544
if I do this if ({!CheckCats()} == false) I get the save error below from salesforce
Save error: Unknown function CheckCats. Check spelling. Salesforce Sandbox/src/pages EscalateTicket.page line 0 1263853087524 3547
if I do if (!CheckCats() == false) I get the following javascript error (The line and char are the if statement)
Message: Object expected
Line: 118
Char: 2
Code: 0
URI: https://c.cs3.visual.force.com/apex/EscalateTicket?scontrolCaching=1&id=500Q0000001IrJa
Why do I feel like this should be a lot easier than it is being
Thanks for all your help bob, I actually figured out a work around.. if VisualForce wants to see it as a property, I let it. I just changed my functions to properties and when it does a getvalue I have it perform the code I wanted it to execute instead of doing it as a function. Its a bit dirty for my code practices ,but it works so that makes me warm and fuzzy
Thanks for your help!
~Rick