function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NM AdminNM Admin 

Related visualforce list button is not working for newly created parent record at very first time in service console?

Hello There,

I am facing an issue with the related list button for the Case in service cosnole is below:

I have a functionality to create a child record for the Case object from the custom object 's related list on the Case in classic service cosnole. When I create new Case record from service cosnole , navigate  to the related list and click on the button (custom visualforce list button) to create new child record. In result it is opening a primary tab and closing it again in few seconds instead of open a new record creation form in a new subtab under the current primary tab.

I am getting expected result if we refresh the cuurent browser tab and the follow the same process its workig fine for me.

But not getting what is happening in very first time after creating the Case record and click on the related list button to create new child record?

Can anybody suggest me something if i am doing anything wrong in this?

Here is the current snippet of the code:
<script type="text/javascript">
    window.onload = function(){
           testOpenSubtab();
        }
        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
           CloseTabTest();
        }
        
        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 , 'myURL', true, 
                'salesforce', 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');
            }
        };

     function CloseTabTest() {
            //First find the ID of the current tab to close it
            sforce.console.getEnclosingTabId(closeSubtab);
        }  
        
        var closeSubtab = function closeSubtab(result) {
            //Now that we have the tab ID, we can close it
            var tabId = result.id;
            sforce.console.closeTab(tabId);
        };

    </script>

Please do let me know is there any way to overcome this issue.


Welcome to your suggestions!


Regards,
Nilesh