New answers tagged

1

That's not how the REST API works. To get the Blob (file contents), you have to call that rest resource. This allows the response to be reasonably sized without overwhelming the client, which may be a mobile device. See Get Attachment Content from a Record.


0

Ok, no idea what went wrong, but this time I created the new field from the object manager and everything is fine.


0

Unless the managed package exposed a method that let you examine this data, there's no way you would be able to tell in Apex. You might ask the vendor if they would add such a method. For example, they might add a Debug class, like this: global class Debug { global static Integer getLimitsQueries() { return Limits.getQueries(); } } They could do ...


1

The following syntax is not a dynamic query: List<customObject__c> lstCstObj = [SELECT ... FROM ...]; What you need is a dynamic query. A dynamic query normally looks like: String myQuery = 'SELECT ... FROM ...'; List<customObject__c> lstCstObj = Database.query(myQuery); What you're after is probably something like: // get the parameters ...


0

You can see the Expiration date of all licenses under "Company Info" which is accessible via the organization object. Unfortunately, in the object User License there is no expiration date, only in PermissionSetLicense. However, the User License seems to be linked to Profile, as you can query via parent-child relationship Profile.UserLicense.Name FROM User.


0

Limits Class will always run in the same namespace it is being run from. So, the limits it returns will be of the same namespace limits and does not include any other namespace limits. However, you can go to Salesforce developer console > Debug > Change log levels > Add/Change for General trace and set all levels to none but profiling to INFO or ...


0

With Spring 19' update there is a new setting in the "App Permission -> Content -> Query All Files: Allows View All Data users to SOQL query all files in the org". This is not enabled by default for the admin user but you can at least enable it in a Profile/Permissions Set. Also, now documented in https://developer.salesforce.com/docs/atlas.en-us....


3

Simpler way? well yes and no. We have Database.getUpdated method that returns Id of records updated in a particular time span. It takes sObject Type , start date and end date as arguments and returns ID of updated record. The tricky bit is not every object is supported, so you have add ignore list or some custom logic for objects not supported by ...


0

Actually, this is how searches work. What you have implemented looks correct and is very easy to use for the end-user. However, If you want to optimize this, I can think of the following approaches: Let the user enter at least 2-3 characters before making the query. Add a delay and check if the user has stopped typing before querying. This will reduce your ...


2

I took a quick look at the PandaDoc app in a dev org. There's no pandadoc__PandaDocDocument__c field on Opportunity. The pandadoc__PandaDocDocument__c object has lookups (many-to-one relationships) to Account, Contact and Opportunity. To get the records that are children of the Opportunity, you need to add another child query, eg: SELECT Account....


3

