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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Line Item Number in Quote Product via Add Products

(0) ShareShare
ReportReport
Posted on by 10

When users are adding Quote Products to a Quote through the Products/Add Products section, often they find that when they return to the quote, the order that they selected the products has not been retained.

There is a LineItemNumber field in the QuoteProducts that could be used, however this would require manual entry which does not seem feasible, my thoughts are that a counting sequence for each quote could be used and the InLine view could be sorted based on this counting number.

I could add a auto-sequencing field to Quote Products but this wouldn't relate to the specific quote and would count without reference, this would work in theory in terms of sorting the quote, but I don't feel it is a rounded solution.

Viewing older posts I found the following discussion:

   

It details using JS and an OnTrigger event to automatically count in sequence depending on if it finds a match for the Quote GUID, I've adapted the following code and have it working in Sandbox, but it only works when actually going into the Quote Products form, and not using the 'Add Products' feature:

function Line_OnSave()
{
    if (Xrm.Page.getAttribute("lineitemnumber").getValue() == null) {
        var serverUrl = Xrm.Page.context.getClientUrl();
        var QuoteGuid = Xrm.Page.getAttribute("quoteid").getValue()[0].id;
        var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/QuoteDetailSet?$select=LineItemNumber&$orderby=LineItemNumber desc&$filter=QuoteId/Id eq guid'" + QuoteGuid + "'&$top=1";
        var req = new XMLHttpRequest();
        req.open("GET", oDataSelect, false);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
        req.onreadystatechange = function () {
            if (req.readyState === 4) {
                if (req.status === 200) {
                    var retrieved = JSON.parse(req.responseText).d;
                    if (retrieved.results.length > 0) {
                        Xrm.Page.getAttribute("lineitemnumber").setValue(parseInt(retrieved.results[0].LineItemNumber) + 1000);
                    }
                    else {
                        Xrm.Page.getAttribute("Lineitemnumber").setValue(1000);
                    }
                }
            }
        };
        req.send();
    }
}
Is there a way this could be adapted to trigger when the Add Products event occurs, or is there potentially a different way that I could achieve auto sequencing for Quote Products within a Quote?
I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans