Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Identify field values for Last Order

Posted on by 85

Hi Community

Looking to identify the last Order ID, Last Order Value and first product of the last order. Ideally would need to do this in Company (Account) entity and Customer (Contact) entity.

Have created a field LastOrderDate (both Company (Account) entity and Customer (Contact) entity) to identify date of last order.

Can not see a First or Last aggregate function, so cannot see how to do this as either a rollup or calculated field.

Is it possible to do this?

*This post is locked for comments

  • Mark WHE Profile Picture
    Mark WHE 85 on at
    RE: Identify field values for Last Order

    tyler many thanks.

    I was hoping for a non plugin way, but kind of figured that would not be possible for the first product.

    Neat simple solution.

  • Verified answer
    TylerS.Dev Profile Picture
    TylerS.Dev 725 on at
    RE: Identify field values for Last Order

    For last Order ID, you can add this field to both account and contact entity, create a workflow that triggers on work order create, and update those fields with last order ID.

    First product from last order is a bit more tricky.   I would create a plugin for this.  First you still need to create last product field in both account and contact entity.  Have this plugin fire on order product entity upon create.  First have the plugin check if this order product created belong to the latest order.  If yes, use either query expression or fetchxml in plugin to pull product of line 1 with condition that order guid equals the order quid of the order product record that was created, and update product to those two fields.

    For last order value, you can apply this same logic as first product from last order using plugin, you can use totalamount field from order entity and use this field to populate the other two.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans