1

On my VF page when I click on 'submit' button, I have pop-up with confirmation message. Then after clicked 'OK' button on this pop-up, I am redirected to the created record. Things are ok at this stage. Now I want conditional redirection when i'm in Classic or in Console mode. Actually when redirect to Console Mode I can't figure how to not display header and sidebar.

Thanks for any support/advice.

Below the codes :

Archive file

function parseSapExpressOrderResponse(obj,id){
if (obj.ErrorLines && obj.ErrorLines.length > 0) {
var s = ''; for (var i = 0; i < obj.ErrorLines.length; ++ i) s += '\n\t' + 
    obj.ErrorLines [i].Message
      alert(orderError + s);
       normalCursor ();
    }

    else {
      alert(orderSuccess + obj.PurchaseNumber__c);               
       window.location = '/'+id;
    }

VF page

<apex:actionFunction name="validateExpressOrder" action="
{!validateExpressOrder}" rerender="messages,hiddenParams"  
oncomplete="SForderCreated();" >
<!--    <apex:param name="jsonparam" value="{!jsonparam}" /> -->
        </apex:actionFunction> 

    </apex:PageBlock> <!-- class="globalSection" -->
 </div>
 </apex:form>

   <script type="text/javascript" src="{!URLFOR($Resource.ExpressOrderJS)}" 
  />
 </apex:page>
1

When you are in console mode you can check sforce.console.isInConsole() using Salesforce Console Integration Toolkit.

<apex:page standardController="Case">
    <A HREF="#" onClick="testIsInConsole();return false">
         Click here to check if the page is in the Service Cloud console</A> 

    <apex:includeScript value="/support/console/22.0/integration.js"/>
    <script type="text/javascript">
        function testIsInConsole() {
            if (sforce.console.isInConsole()) {
                  alert('in console');
               } else {
                  alert('not in console');
            }
        }
    </script>
</apex:page>

In your case, I hope this blog post will help.

How to open a new record inside a console in SubTab by inline visual force page

<script>

 var preRecordId;

        function testOpenSubtab(id, name) 
        {
            preRecordId= id;
            //First find the ID of the primary tab to put the new subtab in

            alert('URL----->'+'{!$CurrentPage.URL}');

             if (sforce.console.isInConsole())
                sforce.console.getEnclosingPrimaryTabId(openSubtab);
             else
              window.top.location.href = '/' + id;
        }

        var openSubtab = function openSubtab(result) 
        {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;

            sforce.console.openSubtab(primaryTabId , '/'+preRecordId , true, 
                preRecordId , null , openSuccess, 'salesforceSubtab');
        };

        var openSuccess = function openSuccess(result) 
        {
            //Report whether we succeeded in opening the subtab
            /*
                if (result.success == true) 
                {
                    alert('subtab successfully opened');
                } 
                else 
                {
                    alert('subtab cannot be opened');
                }
            */
        };



</script>
1
  • I still be worry about this. I forgot to mention that the redirection code is in a JSON file placed in Static Resource. And I do not have habilitation to move it elsewhere. I've tried different way, but no way to test isInConsole () Redirection must be here " else { alert(orderSuccess + obj.PurchaseNumber__c); window.location = '/'+id; } " – wadjo May 7 '17 at 12:01
0

To be more precise, this is what I'm trying to do.
Thanks in advance.

function parseSapExpressOrderResponse(obj,id){
        if (obj.ErrorLines && obj.ErrorLines.length > 0) {
      var s = ''; for (var i = 0; i < obj.ErrorLines.length; ++ i) s += '\n\t' + obj.ErrorLines [i].Messagealert(orderError + s);
     normalCursor ();
    }

        else { alert(orderSuccess + obj.PurchaseNumber__c);

        If {  if (sforce.console.isInConsole()) {
        testOpenSubtab ();}
                else {window.top.location.href = '/' + id; }

    }

}
0
  function parseSapExpressOrderResponse(obj,id){
    if (obj.ErrorLines && obj.ErrorLines.length > 0) {
      var s = ''; for (var i = 0; i < obj.ErrorLines.length; ++ i) s += '\n\t' + obj.ErrorLines [i].Message
      alert(orderError + s);
       normalCursor ();
    }

    else {   alert(orderSuccess + obj.PurchaseNumber__c);
             if (typeof(srcUp) == 'function') {
             srcUp('/'+id);
                                               }
             else {
                 window.open('/'+id);
                  }
            }
}

I did it. So proud.
I'm not developper, just trying hard.

Thanks people.

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.