web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Delete all opportunity product line items in opportunity

(0) ShareShare
ReportReport
Posted on by 45

Hello,

I am looking for a way to allow the user to delete all product line items in an opportunity in one go.

Does anyone know how this can be accomplished please.

Currently they have to delete it line by line with the trash can icon on each line.

Appreciate the assistance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,032 Moderator on at

    Hi e0209,

    I recommend using the Bulk Record Deletion feature for removing large amounts of product line records.

  • e0209 Profile Picture
    45 on at

    Thank you Adrian for your reply.

    However I am not removing large amounts of product line records.

    It's just for the convenience of the user to remove all products (probably 5 to 10 lines each time they use it) and reuse the opportunity to add products to get latest pricing.

  • Suggested answer
    Pawar Pravin Profile Picture
    5,237 on at

    Hi,

    I can suggest you as in case of if they want to delete all product line items of respective opportunity you need to create one custom button on opportunity called as as "Delete Products".

    On that button you can call synchronous js/plugin to delete related all product items.

  • e0209 Profile Picture
    45 on at

    Thanks Pravin, that sounds like a viable solution.

    Do you have any resources/tutorials and plugins/js you have come across which you can share on creating custom button to do this?

    Appreciate your response :)

  • Suggested answer
    Adrian Begovich Profile Picture
    1,032 Moderator on at

    Hi e0209,

    You can create a custom button with the Ribbon Workbench for Dynamics 365 & Dynamics CRM.

  • Verified answer
    Pawar Pravin Profile Picture
    5,237 on at

    Hi ,

    Please do follow steps as given:

    1. Create custom button on opportunity using ribbon workbench or ribbon editor

    ribbonworkbench.uservoice.com/.../358664-create-a-command-bar-button-for-your-custom-acitiv

    2. Call js/ plugin on button click using command action but make sure that should be synchronous

    (For plugin either use background flag or custom action)

    sasankkomarina.wordpress.com/.../delete-record-plugin-in-crm-2011

    a2zcrmstuff.blogspot.com/.../mscrm-javascript-delete-record-using.html

    arunpotti.wordpress.com/.../crm-delete-record

    https://www.inogic.com/blog/2016/04/how-to-delete-recordfield-value-using-the-web-api-in-dynamics-crm/

  • e0209 Profile Picture
    45 on at

    Awesome Pravin! Will look through the links you have shared.

    Appreciate your assistance and have a good weekend ahead.

  • e0209 Profile Picture
    45 on at

    I'm close to being successful on this. 

    Created a button using RibbonWorkbench and set it to ran a javascript in webresource.

    Currently using the v9 code suggested at https://arunpotti.wordpress.com/tag/crm-delete-record/ and changing opportunityproduct.

    It works if I feed it the GUID of the opportunityproduct within the opportunity 

    function DeleteRecord() {
     // Delete Account record
     Xrm.WebApi.deleteRecord("opportunityproduct", "9C36DC38-79E9-E711-A95E-000D3AF27CC8").then(
     function success(result) {
     // Perform operations on record deletion
     Xrm.Utility.alertDialog("Account deleted", null);
     },
     function (error) {
     // Handle error conditions
     Xrm.Utility.alertDialog(error.message, null);
     });
    }
    

    How can I dynamically fetch the list of GUIDs of all opportunityproducts within the opportunity and pass it in the required format to the Xrm.WebApi.deleteRecord function to delete all opportunityproducts within the opportunity?

    Appreciate any assistance.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans