2

I have a business requirement to update / close an existing opportunity in Salesforce automatically. I have an existing script that extracts record from salesforce automatically using soql query and I am wondering if it is also possible to use SOQL to insert/update data in Salesforce.

4
  • 1
    Don't confuse SOQL with SQL. I can appreicate that, given that in SQL you'd use something akin to INSERT INTO Contact (FirstName, LastName) VALUES ('Foo', 'Bar'), Salesforce is very different.
    – Dan Jones
    Nov 14, 2016 at 16:55
  • Hi Christine - no, SOQL is only for retrieval of records. There are a lot of acronyms thrown around in Salesforce development and I know it can be confusing, so to answer your question - no, SOQL cannot insert/update data. Nov 14, 2016 at 18:39
  • I have an existing script that extracts data from salesforce and I'm wondering how can I use this to update data in Salesforce. I am just new in Apex and needed all the help I can get. Thanks again: Nov 14, 2016 at 22:15
  • Here's the extract script: <bean id="csvExportOpportunityProducts" <property name="name" value="csvExportOpportunityProducts"/> <map> <entry key="sfdc.entity" value="OpportunityLineItem"/> <entry key="sfdc.extractionSOQL" value="Select OpportunityID, PricebookEntryID, Quantity, UnitPrice FROM OpportunityLineItem "/> <entry key="process.operation" value="extract"/> </map> </property> </bean> Nov 14, 2016 at 22:20

1 Answer 1

6

No, SOQL (Salesforce Object Query Language) is a query language. It allows you to pull data from the database. If you want to push data to the database, you use DML (Database Manipulation Language) operations.

Basic Example:

List<Opportunity> records = [SELECT Id FROM Opportunity WHERE ...];
// above is SOQL

// set some fields...

update records;
// above is DML
3
  • 1
    Didn't see this answer in the review queue before I commented. Good answer! Nov 14, 2016 at 18:40
  • Thanks Adrian.Maybe you can help me transform my extract script to update record: <bean id="ExportOppProds" <property name="name" value="ExportOppProds"/> <map> <entry key="sfdc.endpoint" value=""/> <entry key="sfdc.username" value=""/> <entry key="sfdc.entity" value="OpportunityLineItem"/> <entry key="sfdc.extractionSOQL" value="Select OpportunityID, Quantity, UnitPrice FROM OpportunityLineItem "/> <entry key="process.operation" value="extract"/> </map> </property> </bean> Nov 14, 2016 at 22:24
  • @ChristineP. That seems like an entirely separate question. Take a moment to visit the faq and the help center, and read How to Ask. Perhaps you should ask a new question about your export script specifically.
    – Adrian Larson
    Nov 14, 2016 at 22:37

Not the answer you're looking for? Browse other questions tagged .