Questions tagged [database]

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

0
votes
2answers
34 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
20 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
33 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
85 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
88 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
46 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 ...
1
vote
2answers
525 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
75 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 ...
1
vote
1answer
304 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
157 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
92 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
154 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
49 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
184 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
39 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
132 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
33 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
106 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 ...
0
votes
1answer
636 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, ...
5
votes
2answers
2k 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 ...
1
vote
2answers
616 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
139 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
48 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
100 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
96 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
58 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 ...
3
votes
0answers
59 views

First event/event relation insert taking a while

I have an application that inserts events and event relations in an org's database and has a loading icon to prevent the user from doing anything until the event and relations are properly created and ...
1
vote
1answer
24 views

How do I create a related field in Products2 to Documents.Id?

I am trying to pull in Document images to display on product listings (Product2 object) and wanted to just create a related lookup field to the Document Id. The image is displayed by a formula/text ...
2
votes
1answer
370 views

Database.Query Variable Does Not Exist

How can I get the field results from a dynamic database query to be available to be put into a list? Here is the code I have: //Query on the destinationObjectFieldName results List<sObject> ...
0
votes
1answer
611 views

Salesforce DB connect with SQL Management Studio

I'm trying to connect SQL Server Management Studio to Salesforce so I can see tables and columns but unable to connect. Do I need any ADO.net connector or Salesforce plugin for this to work? Do I need ...
-2
votes
1answer
245 views

What is the execution time spent in the database for an DML or SOQL or SOSL?

Is it possible to find the execution time for a DML or SOQL or SOSL? What are the factors on which the execution time of these queries depend?
2
votes
1answer
330 views

DML Database method is covered by unit tests, how to determine reason for no test coverage of the SaveResult variable?

The blue indicates test coverage. The red indicates uncovered code. Where would I find the cause for the uncovered code? public List<Opportunity> insertOpportunityAndDefineRelationships(...
1
vote
1answer
504 views

Error when calling Database.insertAsync (Status Code “ASYNC_OPERATION_LOCATOR”)

I am experiencing some bizarre behaviour when trying to insert external objects. The following statement results in an error: Object__x o = new Object__x(Name__c='Test'); Database.SaveResult[] sr = ...
0
votes
1answer
119 views

How our database should be for using it with Salesforce Connect?

I have a on-premise data base(Oracle DB), this database i need to use in salesforce directly using External Object technology provided by salesforce. I understood how to use External objects in ...
0
votes
2answers
75 views

Rolling back a complete transaction

I have two object foo__c and zoo__c. zoo__c is a child of foo__c with a master detail relationship. I have validation rule created on Zoo__c with a condition that when the status__c field on related ...
0
votes
1answer
100 views

How can I find out what fields made my upsert fail?

I'm trying to upsert some records. I use Database.upsert. If the failure is related to a duplicate value (external ids that have to be unique) I need to know what fields are duplicate and clear (...
1
vote
1answer
25 views

Compile Error on batch class to fetch fields from saveresult

I have below code to fetch field values from records of Database.Saveresult. I am getting error as below. Error Expression of type Database.SaveResult has no member named Territory_Name__c Code ...
1
vote
1answer
62 views

Apex to run cross-object duplicate detection (Leads vs Contacts)

I have the following code that checks Phone, Phone2 and Mobile for Leads and gives an error if a Lead with the same phone exists, before saving the new record. How do I turn it into a code that will ...
0
votes
1answer
242 views

What are the implications of trying to modify a rollup summary field?

I have tried manually modifying it and it seems possible, but I am not sure if there are any unintended side effects. My requirement is to have a logging summary table that rolls up the details of ...
1
vote
1answer
525 views

Accessing ALL SUBSCRIBERS in a Parent BU from a Child BU?

I have two child BUs and as people are deployed they are added to the ALL SUBSCRIBERS list. Their STATUS is limited to the Child BU, so an unsubscribe occurs only at the child BU. Question: If a ...
0
votes
1answer
149 views

How to format a number with comma?

Currently, I am using this query SELECT top 10 snt.Domain, count(*) AS DomainCount from _Sent snt group by snt.Domain order by count(*) desc The data type of "DomainCount" is number and the ...
0
votes
2answers
3k views

Using query for a specific date

I am trying to pull data from SENT data view based on date. What format of date should I use? I have tried this but no results: SELECT * FROM _Sent WITH (NOLOCK) WHERE EventDate = '2017-05-29' I ...
1
vote
2answers
2k views

Pulling data from data views for one business unit only using query

SO, I want to pull data from data views for our business unit only in marketing cloud. Currently, it seems like when I run a query something like: SELECT * FROM ent._Subscribers WITH (NOLOCK) It ...
0
votes
1answer
22 views

Which is the default field on which operates Database.Update?

I just couldn't find any topic regarding on which Field the Database.Update will operate? I suppose that it will do the update on id but I'm not sure. Am I right?
1
vote
2answers
436 views

Storing time-stamps with millisecond precision

When you have automated processes interacting with your system, it is very common for multiple things to happen within the same second. In order to prove that these events happened in the correct ...
0
votes
2answers
916 views

Database.update() is not updating the data, but there are no error message

I am experimenting this to test Database.update() to update data partially in Developer Edition. The issue is that, it is not updating the data and is not throwing any error. I am certain that, there ...
0
votes
0answers
34 views

why database.emptyRecycleBin() not removing the actual record from bin? [duplicate]

database.emptyRecycleBin([select id from test__c where IsDeleted = true ALL ROWS]); when i run the above and try to query the bin record, still record exist. What is wrong ? Please guide me !
0
votes
1answer
80 views

Understanding Salesforce user database

I wish to know how Salesforce designs their Multi-Tenant database. My questions are as follows: Is every tenants and users stored in a central master user database? Does every tenant have their own ...
1
vote
2answers
80 views

Prevent insert if object in list is not valid and find which record is invalid

I am developing lightning component, on which user enters data in table and creates multiple records. If some records do not pass validation - row has to be highlighted with red. For this I need to ...
1
vote
2answers
767 views

Partial success for insert, update, delete [duplicate]

Not long time ago I decided to use insert, update, delete methods of Database class and its optional 2nd parameter allOrNone with false as value. But I found calling getId from the result does not ...