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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to reset the sequence number in a product line when I delete a product line in a quote?

(0) ShareShare
ReportReport
Posted on by 5

Hello everyone I have the following situation: Example: I have a quote with 5 product lines, in each line the line sequence number appears 1,2,3,4 and 5, which is fine. The problem is when I want to make a modification in the quote, for example, delete the third product line, when saving changes, I have the sequence numbers: 1,2,4, and 5. Is there a way to restart this count when one or more product lines are eliminated? in this case to appear 1,2,3,4. I hope I have made myself understood Thanks

I have the same question (0)
  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at

    Hi,

    Thank you for your query.

    I assume this seq. no. is a custom field and being calculated when a quote product is created. Because it is real-time (i guess), it is achieved using a custom code activity (custom workflow step) or a plugin.

    In either case, you need to either modify the existing code or implement a new plugin (preferred) as following:

    • Trigger the plugin on Delete of Quote Product
    • RetrieveMultiple Quote Products based on Parent Quote ID (except the one got deleted).
    • Reset seq. no. based on each Quote Product.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Nahumjn,

    You can create a flow to reset the sequence number in a product line, which is a no-code way, so it is easier to operate and implement what you want.

    Overview of the flow.

    pastedimage1615185761709v7.png

    Here are steps.

    1.Go Power Automate(https://us.flow.microsoft.com/en-us/ ) to create an Instant flow.

     pastedimage1615185814918v8.png

    2.Set trigger.

     pastedimage1615185332508v1.png

    Note: I was going to use the ‘when a record is deleted’ trigger at first, but it couldn't detect the deleted record information (quoteguid) in step4, so I had to use the manual trigger.

    3.Initialize variable.

    pastedimage1615185368086v2.png

    4.List records.

    pastedimage1615185409396v3.png

    5.Apply to each

    pastedimage1615185504407v4.png

    5.1 Increment variable

    pastedimage1615185559696v5.png

    5.2 Update a record.

    pastedimage1615185694217v6.png

    6.Test.

    Go to the quote(deleted quote line)  form, expand flow to run the flow that just created.

    I have deleted one quote line---test3.

    pastedimage1615186003285v9.png

    Results:

    I found that they reset sequence number based on created on field value.

    pastedimage1615186140771v10.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Nahumjn Profile Picture
    5 on at

    thank you so much, i'm trying to replied your instructions, but in step 4 (list records) i'm not sure what is te expression or formula for this area:

    pastedimage1615224515121v1.png

    could you guide me on this?

  • Verified answer
    Wahaj Rashid Profile Picture
    11,321 on at

    Hi,

    The expression should go like this:

    _quoteid_value eq '<Choose column named Quote here from the Dynamics content>' (not sure if the Display name of the column is translated here).

    Basically, you need retrieve the quote lines based on the ID of the parent Quote, which is stored in the Quote column.

    As Leah mentioned, using flow is easier then plugin/custom code activity, but please note, it will not work in real-time.

    This means, when you delete a quote line, it may take a while to fix the sequences.

    If that's okay in your scenario, go for a flow, otherwise you need to do it using code.

  • Nahumjn Profile Picture
    5 on at

    Thank you very much Leah Ju/Wahaj Rashid

    It works,

    Appreciate your help

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Pallavi Phade Profile Picture

Pallavi Phade 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans