Questions tagged [database]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

Api Integration Issue

I have created an api integration in salesforce. From client's website a request will send to Salesforce in form of JSON. This will create record in Salesforce. Sometimes multiple requests are sent ...
3
votes
2answers
131 views

How to rollback DML after catching exception in unit test

I have a custom business logic that will block certain profiles from editing/creating/deleting an account. Because of other requirements, mainly around Record Types, I can't use profiles and ...
1
vote
0answers
17 views

Heroku & Salesforce - Database question for multiple environments [closed]

Along with our production org, we have 3 full sync sandboxes, Mule APIs and Heroku. We are in the process of setting up an app, which is really just going to hold a postgreSQL database that is written ...
0
votes
1answer
42 views

Setting up MC with dedicated db

We have a new MC account we would like to start setting up. We have purchased a dedicated db sku for this account. Are there any implactions or things we should know while setting up this new MC ...
0
votes
0answers
15 views

Unable to get related data in apex when using dynamic SOQL [duplicate]

I have a requirement where I have to query certain fields dynamically based on a string that contains the fields. However, when trying to obtain the values, I get 'Invalid field' error. A simple ...
2
votes
1answer
25 views

What would be an ideal use case where you would use sObject.addError() over savepoints and rollbacks?

I came across two methods of preventing errors while inserting, updating or deleting the records in salesforce. Let's say I am performing any one DML operation, and I want the transaction to stop if ...
0
votes
2answers
27 views

Can two email messages be inserted at the same time with email to case?

I am setting up a trigger for when email messages are after inserted and we use email-to-case. Is there any way that the email-to-case inbound or normal sf outbound message system could result in two ...
1
vote
0answers
40 views

Database.saveResult showing only one error at a time

I am trying to write an apexrest service that takes in fields for the Opportunity Object. There are certain restrict picklists on the Opportunity object that I've created. Additionally there are other ...
0
votes
0answers
48 views

Error saving data to an external object

When trying to save data in an external object the following error occurs: FATAL_ERROR|System.UnexpectedException: A callout was unsuccessful because of pending uncommitted work related to a process, ...
0
votes
1answer
27 views

Multiple contacts for a single person? [closed]

I'm integrating Salesforce with a system that will act as the source of employee records. In the source system, each employee human can be represented by multiple employee records - one per ...
2
votes
0answers
142 views

Reliable Salesforce JDBC to be used with DataGrip

Do you recommend any particular JDBC for Salesforce (can be paid) which is reliable enough to be used for commercial purposes along with DataGrip (or similar) software? I've been checking similar ...
0
votes
1answer
100 views

How to use insertAsync with processSave

I am trying to understand how insertAsync(sobjects, callback) works with processSave(saveResult) I went through the following two documentations, but couldn't find an example anywhere https://...
2
votes
1answer
229 views

Salesforce DB query cache (how long?)

How long does Salesforce keep results of a query in its internal database. We know that the first execution of a query takes the longest. Subsequent queries are much faster due to the caching ...
0
votes
1answer
49 views

How can I find problematic records in a dml action?

Let's assume I have a list of 100 new records that I want to insert, 10 of these records are missing information which will result in DML exception. Is there a way for me to create a list and include ...
1
vote
1answer
382 views

Throw a DML exceptions in Apex Batch Class for testing

Below is my batch apex class that updates Account object for example: global class abc implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext ...
3
votes
2answers
147 views

Deleting Big Object Workaround Without Using Database.deleteImmediate

Known Issue for not being able to deletg Big Objects with database.deleteImmediate still open. This is the only method mentioned in docs to do this. Workaround to delete 1 X 1 is a joke. Any other ...
2
votes
1answer
94 views

Salesforce Relational Database ACID

I was reading about relational databases and found that Salesforce is built on Oracle's Relational Database. Based on my understanding, Relational Databases "promise" the following ACID principle: ...
0
votes
1answer
76 views

Database Apex class benefits [closed]

