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

trigger to create quote problem, Please

Hi everybody, I have a problem on my project, because I am new, so please help me, thank you a lot:)

My problem:

I need automatically create a quote on opportyunity by trigger, and I need use some data from custom object which are from OrderFromWeb__c and Orders__c. So, once I create an order__c, will trigger an new opportunity and then according to this opportunity to create an quote.

could any one can give me a example code for this, thank you:)
Hi - Using a lighning process builder you can able to do this without writing a code.

1. Create a Lighning process builder for ht Order whenever record is created then selecte the action as 'Create record' and create the Opportunity record.
2. Create a another process builder for the object Opportunity with same criteria and create your quote object in the action. 

To know, more about lighning builder take a look into this Trailhead module -
Jayant JadhavJayant Jadhav
trigger CreatingOppAndQuote on Order__c(After insert)
    List<Opportunity> oppCreatelist=new List<Opportunity>();
    List<Quote> quoteCreatelist=new List<Quote>();
    for(ChildObj__c c:
        //Create opportunity based on your requirement i.e assign values form your custom object to opportumnity
       //You can use your OrderFromWeb__c data to create opportunity.
        Opportunity opp=new Opportunity();;
        //Create opportunity based on your requirement i.e assign values form your custom object to opportumnity
        Quote qt=new Quote();;
    insert oppCreatelist;
    Integer numberOfRecords=oppCreatelist.size();
    // Assign opportunity to Quote
    for(Integer i=0; i<numberOfRecords;i++)
    insert quoteCreatelist;

Let me know if this works for you.