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
sai ramsai ram 

opportunity stage is changed closed won it must contain one opportunitylineitem

using validation rule or processbuilder
opportunity stage is changed closed won it must contain one  opportunitylineitem.
with out apex coding is possible
AbhishekAbhishek (Salesforce Developers) 
No without apex it's not possible.

For code, you can check the below discussions,

https://trailblazers.salesforce.com/answers?id=90630000000D0oNAAS

https://salesforce.stackexchange.com/questions/66936/fire-trigger-only-when-stages-moves-to-closed-won


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
Maharajan CMaharajan C
Hi Sai,

Using Lightning Flow we can do this. But you have to perform small POC for this.

Components Needed :
1. Before Save Auto Launch Flow.
2. One Custom Field (Checkbox Field).
3. Validation Rule (Fire Validation based on above custom field is true).

Steps :
  • In the before save flow first you have to check the Opportunity Stage is Closed Won or not using Decision ( $Record > Stagename).
  • iIf the StageName is ClosedWon yes then Use GET Records Element to query the OpportunityProduct by using the Opportunity id ($Record > Opportunity Id) in Filter.
  • Again create the Decision Element to check the get record is null or not.
  • If get record is null true then use the Assignment Operator to update the above created custom checkbox field as True. No need for seperate record update here because we are doing this before flow. This will fire the validation rule.
https://www.accidentalcodersf.com/2020/06/before-save-update-flows.html
https://www.linkedin.com/pulse/using-before-save-flow-prevent-record-creationupdate-based-gidi/


Thanks,
Maharajan.C