function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jordan HunterJordan Hunter 

Last Opportunity Product Date

DYING for some help on this one.

I need to pull the last opportunity line item (opportunity product) date and i cant figure out how to do it.

Use Case:
I have an opportunity where a customer has order 100 units, and wants them in 5 drops of 20. So i will need to create 5 different line items, with 5 different drop dates. 
I need to be able to pull out the line with the last drop date into a field on the main opportunity record page.

I have wrapped my brain and cant figure out how to even get close.
mukesh guptamukesh gupta
Hi Jordan,

Please use below code:-
SELECT (
    SELECT Product2.Name FROM OpportunityLineItem
    ORDER BY LastModifiedDate DESC LIMIT 1
) FROM Opportunity WHERE Id = 'opportuity Id'

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Jordan HunterJordan Hunter
Hi Mukesh, 
Thanks for getting back to me. Im struggling as to where to place this code. Ive created a formula field for Opportunity but it wont accept the above code.
Kind regards,
J