We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [database]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
41 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
0answers
15 views

Batch merging duplicate records?

I've set up a scheduled apex job to run once a week that merges duplicate records from the DuplicateRecordSet object. The problem is that this class can only merge three records at the time and doesn'...
0
votes
2answers
53 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
117 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
21 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
22 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
122 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
39 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
35 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
242 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
147 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
83 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 ...
2
votes
2answers
1k 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
129 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
550 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
255 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
145 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
258 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
76 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
347 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
67 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
146 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
41 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
118 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 ...
1
vote
1answer
936 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
5k 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
1k 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
230 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
70 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
174 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
151 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
78 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
67 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
27 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
427 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
782 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
285 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
429 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
645 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
151 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
84 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
127 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
27 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
71 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
310 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
629 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
191 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
5k 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
24 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?