Activity Forums Salesforce® Discussions How to use Post Install Script to enable Quotes and Order object?

  • Abhinav

    Member
    April 11, 2016 at 11:24 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);

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

    • This reply was modified 8 years, 7 months ago by  Abhinav.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos