You need to sign in to do that
Don't have an account?
Mac Swift
Please help me with the issue.
For example - we have ABC opportunity and having AA, BB, CC products in that opportunity. Now Sales rep won the opportunity and customer wants to purchase only AA and CC product and don't want the BB product. Here Sales rep will delete the BB product from the opportunity and close the deal as "Closed Won"
PROBLEM: Mgt wants the report of the deals with closed lost status. How I can address such issues in my reporting if sales rep delete the products from the opportunity if customer doesn't want them. Logically those are opp lost but not able to track them via reporting.
PROBLEM: Mgt wants the report of the deals with closed lost status. How I can address such issues in my reporting if sales rep delete the products from the opportunity if customer doesn't want them. Logically those are opp lost but not able to track them via reporting.
Here's the steps:
1. Add a new checkbox field in Opportunity Products: Setup -> Customize(Left panel) -> Opportunity -> Opportunity Products -> Fields -> New
In the example, I name this field 'IsDeleted'
2. Create a custom button for Opportunity Products: Opportunity Products -> Button And Links -> New Button And Links
Settings for the btton: Display Type: Detail Page Button, Behavior: Excute Javascript, Content Source: OnClick Javascript.
Copy and paste the following code to the white box in that setting page:
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
var p = new sforce.SObject("OpportunityLineItem");
p.Id = "{!OpportunityLineItem.Id}";
p.IsDeleted__c = true;
result = sforce.connection.update([p]);
if(result[0].getBoolean("success"))
{
alert("Opportunity product updated successfully");
window.location.reload();
}
else
{
alert("Error: " + result);
}
3. Add the button to your page layout: Opportunity Products -> Page Layouts -> (Assmuing you are using the standard layout) Edit -> Drag and drop your button into the layout and save.
Now if you go to your product page, you will find this button.
All Answers
I suggest that instead of completely delete the product, you could create a flag field for addressing if the product is deleted or not. So when your sales rep 'delete' it, it's actully set the flag to true while your data is still there.
Could you please elaborate more. I mean steps to create this functionality.
I am Newbie!
Here's the steps:
1. Add a new checkbox field in Opportunity Products: Setup -> Customize(Left panel) -> Opportunity -> Opportunity Products -> Fields -> New
In the example, I name this field 'IsDeleted'
2. Create a custom button for Opportunity Products: Opportunity Products -> Button And Links -> New Button And Links
Settings for the btton: Display Type: Detail Page Button, Behavior: Excute Javascript, Content Source: OnClick Javascript.
Copy and paste the following code to the white box in that setting page:
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
var p = new sforce.SObject("OpportunityLineItem");
p.Id = "{!OpportunityLineItem.Id}";
p.IsDeleted__c = true;
result = sforce.connection.update([p]);
if(result[0].getBoolean("success"))
{
alert("Opportunity product updated successfully");
window.location.reload();
}
else
{
alert("Error: " + result);
}
3. Add the button to your page layout: Opportunity Products -> Page Layouts -> (Assmuing you are using the standard layout) Edit -> Drag and drop your button into the layout and save.
Now if you go to your product page, you will find this button.
When I copy paste the code for creating the button its working and also able to drag the custom button i.e Delete_Product to the Opportunity Product Layout. But when I go to Opportunity product and try to change the layout for the Product related list the button is not available.
I dont know where I am wrong. Sorry for asking such a basic question as I am trying to learna nd explore.
Thankyou again for your help! Its working now I am able to edit the page layout as well.
Appreciate if you could help me to remove the "Del" button. As if Sales rep use that button in that case again the issue will remain the same. We want that Sales rep are not able to remove the data as it will affect the reports. If there is no "Del" button on the left side then Sales rep needs to click on the product and and then click on the custom button i.e "Delete Product" and then the IsDelete Check box will checked.
Please help me!
Unfortunately, you cannot modify action button with standard page. A simple way is that you could set user's permission to not allow them delete the data, but the action button is still there. Another way is much complicated but it does meet your requirement: You will need to create a VisualForce page and embed your VF page into Opportunity page.
Somebody suggested to have a trigger. So when Sales rep delete the products line item from the opportunity it will update the custome object as opp lost and then we can do the reporting easliy and track those deleted products as well.
Could you help me in creating that kind of trigger.