You need to sign in to do that
Don't have an account?
Kondal Patchala
unable to get Opportunity record url into java-script
Hi All,
i am trying to create new button(custom survice item) with javascript to autopopulate record type when create child record . so all the work has done and place the button on parent related list layout and its works when click button on view page related list . but have a issue when click on related list summary ( top of the record )
getting url code in java script is
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var refurl = window.location.href;
i am placing alert as part of debugging , when i click on related list on detail page, refurl stores correct page url , which is expected (https://cs17.salesforce.com/006g0000004UHMh)
But when i click on the same button(custom survice item) from the related list summary on detaild page, different url stores in refurl.
Can anyone please suggest me what is the wrong in the above case or any process or tag to store current page url in java script
Kind Regards,
Patchala
i am trying to create new button(custom survice item) with javascript to autopopulate record type when create child record . so all the work has done and place the button on parent related list layout and its works when click button on view page related list . but have a issue when click on related list summary ( top of the record )
getting url code in java script is
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var refurl = window.location.href;
i am placing alert as part of debugging , when i click on related list on detail page, refurl stores correct page url , which is expected (https://cs17.salesforce.com/006g0000004UHMh)
But when i click on the same button(custom survice item) from the related list summary on detaild page, different url stores in refurl.
Can anyone please suggest me what is the wrong in the above case or any process or tag to store current page url in java script
Kind Regards,
Patchala
Appreciate if you mark it as Best Answer if it solves your problem :)
All Answers
The related list you see in the quick navigation menu renders in an iframe which is the reason why you see different ref url.
You can add a small check in your javascript code for this and get the parent url in both cases as below:
Let me know if you need any other help.
Thank for your reply, after inserting the code you give is work fine and it bring parent url for both cases but i am facing another issue after refurl alert, when click the button through quick navigation menu , please find bellow for new error and i am posting complete code where i am bring opp id from url.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
alert("hiiiiiiii111111");
var refurl = window.location.href;
if (refurl.indexOf("emptyHtmlDoc") > -1) {
refurl = window.parent.location;
}
alert(refurl);
var stpos = refurl.lastIndexOf("/")+1;
alert(stpos);
var endpos = refurl.length;
alert(endpos);
var strOppId = refurl.substring(stpos,endpos);
alert(strOppId);
}
Regards,
Patchala
Appreciate if you mark it as Best Answer if it solves your problem :)