You need to sign in to do that
Don't have an account?
Kate Starostina 13
Need some help with Custom Button code
I have a custom button on Quote/Proposal object (Apttus) that looks at the Line Items, sees if one of them has the Sample check box checked and if so, pulls that line item into a Visual Force page to place a sample order. The code from the Quote/Propsal is pasted below. What I am trying to do is replicate this behavior on the Opportunity Product. I've created the same Sample_c button on the Opportunity Product object and I have added the button on the Opportunity page layout. What I would like is that when the user clicks the button from the Opportunity that same VF page is invoked. So I need to make changes to this code, but I have no idea what I'm doing.
-->PS_CreateSampleOrder is the name of the VF page.
-->Behavior is Execute JavaScript
-->Display type is Detail Page Button
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
var sampleOrderPage = "/apex/PS_CreateSampleOrder?Id={!Apttus_Proposal__Proposal__c.Id}";
var propLineItemRecs = sforce.connection.query("SELECT Id FROM Apttus_Proposal__Proposal_Line_Item__c WHERE Apttus_Proposal__Proposal__c = '{!Apttus_Proposal__Proposal__c.Id}' AND Sample__c = true");
records = propLineItemRecs.getArray("records");
if(records.length > 0){
window.open(sampleOrderPage, "_self");
}
else {
alert("{!$Label.PS_CreateSampleOrderNoSampleProdsError}");
-->PS_CreateSampleOrder is the name of the VF page.
-->Behavior is Execute JavaScript
-->Display type is Detail Page Button
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
var sampleOrderPage = "/apex/PS_CreateSampleOrder?Id={!Apttus_Proposal__Proposal__c.Id}";
var propLineItemRecs = sforce.connection.query("SELECT Id FROM Apttus_Proposal__Proposal_Line_Item__c WHERE Apttus_Proposal__Proposal__c = '{!Apttus_Proposal__Proposal__c.Id}' AND Sample__c = true");
records = propLineItemRecs.getArray("records");
if(records.length > 0){
window.open(sampleOrderPage, "_self");
}
else {
alert("{!$Label.PS_CreateSampleOrderNoSampleProdsError}");