According to what you said - The query works if I take off the pandadoc__PandaDocDocument__c. This is because Panda documents are child objects of Opportunity. So, you need inner query to get documents: SELECT Account.BillingStreet, (SELECT Id, Name, pandadoc__Account__c, pandadoc__Contact__c, pandadoc__Lead__c FROM pandadoc__Panda_Doc_Documents__r), (...


1

As the [doc states(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm?search_text=getquerylocator), the argument to a Database.getQueryLocator can not be an Aggregate query You can't use getQueryLocator with any query that contains an aggregate function. There are two workarounds: If the number of ...


1

HAVING COUNT(Name) > 0 AND CustomField__c = 'myValue' Only aggregated fields can be added in HAVING filter. CustomField__c is not being aggregated in query. In above given query, you are grouping on Account__c and you can add filter in HAVING clause only on this field. I don't your problem but a valid query similar to your query would be: SELECT ...


-1

Try [...](select id, Name from Initial_Notification_Templates__r where Program__c ='+ programId+') [...] instead.


1

1) Create a formula field FullName__c = FirstName + " "+ LastName 2) Then in your apex code create a third list: List<String> fullNameList = new List<String>(); for(Integer i=0;i<firstNameList.size();i++){ fullNameList.add(firstNameList[i] + ' '+ lastNameList[i]); } List<Contact> contactList = [SELECT Id, firstName, LastName ...


1

The field Voucher_Assign_Date__c seems to belong to the object Voucher_Repository__c and not to the object Webinar_Attendees__c. In your VF page, it looks like the variable c is assigned to an object of type Webinar_Attendees__c, not of type Webinar_Attendees__c. So, there are two potential issues here. There is a field called Voucher_Assign_Date__c in ...


1

web is a variable of type Webinar_Attendees__c. It is not a collection, and cannot be used in an iteration. To access subquery results, you must use the relationship name given in the child query as a property on the parent. This value will be typed as a List<sObject>, where the sObject is the type of the child object. for(Voucher_Repository__c ...


4

As @Adrian said, SOQL is read only. However, Salesforce provides you with a way to do this when you have many records and you have Gov Limit concerns. It is called Batch Apex. You would create a class, define a query (which can be dynamic) and then iterate through the record. You can also, optionally, specify how big the batch is (ie: how many records get ...


7

SOQL is a read only language. You cannot in any way use SOQL to perform write operations.


4

The following should work. Set<Id> accountIdsWithOneInactive = new Map<Id, SObject>([ SELECT AccountId Id FROM AccountContactRelation WHERE IsActive = false GROUP BY AccountId HAVING count(Id) = 1 ]).keySet(); List<Account> records = [ SELECT Id FROM Account WHERE Id IN :accountIdsWithOneInactive AND Id NOT IN ( ...


3

Yes, you can use a join to find only records which have child records meeting certain criteria. SELECT ... FROM MyObject__c WHERE Id IN ( SELECT Lookup__c FROM Child__c WHERE ... ) So in your case, if your child object is named VotingRelatedCompany__c, it would look like: WHERE Id IN ( SELECT Company__c FROM VotingRelatedCompany__c WHERE ...


4

You can use a filter without needing a variable, via LAST_N_DAYS: data = [SELECT LastModifiedDate FROM Account WHERE LastModifiedDate < LAST_N_DAYS:30]; This returns records that haven't been modified in 30 days. Also see Date Formats and Date Literals for other alternatives.


1

Just add it as a criterion in your WHERE clause: SELECT ... FROM Opportunity WHERE ... AND Prop_Building_Name__r.name = :searching Also, a lot of your code is just doing nothing at the expense of CPU cycles. Adding the records from one list to another is not necessary here. Just return the results of the query directly. public static List <Opportunity&...


0

The cause of the issue is you are attempting to query too many records. My guess on what is actually occurring under the hood is that you are reaching a governor limit such as, "maximum SOQL query run time before Salesforce cancels the transaction" which is 120 seconds. What you can do is add a LIMIT to your query and if that is not sufficient you can ...


1

Notice the Deleted and archived records: Include in top right? LIST: SUM:


0

You can't directly get the Role id from the Single Query. You need to query in such a way : [select relatedid from Group where id in (SELECT UserOrGroupId FROM customObject__Share where rowcause='Rule')].. The RelatedId is the Id of role that has access/the role with the record is being shared.


0

There are many fields available on permissionset object. You can query those permission which you need. In general:- PermissionsPermissionName One field for each permission. If true, users assigned to this permission set have the named permission. The number of fields varies depending on the permissions for the organization and license type. read more ...


2

As this is a custom relationship between Contact and Orders, you will have to use __r with the child relationship name. So your query should be select Id, (select id from Orders__r) from Contact You can get further information about the custom relationship name and how to use parent to child relationship queries at this salesforce documentation ...


0

As far as I am understanding, you want to filter the records based on another profile. If that is what you are asking, then you can add the OR clause to your SOQL query and filter the records. UserData = [Select u.Name From User u where IsActive = true and (Profile.Name = 'Service Marketing' OR Profile.Name = 'System Administrator') ORDER BY Name ASC NULLS ...


0

I've resolved using a workaround padding every element of the string to 2 digits adding '0' to the left. now 1.1.1 is sorted before 1.10 as i was expecting


2

This ordering is actually correct because the field type is text. It will be same whichever language (database/server/javascript) you do a sort. Since you have multiple dots, you cannot even set the data type as number. The only option is to get the records and write a custom logic to sort them correctly. adding based on comments: Adding 0 still is failing:...


3

Queueable Apex is an asynchronous context as far as limits go, which does affect a variety of limits, including the total SOQL count (200 instead of 100). Each Queueable job enqueued and executed represents a separate transaction, which is the unit of limits consumption. What is happening here appears to be your process automation downstream of the ...


5

Since there are more than 200 results, it could be a variation of this known issue. Try executing it as a script instead of a query: List<My_Text_Content__mdt> myTextContents = [Select Id, Label, DeveloperName, Version__c, Content__c FROM My_Text_Content__mdt WHERE Version__c = '2020' ORDER BY Version__c]; for(My_Text_Content__mdt ...


1

The relationship name for feed items is Feeds, not FeedItems. The below query should work: [SELECT Id, CaseNumber, (SELECT Id, Title From Feeds) From Case]


0

You can query them like Select id,title,body from casefeed


0

In Understanding Query Results, it says: Query results are returned as nested objects. The primary or “driving” object of the main SELECT statement in a SOQL query contains query results of subqueries. I didnt find much of other documentation on this, I have been using this kind of behaviour of SOQL from a long time. For example, consider below SOQL: ...


7

Can anyone point me to some documentation that states this as expected behaviour? I've never seen such documentation. Empirically, it appears that the common B__c instances are actually shared (I can update the B__c instances obtained via A__c.B__r in different ways, based on other A__c values, and get the expected results). This is definitely true; I ...


4

To find out if a given class is scheduled use an SOQL query like: SELECT Id, CreatedById, CreatedDate, Status, CompletedDate FROM AsyncApexJob WHERE ApexClass.NamespacePrefix = :namespace AND ApexClass.Name = :className Where namespace is your namespace (leave out if you are not in a package) and className is the class name string, such ...


0

Best place to start is the Monitor Asynchronous Apex trailheal module. Gives nice SOQL queries, like: AsyncApexJob jobInfo = [SELECT Status, NumberOfErrors FROM AsyncApexJob WHERE Id = :jobID];


3

As your code is right now, moreInfo is an empty List, so you shouldn't be getting any results: List<String> moreInfo = new List<String>(); // <=== EMPTY right now! List<Detail__c> details = [SELECT Info__c FROM Detail__c WHERE MoreInfo__c IN : moreInfo LIMIT 1]; Use your for loop before the details ...


4

You can instead get the results into Map and get the keyset from Map to get Set<Id> Map has a constructor which takes List<sObject> and creates a instance of Map with ID as Key and sObject as value. Excerpt from Salesforce Map documentation. Map<ID,sObject>(recordList) Creates a new instance of the Map class and populates it with ...


1

Update from Salesforce - confirmed that Mine_And_My_Groups scope is only valid for ProcessInstanceWorkItem I think there's a couple of issues here: I think the Salesforce USING SCOPE documentation is wrong, and the correct scope is probably Mine_And_My_Groups, which matches the other syntaxes e.g. My_Team_Territory. Whether it's MineAndMyGroups or ...


2

This is a bit of a guess but I think this is what you'd want. This would exclude the record if any of the listed conditions are true. I have changed your like query because I find it easier to read this way, but I believe yours should work too. SELECT Full_Name__c, Account.Name FROM Contact WHERE (NOT Account.Name LIKE '%LTD%') AND (NOT Account.Name LIKE '%...


1

We came across the similar issue previously. First, the granularity of createdDate is precised to seconds instead of days. So if you don't have too many records created at the same second, you are probably fine. What you can do is instead of using CreatedDate > lastQueriedCreatedDate, use >=. You could have a few overlapping, but that's still better than ...


7

The isRestrictedPicklist() method, documented at the link in your question, is what you're looking for.


0

You might be sending a stringified list with 1 member and ids separated with commas. Use debug to check the list size.


1

Firstly, you have constructor in Apex Set to convert List to Set directly. You can use like below: Set<String> filterIds = new Set<String>(Ids); You need not iterate over list for getting Set. This method should definitely work. Can you check If you are definitely passing correct Product2 Ids and whether its List because I have seen ...


0

you are using "=:" but it should be "in :" like following : List<Product2> products = [SELECT Id, Name FROM Product2 WHERE Id in :filterIds]; "=:" is used to compare only one id and you are using list so "in :".


1

Approach 1, return a User SObject with children that identify Teams public static User getUdserData() { return [SELECT Id, UserName, ..., (SELECT Team__r.Name FROM Team_Relationships__r) FROM User WHERE Id = UserInfo.getUserId()]; } Approach 2 - return a custom type public class UserData { public ...


-2

Go to your custom object, then go to the lookup field. Select 'Field Name' value (Assume you have 'Contact_ABC'). Note : Do not use API Name or relationship name. suffix __r to it. That will give you relationship name and you can use it to query any field Example : Contact_ABC__r.id - This will give you contact ID Contact_ABC__r.name - This will give you ...


Top 50 recent answers are included