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.
1 Answer
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
-
1Didn'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
SOQL
withSQL
. I can appreicate that, given that inSQL
you'd use something akin toINSERT INTO Contact (FirstName, LastName) VALUES ('Foo', 'Bar')
, Salesforce is very different.