New answers tagged

0

This is for you if you have XYZ, ABC, PQR picklist values in your multi-picklist field and wanted to query on it String sampleString = 'ABC'; Select id, Name, APINameOfMultiPickField FROM ObjectAPIName WHERE APINameOfMultiPickField includes (:sampleString)


1

+1 for Sachin's answer. Looking at the code here, do remember that one benefit of Apex is that the compiler is aware of SOQL syntax. That means you can add line breaks to make your code easier to read: for (Applicable_Model__c model : [ select Id, Knowledge__c, Product__c, Product__r.Model_Code__c from Applicable_Model__c where Product__r....


2

conModelcodeMap.values() would actually be a list of list. And you can not bind a list of list in the SOQL. You would need to flatten it to an list first then you can bind it & get the list of records. SObject [] allRecords = new SObject []{}; for(SObject[] records: conModelcodeMap.values()) allRecords.addAll(records); for(Applicable_Model__c ...


0

You can export all notes and attachments using open-source sfdx-hardis plugin command First, define a files export sfdx hardis:org:configure:files When prompted for SOQL request, you can input SELECT Id,Name FROM MyCustomObjectX__c Then, run the files export sfdx hardis:org:files:export More details in this article Disclaimer: My company authors sfdx-...


0

You can export all notes and attachments using open-source sfdx-hardis plugin command First, define a files export hardis:org:configure:files Then, run the files export sfdx hardis:org:files:export More details in this article Disclaimer: My company authors sfdx-hardis plugin


0

You can use Layout Tooling API : SELECT TableEnumOrId, count(Id) FROM Layout WHERE ManageableState='unmanaged' group by TableEnumOrId


1

One way to achieve this just by using Salesforce administration would be the following one: Create a new text field and set it as unique Create a Flow and update the field that you just created with something like (OwnerId + Multipicklist Value) By doing this, you ensure that you can't have in the System two records with the same Owner Id and same values ...


1

You have to provide a method name: public static void (){ The name of the method goes between the void return type and the empty parameter list (). The query does not do what your text states. If you're expecting a query to return Case records, the query must have Case as the primary object (in the top-level FROM clause). That query returns Account records. ...


0

A constructor is a method with the exact same name as the class, and has no return type. From https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_constructors.htm : The syntax for a constructor is similar to a method, but it differs from a method definition in that it never has an explicit return type and it is not ...


0

your method name is missing a "name" public static void methodName(){ ...your code }


1

Composite Graph API only supports few types of API. The query API is not supported. The docs are here. For the other different types, I recommend a move to regular REST API.


0

For some strange reason in LWC, Name field from PermissionSetTabSetting returns either standard object name or custom tab id, while in Classic, it returns the tab name. Workaround here is to use Tooling API with Classic Session Id. Create Visualforce Page 'Api'. <apex:page controller="ApiCont" showHeader="false" sidebar="false&...


1

I'm the author of the apex-lambda library that you mentioned. I believe it's the closest thing to what you looking for on the platform. As Apex is a very static language, you have to reify (i.e. "make into classes") all the type-related things that would be avoided through generics. If 3,000,000 characters are a risk, a library that provides many ...


0

I have fixed this issue: This problem was 2-fold because: It dealt with extra padded spacing after the first name field in the taxonomy file being ingested into S3. Also, the code was incorrectly returning the wrong attribute API field name for the AccountContactRelation object's contact ID Hopefully this will be huge in solving this intermittent ...


0

You can use the Apex Schema class to do a GlobalDescribe on the chosen SObject and then work your way through the fieldMap to retrieve each label. Map<String, Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap(); List<String> labels = new List<String>(); for (String fieldName: fieldMap....


0

Don't have a high enough reputation to reply to the accepted answer, be careful of when Daylight savings time ends in November. For the calendar year 2023, the pasted solution will calculate 5 Fridays, when there are only 4. The pointer variable is GMT 04:00:00 which is the previous day and throws off the calculation Pointer = 2023-11-03 04:00:00 ["2023-...


0

To extract over 1 million records, you should be using the Bulk API. The Bulk API efficiently handles enormous queries and provides its own chunking features where required (such as PK Chunking in Bulk API 1.0).


3

As of this writing, the following types are available in the Schema namespace and can be queried (with one noted exception). These objects are listed in the Tooling API Developer Guide, but not in the SOAP API Developer Guide: ApexEmailNotification BrandingSet BrandingSetProperty BusProcessFeedbackConfig DataType EntityDefinition EntityParticle Can be ...


0

You're assigning the wrong values to the record. UserFromGroup.UserOrGroupId = strUser; UserFromGroup.GroupId = groupId; Do not assign a value to Id when inserting records.


4

Taking time to try to understand the error message you're getting will help you understand how to move forward. Although you have paraphrased the error and not included the stack trace (when asking about errors, you should never try to shorten it or paraphrase it. You don't know what the important part of the error is, and have a fair chance of leaving out ...


0

As the previous answer to a similar scenario shows, you can leverage what the documentation goes over under Semi-Joins with IN and Anti-Joins with NOT IN You care about User and GroupMember in this scenario. As mentioned before and noted in the GroupMember docs, you'll be ignoring "other" ways users can be part of a group with this approach. User ...


0

You can't get the user names directly from that query because the GroupMember object is a joining object between User/Group and Group. You need to do another query on the User object to fetch the Name. SELECT FirstName, LastName FROM User WHERE Id IN: userIDsFromGroupMemberQuery


1

SOQL does not allow us to compare two fields (more specifically, a field cannot appear in the Right-Hand Side of a filter expression). In some cases (generally when you're trying to compare a field value on a child record against a field value on a related parent record), we can use a formula field to do the field comparison and then use that formula field ...


0

As Mohan mentioned the best practice is to create Custom Profiles, because their names are not translated. If you are stuck with using 'System Admin' then I would suggest introducing CustomLabel with values for different languages


0

In Salesforce, Standard Profile's name property is not allowed to renamed into another language I think. If you tried to edit the name it's not allowed to change, it's just shows that name in read onlymode. So If you need your profiles in your local language (like korean, chinese etc.) Please create a custom profile (by cloning from Std. profile) and you can ...


1

Since profiles and permission sets have a 1-1 relationship, you can query the permission set without relying on the profile name. This is a more accurate way to check since multiple profiles can have PermissionsModifyAllData. Boolean hasModifyAll = [SELECT PermissionsModifyAllData FROM PermissionSet WHERE ProfileId = :UserInfo.getProfileId()]....


3

Iterate GroupMember records and group UserOrGroupId by unique Group.DeveloperName List<GroupMember> groupMemebrs = [ SELECT Id, GroupId, Group.DeveloperName, UserOrGroupId FROM GroupMember LIMIT 50000 ]; Map<String, List<Id>> groupMemebersByGroupDeveloperName = new Map<String, List<Id>>(); for(GroupMember ...


3

Your data needs to come from somewhere. If you have the data "in memory" (that is, you already have an SObject instance with your data), then you don't need to query. If you don't have (or can't construct data from) the data "in memory", then you will need to query for it. When you write a query, it's just a fact of life that you need to ...


0

If you thinking of combining 2 logics then you have first find minimum criteria between them. In your case minimum criteria is OpportunityID = Oppty.Id. Then for remaining criteria you can use if else in for loop. A simple way to can write query is List<CUSTOM_OBJ> customObjList = Select Id, checkBoxField, Status from CUSTOM_OBJ where OpportunityID = ...


0

In addition to Data Loader, maybe you can try other third-party tools, such as Acho, to bulk export data. Although it still takes time to retrieve data, the process runs on cloud so you don't need to worry about the network issue.


3

You can use the following Date Functions: CALENDAR_MONTH CALENDAR_YEAR DAY_IN_MONTH Which in combination would look like: WHERE CALENDAR_YEAR(Date__c) = 2021 AND CALENDAR_MONTH(Date__c) = 7 AND DAY_IN_MONTH(Date__c) = 31 If you want it to be always a specific date last year, you need a Date Literal as well. That would change your query filter to: WHERE ...


3

you can use SOQL Date Literals: with a combination of date functions. For your current example: WHERE Date__c = LAST_YEAR AND CALENDAR_MONTH(Date__c) >= 8


-1

Please try the below query, it should give you all the contacts with lastname 'Smith' and a record with name 'John Johnson'. Edit the returned fields according to your requirement. SELECT AccountId,Email,FirstName,LastName FROM Contact WHERE (FirstName = 'John' AND LastName = 'Johnson') OR LastName = 'Smith'


1

You may want NOT IN in this case; this will find any accounts with no open opportunities (including those with no opportunities at all): Select id from Account WHERE Id NOT IN ( SELECT AccountId from Opportunity where IsClosed = true )


3

You need to write a query with IN for receiving account id list from your nested query SELECT AccountId from Opportunity where IsClosed = false. So your query will be followingly, SELECT Id FROM Account WHERE Id IN (SELECT AccountId from Opportunity WHERE IsClosed = false) And refer this link to learn more about SOQL queries.


1

The field name is AccountId and not AccountNumber. Use below SOQL Order currectOrder = [SELECT AccountId, OrderNumber, Type, Status FROM Order WHERE Id =: currentOrderId]; If you need AccountNumber then you can use below SOQL that uses Relationship in SOQL to pull info Order currectOrder = [SELECT Account.AccountNumber, OrderNumber, Type, Status FROM Order ...


7

Triggers are not firing when a record is queried, but formula fields are recalculated. This error is normally happening, if the SOQL query to get record information, exceeds the character limit of 20K. I can make an assumption, that the Account object has a big number of custom fields (more than 250) and some of them can be pretty complicated formula fields. ...


2

There is method in the DescribeFieldResult to determine if the field can be used as part of the filter criteria of a WHERE statement, this method isFilterable() can be used to distinguish the field type System.debug('@@@ field LONG ' + Opportunity.Test_Text_Area_Long__c.getDescribe().isFilterable() ); // False System.debug('@@@ field Rich ' + Opportunity....


2

This won't work. The error is telling you that you can't have the outer parentheses in your query: SELECT Id,Partner__c FROM Promo_Association__c WHERE Partnership__c =null OR Partnership__c IN ( SELECT AccountId FROM Opportunity WHERE id =:partnershipId ) However, that will only lead to your next error, namely "Semi join sub-selects are not ...


0

If Priority is a number value, it's easiest to build a Roll-up Summary field on Person__c to get the MIN value of the Priority__c, then you can just run a query on Person__c using the summary field.


Top 50 recent answers are included