The pros and cons of using Database apex class oposite to SOQL direct queries or DML - in which cases we should use database class?
0
votes
1answer
83 views

Accessing data of Sandbox from Scratch Org

I want to be able to query, insert and update records of a Sandbox from a Scratch org, only during the development phase. I know that scratch orgs are meant to be populated with just a little amount ...
2
votes
2answers
48 views

SOQL - Best practise : what method choosing while retrieving datas?

There are multiple ways of let's say instanciate a list of contacts using SOQL ; My question is : is there a difference between each other, and is there a best practise ? Examples String name = '%a%'...
0
votes
2answers
303 views

Does Database.Update(records, false) roll back the failed records?

If I call Database.update(records, false); will only the failed records be rolled back or will there be no rollback whatsoever? Imagine this scenario, record is updated, kicks of an insert (inside ...
0
votes
1answer
1k views

Database.Query does not return fields with null value

Hi i'm executing this query using Database.Query(query) Where query is SELECT field1__c, field2__c, field3__c FROM Object1__c On the current record, field3__c is NULL but when i query on the ...
0
votes
0answers
41 views

Duplicate record not added to Database DuplicateRecordSet

We have activated the standard duplicate rules and matching rules for Account. Generally, they seem to work and the duplicate records get written into the tables DuplicateRecordSet and ...
1
vote
1answer
26 views

Object relationships

I have two objects Parent__c and Child__c, Child__c object have a lookup to Parent__c. This code is clear to me, Child__c has a Parent__c field through which it can access to the Parent__r object: [...
0
votes
2answers
640 views

SObject.addError() method does not prevent DML Operation [duplicate]

I want to prevent DML operations during certain processing-situations and provoke a Database.SaveResult with an Database.Error[]-List. According to SObject class documentation, the method addError() ...
2
votes
1answer
150 views

Unable to Create/Update Fields CreatedDate - Database.Merge Leads

I am trying to merge leads with the Database.merge method of syntax merge(masterRecord, duplicateIds, allOrNone), but I'm getting the following error: Unable to create/update fields: CreatedDate. ...
0
votes
1answer
38 views

What is the behavior of date/time fields regarding daylight saving time?

A user located in São Paulo/Brasil is on the UTC-3 timezone. As I write this post it is actually UTC-2 because of daylight saving time. That means that records created today will have the value of ...
0
votes
1answer
517 views

How to add 'LIMIT :' to String in Database.query?

I have Database.query that sorts records by a few filters (or any filter). I want to set the limit for it. How should a write it? return Database.query('SELECT Id, Name FROM Stereo_System__c' + ...
0
votes
1answer
400 views

Querying external database from Salesforce Marketing Cloud

I have an external database containing contacts and transactions. How do I query that database from SFMC to update data extensions for e.g. contacts or transaction data extensions? I don't need to ...
0
votes
1answer
191 views

Help with a schema, custom object to track product stock on Orders

How can I track product stock levels across locations? Our business process is basically this: When an oppy is closed won a trigger will automatically create a contract (not used by us - consider ...
3
votes
2answers
3k views

Database Query Locator vs Simple Query

I want to know what is the difference between Database.QueryLocator() and simple SOQL Query i.e. List<Inventory__c> invent = [Select Id,Quantity__c,AccountId__c,Name,Expiry_Date__c From ...
0
votes
2answers
420 views

Test Coverage for Custom Error Logging

I created a custom object to store errors in my code. So I am updating some of my classes to take advantage of this object, but I am now running into issues with test coverage. I am taking advantage ...
2
votes
1answer
2k views

SOQL Order by multiple fields with specific values

I have a problem with sorting data with SOQL query. I am sorting data with SELECT Id, Name, CreatedDate, Status FROM Account ORDER BY CreatedDate ASC; But i want to add one more field to sort with. ...
1
vote
1answer
696 views

Exception in Database.save result in trigger context

1) In my opportunityLineitemtrigger, I have a method which updates the opportunity. system.debug('######'); database.saveresult [] rst = database.update(oppList,true); system.debug('######'+rst); ...
0
votes
4answers
285 views

How can I access variable in switch case outside of switch block?

I am trying to upsert a dynamic sObject list of records using Database.Upsert, I want to be able to use AllOrNone parameter however this returns an error saying that my toUpsert variable must be a ...
1
vote
2answers
571 views

Dynamic field for Database.Upsert

I am trying to use a dynamic field for my Database.Upsert command as follows: String extField = objVariable + fieldVariable; Database.UpsertResult[] up = Database.upsert(toUpsert, extField); This ...
0
votes
0answers
126 views

Search and view data from external database

I have a business requirement to create a way for users to search and view results from an external database (Snowflake) in Salesforce. I have created a simple visualforce page and need to send a ...
0
votes
1answer
656 views

Can I pull DISTINCT customers with SQL based on most recent row record only?

So, I have a data extension where data is being saved. My data extension (CustomerSourceDE) looks something like this: Id (text) NULLABLE Email (Email) NULLABLE Customer_FirstName (Text) NULLABLE ...
0
votes
1answer
104 views

Database.query not working with RecordTypeId

I'm making a call to db to retrieve the RecordTypeId from a record of an Object (both values passed as parameters in the function). The point is that when I'm trying to save the code it gives me this ...
10
votes
1answer
196 views

FOR UPDATE returns old values

I use FOR UPDATE locking in a query but when the first execution completed, the second execution (started while records were locked) seems to use the old data set. I played around for a while and ...
0
votes
1answer
51 views

Need to retrieve values from database without refreshing the entire page

I have a Visualforce page with picklist and associated fields with it. When the picklist value is no I want the other input field values that we have provided to be saved in the database after ...
1
vote
3answers
151 views

Help Schedule email reminder

Im new in salesforce apex programming.. I want to make an email reminder if case status != closed to case owner H+5, H+7, and H+10 .. H = created date .. how do i get the owner email value? and ...
3
votes
1answer
2k views

Difference between Database.executeBatch vs System.scheduleBatch

I am curious to know is there any notable difference between Database.executeBatch vs System.scheduleBatch. One difference I know is, we can delay the batch execution in scheduleBatch method. However, ...
7
votes
2answers
10k views

updating a records using external Id in Apex

I copied the product data to another object named foo. I used only the name and externalId of product to copy it to Foo object. Foo's external id matches with product's external Id. Some of my ...
2
votes
2answers
2k views

Is it possible to not use an ExternalId field for Database.Upsert?

I'm trying to upser a list of Asset records via Database.upsert(List, externalIdField, boolean) and on the externalIdField, I want to pass the standard field 'SerialNumber'. List<Database....
0
votes
1answer
631 views

How to get the Id of Inserted records from Database.Upsert? [duplicate]

I'm having this dilemma regarding the result for Database.Upsert(List, boolean). Database.Upsert returns Database.UpsertResult and it provides as the Id of the record that was successfully inserted/...
0
votes
0answers
84 views

Exception: Invalid field X__c for SObject Y__c

I have below VF Page. <apex:pageBlock > <apex:pageBlockTable value="{!CPAT_accounts}" var="c"> <apex:repeat value="{!excelFields}" var="f"> <...
1
vote
3answers
585 views

How to identify records “actually” getting updated?

We have a SAS Datawarehouse system in our project that polls records daily from Salesforce to support data archival process. However, they have started complaining that the "updated" Account records ...
0
votes
2answers
242 views

Get slow running SOQL information from production

Since Salesforce underlying data layer uses oracle database, can we get information on Slow running SOQL’s in production with times that we can target to improve? Any indexing advice from salesforce ...
0
votes
1answer
104 views

How to access SOQL query results

I have a table that I'm querying using SOQL and the query results should contain multiple rows. I'm trying to iterate through the query results and access attributes from each row of the query ...