You need to sign in to do that
Don't have an account?
Sebastian Żuliński
Acces to specific pricebook and produckt paige
Hello,
I have a problem with JavaScript button which i wanna put to our opportunity paige to make faster acces to specific products.
Code looks like this:
var loc;
loc = "/p/opp/SelectSearch?";
loc +=
"addTo={!Opportunity.Id}&" +
"retURL={!Opportunity.Id}&" +
"sfdc.override=1&" +
"rolodexIndex=21";
window.top.location.href = loc;
with that code i can acces to specific place but i don;t know how to skip step with choosing pricebook when i have a pricebook ID.
If someone can help me with info how i can put to code pricebook ID to identify it and skip manual pricebook validate for actual opportunity.
My code work fine when pricebook is already choosen and validate.
Thx in advance.
I have a problem with JavaScript button which i wanna put to our opportunity paige to make faster acces to specific products.
Code looks like this:
var loc;
loc = "/p/opp/SelectSearch?";
loc +=
"addTo={!Opportunity.Id}&" +
"retURL={!Opportunity.Id}&" +
"sfdc.override=1&" +
"rolodexIndex=21";
window.top.location.href = loc;
with that code i can acces to specific place but i don;t know how to skip step with choosing pricebook when i have a pricebook ID.
If someone can help me with info how i can put to code pricebook ID to identify it and skip manual pricebook validate for actual opportunity.
My code work fine when pricebook is already choosen and validate.
Thx in advance.
In following code replace the bold parts with id's from your org (pricdebookid is the id of the pricebook you would like set as default)
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
var pricebookid = "01sw0000000UGtr";
var opportunityId = "{!Opportunity.Id}";
var opportunityQuery = sforce.connection.query("Select Id, Name FROM Opportunity WHERE Id='" + opportunityId + "'");
var opptyResult = opportunityQuery.getArray("records");
opptyResult[0].Pricebook2Id = pricebookid;
var updateopptyResult = sforce.connection.update([opptyResult[0]]);
var loc;
loc = "/p/opp/SelectSearch?";
loc +=
"addTo={!Opportunity.Id}&" +
"retURL={!Opportunity.Id}&" +
"sfdc.override=1&" +
"rolodexIndex=21";
window.top.location.href = loc;
I tried this in my org and works fine.
Please select as best answer if it helped you ;-)
All Answers
In following code replace the bold parts with id's from your org (pricdebookid is the id of the pricebook you would like set as default)
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
var pricebookid = "01sw0000000UGtr";
var opportunityId = "{!Opportunity.Id}";
var opportunityQuery = sforce.connection.query("Select Id, Name FROM Opportunity WHERE Id='" + opportunityId + "'");
var opptyResult = opportunityQuery.getArray("records");
opptyResult[0].Pricebook2Id = pricebookid;
var updateopptyResult = sforce.connection.update([opptyResult[0]]);
var loc;
loc = "/p/opp/SelectSearch?";
loc +=
"addTo={!Opportunity.Id}&" +
"retURL={!Opportunity.Id}&" +
"sfdc.override=1&" +
"rolodexIndex=21";
window.top.location.href = loc;
I tried this in my org and works fine.
Please select as best answer if it helped you ;-)
Your code work perfect. This is what exactly i wanna :)
best regards
Sebastian
So here is the modified code snippet:
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
var pricebookid = "01sw0000000UGtr";
var opportunityId = "{!Opportunity.Id}";
var opportunityQuery = sforce.connection.query("Select Id, Name FROM Opportunity WHERE Id='" + opportunityId + "'");
var opptyResult = opportunityQuery.getArray("records");
if(opptyResult[0].Pricebook2Id != null){
opptyResult[0].Pricebook2Id = pricebookid;
var updateopptyResult = sforce.connection.update([opptyResult[0]]);
}
var loc;
loc = "/p/opp/SelectSearch?";
loc +=
"addTo={!Opportunity.Id}&" +
"retURL={!Opportunity.Id}&" +
"sfdc.override=1&" +
"rolodexIndex=21";
window.top.location.href = loc;