1

I have a VF link on a page which creates a new record. It's embedded on a page layout. My problem is that I would like errors to show in the embedded section without redirecting, but if it's successful, I would like the page to redirect to the new record. Is there is way to say if the page has errors, target = '_self' else target = '_top'?

Something like:

<apex:commandLink action="{!autoRun}" value="Create Dog Record" target="{!pgTarget}"/>

This doesn't work because it doesn't update the pgTarget part.

1
  • Did my ans solve your purpose? If so, then close the ques Commented Nov 14, 2016 at 15:47

1 Answer 1

1

You can use oncomplete function rather than using target as below:

<apex:commandLink action="{!autoRun}" value="Create Dog Record" oncomplete="doRedirect('{!pgTarget}')"/>

<script>
function doRedirect(param){
    if(param == '_top'){
        window.open('<pageURL>',param);
    }   
}
</script>

It has been assumed that you will assign correct pgTarget inside the controller based on successful or error condition.

1
  • Thanks for the response. I had found a different work around using this post: stackoverflow.com/questions/11552514/… I will however try your answer when I have time later to see if it works out and mark it as the answer if it functions as expected.
    – Jennifer
    Commented Nov 16, 2016 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .