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
Karna_ShivaKarna_Shiva 

when i click button, it is redirecting another page, but that page is opened in a same page

Generally, we have links on opportunity header to check count of line item or  etc and i am trying to create Opportunity line item from opportunity header link, but it is opening opportunity line item insert page in header page itself, i mean please see my screen shot.

actually i want to show line item insert page, when user click serivce line item button on Opportunity header links

Code, I have written in Button.

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var opp = new sforce.SObject("Opportunity");
opp.Name = "{!Opportunity.Name}";

if('{! Opportunity.Count_Closure__c}' == 0)
 {
window.location.href='/apex/OppClosureDeclaration?CF00Ne0000000sJl7=opp.Name&CF00Ne0000000sJl7_lkid={!Opportunity.Id}&scontrolCaching=1&retURL=%2F{!Opportunity.Id}&sfdc.override=1';
}else
  alert('OPPORTUNITY CLOSURE IS ALREADY SUBMITTED');

User-added image
Best Answer chosen by Karna_Shiva
Shashikant SharmaShashikant Sharma
Try to use this : window.parent.location.href
                        instead of 
                        window.location.href

 

All Answers

Shashikant SharmaShashikant Sharma
Try to use this : window.parent.location.href
                        instead of 
                        window.location.href

 
This was selected as the best answer
Karna_ShivaKarna_Shiva
i used parent.location.href, its worked.

Thanks for your reply.
Shashikant SharmaShashikant Sharma
Glad that it helped you :) .