Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Enable Quotes and Order using Post install Script

    Tagged: CRUD Operation, Metadata API, Order, Post Install Script, Quote, Salesforce Force.com, SessionId

    • Salesforce® Discussions

      Enable Quotes and Order using Post install Script

      Posted by Bhavesh on March 29, 2016 at 4:33 AM

      Hello Team,

      I want to enable Quotes and Order object using Post Install Script. Is it possible?

      Abhinav replied 9 years, 8 months ago 3 Members · 9 Replies
      • CRUD Operation
      • Metadata API
      • Order
      • Post Install Script
      • Quote
      • Salesforce Force.com
      • SessionId
    • 9 Replies
    • Naman

      Member
      April 1, 2016 at 11:03 AM

      Hi Bhavesh,

      We can only enable the Quotes and Order settings either by point and click or by using Metadata APIs. See the below link -

      https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_quotessettings.htm
      https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_ordersettings.htm

      We can use the above links info in apex class like below

      HTTP h = new HTTP();
      HTTPRequest req = new HTTPRequest();
      req.setMethod('POST');
      req.setHeader('Content-Type', 'text/xml');
      req.setHeader('SOAPAction', 'create');

      String b = '';
      b += '';
      b += 'true';
      b += '
      ';
      req.setBody(b);
      req.setCompressed(false);
      req.setEndpoint('https://na12-api.salesforce.com/services/Soap/m/25.0');
      HTTPResponse resp = h.send(req);

      In apex, we can do only simple CRUD operations using Metadata APIs.

    • Bhavesh

      Member
      April 11, 2016 at 6:02 AM

      Hi naman,

      I have managed package in which Opportunity, Quotes and Order I have. Now when customer is installing it at that time it is giving the error that please enable quotes.

      I want that when customer installed this managed package at that time if Quotes is not enable , enable it by some code without knowing to customer.

       

      Is it possible?

    • Abhinav

      Member
      April 11, 2016 at 11:25 AM

      Yes it is possible.

      HttpRequest request = new HttpRequest();
      request = new HttpRequest();
      request.setEndpoint('https://ap2.salesforce.com/services/Soap/m/31.0');
      request.setMethod('POST');
      request.setHeader('Content-Type', 'text/xml');
      request.setHeader('SOAPAction', 'update');
      String b = '<?xml version="1.0" encoding="UTF-8"?>';
      b += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
      b += '<soapenv:Header>';
      b += '<ns1:SessionHeader soapenv:mustUnderstand="0" xmlns:ns1="http://soap.sforce.com/2006/04/metadata">';
      b += '<ns1:sessionId>' + UserInfo.getSessionId() + '</ns1:sessionId>';
      b += '</ns1:SessionHeader>';
      b += '</soapenv:Header>';
      b += '<soapenv:Body>';

      b += '<update xmlns="http://soap.sforce.com/2006/04/metadata">';
      b += '<UpdateMetadata>';
      b += '<currentName>QuoteSettings</currentName>';

      b += '<metadata xsi:type="ns2:QuoteSettings" xmlns:ns2="http://soap.sforce.com/2006/04/metadata">';

      b += '<fullName>QuoteSettings</fullName>';
      b += '<enableQuote>true</enableQuote>';

      b += '</metadata>';
      b += '</UpdateMetadata>';
      b += '</update>';
      b += '</soapenv:Body>';
      b += '</soapenv:Envelope>';
      request.setBody(b);
      request.setCompressed(false);

      //request.setHeader('Authorization', 'OAuth ' + SESSION_ID);

      String body = (new Http()).send(request).getBody();
      system.debug('Hello from body'+body);

      • This reply was modified 9 years, 9 months ago by  Abhinav.
    • Bhavesh

      Member
      April 11, 2016 at 11:37 AM

      @Abhinav,

      Should I write above code in post install script?

    • Abhinav

      Member
      April 11, 2016 at 12:38 PM

      The above code is to enable the quote in the Org. But we cannot get the SessionId in the post install script. Please see the link below :- https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/apex_post_install_script.htm#apex_post_install_script

    • Bhavesh

      Member
      April 26, 2016 at 5:52 AM

      @Abhinav, Where should i write above code then? So I enable Quotes when customer installs my package?

      Do you have any idea where should i write?

    • Abhinav

      Member
      April 26, 2016 at 8:08 AM

      Yeah, in place of using the above code in the post install script as we do not get the session Id in the post install script, we can either make one tab in our app so that on the click of the tab the above code runs and the quote gets enabled or we can make one custom button on the object such that on the click of that button we can enable the quote using the above code.

    • Bhavesh

      Member
      April 28, 2016 at 3:58 AM

      I think enable quotes or order manually or do like @abhinav told both are same. So It is not different.

    • Abhinav

      Member
      April 29, 2016 at 7:35 AM

      Yeah, that may be same but i have not worked for order. I did for quote enabled.

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    A Comprehensive Guide to Salesforce Lightning Development

    Blog in Salesforce integration

    Businesses are depending more and more on strong, adaptable platforms as the digital landscape changes in order to spur innovation and productivity. One such platform…

    CRM Solutions, Hiring Salesforce Lightning Developers, Salesforce Consulting Partner, Salesforce Consulting Services, Salesforce Integration
    AwsQuality Oct 4, 2024
    597  Views

    Salesforce Vaccine Cloud: Streamline Vaccine Management

    Blog in Salesforce Cloud Platform

    Things are changing now - after one full year. COVID-19 cases have gone down, people are out again (with safety precautions though), and the new…

    Artificial Intelligence, Automating Notifications, Community Level, COVID-19 Cases, Covid19
    CRMJetty Feb 10, 2021
    2,290  Views
    Lightning Web Component

    How To Create A Lightning Web Component | The Salesforce Developer Guide

    Blog in Lightning, Salesforce Training

    For this, you first need to have Visual Studio Code in your system. If you don’t have that then first install it.  After that, you…

    Authorize the Org, Command Prompt, Connect Visual Studio Code, Create Lightning Web Component, Deploy Component
    krati vishnoi Jan 6, 2021
    25,469  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.