1

I basically need to mimic the button content source: Visual Force Page logic enter image description here

I can't use the Visual force drop down button because I need to check that a field is filled in first. So I need to use the javascript option instead, but still need to navigate to a visual force page. I also can't make that field mandatory before saving.

Code:

var id = '{!Case.Paradigm_ID__c}';
if(id.length == 0){
     alert("No Paradigm ID, SSRS History will not be linked");
}
else{

     window.location = //link to visual force page here
}
  • Can you be a little more clear what you're trying to do? You just want the user to be able to click a button to take them to a page, but only if a field is filled out? You can still use a VF element and combine it with JS.. – Brian Mansfield May 14 '15 at 20:42
  • What vf element? This is within the custom buttons and actions setup area. It's exactly the same thing that the 'Content Source: VisualForce Page' does just with a preliminary step. – TemporaryFix May 14 '15 at 20:45
  • Oh, I thought this was on a VF page, you didn't say anything about being the definition of a custom button haha. I see it now. Anyway, what exactly is the trouble you're having with this? You're trying to reference a field on Case in the JavaScript of a custom button? – Brian Mansfield May 14 '15 at 20:47
  • How would I navigate to the custom visualforce page? The vf page uses a case as a standard controller, and the vf page uses the case's fields. So when navigating to it, it would have to know case that it navigated from. – TemporaryFix May 14 '15 at 20:50
  • You misunderstand me, I just mistakenly thought you were talking about this in the context of a page, I'm not saying you should do that haha. One solution would be to do a SOQL query in the JS based on the id from the URL. There is probably a more elegant or "recommended" solution but it would work. – Brian Mansfield May 14 '15 at 20:52
1
window.location.href='/apex/VFPageName'

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.