New answers tagged

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

Based on our conversation, I have put together a sample Aura component that enables/disables a Lightning button. Here it is: SimpleButton.cmp <aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="SimpleButtonCtrl"> <aura:attribute name="cons" type="List" /> <aura:attribute name="isDisabled" type="...


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 ...


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&...


1

The instance of apex controller called from visualforce page will be totally different from the instance called by lightning component. You need to query for the fresh data again from page. Basic criteria can be passed in parameters. public PropertyPDFController(ApexPages.StandardController controller) { hipdeals = new List(); String ...


0

You are creating a new variable in your method, so it will be considered local to that method which doesn't have any value. Don't reinitialise the variable, just do.. hipdeals = [select stuff from opportunity] in your method. Another thing, you are using same Apex class for lightning component and vf also, so once you call the VF using JavaScript window....


1

The FOR XML translates & to &amp;. This works as intended as XML does not support the & character. You could use a placeholder for the delimiter such as pipe (|). And then use the REPLACE function to replace the placeholder with the & character. select case when B.Contact_Email is not null then REPLACE(STUFF ( ...


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

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 ...


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 '%...


-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 ...


2

Please find the below code snippet: Apex Class: public List<Hammer__c> getHummers() { return [SELECT Id, Name, (SELECT Name FROM Factories__r ) FROM Hammer__c]; } VF page: <apex:repeat value="{!hummers}" var="hummer" > <apex:pageBlock title="{!hummer.Name}"> <apex:pageBlockTable value="{!hummer.Factories__r}" var="...


1

Here you can make use of the relationship queries. You can query on Factory__c object along with the Hammer__c object which will tie the factory records to its respective hammer record. That way, it would need only single query and only one method i.e. getHummers would suffice your needs and there won't be any need to use maps to associate factory records ...


2

List<Detail__c> details = [SELECT Info__c FROM Detail__c WHERE MoreInfo__c =: tool.MoreInfo__c LIMIT 1]; this should be outside loop. First create a List<String> to hold MoreInfo__c of all tools the use it in SOQL with IN operator


3

Its called as boxcarring, Salesforce bundles multiple request in to 1 to save repeated calls to server. You can seee from Debug logs, only one is created. A quick solution is to add a timeout or use the promise chain while calling apex. In this way , each apex call will be treated as new transaction and those limits get reset. new Promise(function(resolve,...


5

Aura, and LWC, groups several requests together in order to maximize performance. This is called "boxcar'ing" (or boxcarring) in the documentation. All Apex requests in the same boxcar payload are subject to a single set of governor limits, even though they're allowed to fail/succeed independently. This means you need to make sure you don't place DML before ...


3

If you deployed the field but didn't deploy any profiles then the field security needs to be updated. By default when you deploy a field on its own nobody has access to view it or edit it. Check your field level security for your new field in production.


2

You can use SetupEntityAccess and Apex class to get required information. First SOQL will show all apex class Ids which is enabled for permission set 'CustomPermission'. Second SOQL will show Apex Class Name based on first query result. Map<ID,AggregateResult> mapAccess=new Map<Id, AggregateResult>([SELECT SetupEntityId Id FROM ...


1

As per the documentation of SetupEntityAccess at https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_setupentityaccess.htm SetupEntityAccess - Represents the enabled setup entity access settings (such as for Apex classes) for the parent PermissionSet In this SetupEntityId represents the ID of the entity for which access is ...


Top 50 recent answers are included