12

This code was actually copy-pasted from a UTF-8 file to an ASCII file at some point, which turned the original symbols into "?", because they were not convertable from UTF-8. The original code probably should have looked like this: Phone{!IF(sortExpression=='Phone',IF(sortDirection='ASC','▲','▼'),'') This is a pretty common design; if the field is sorted ...


9

In this specific case, it would be marginally more efficient to use BLANKVALUE, just as you would with a formula: <apex:outputText value="{!BLANKVALUE(item['text_1'],item['text_2'])}" /> A merge expression begins with {! and ends with }. You do not need to use the syntax recursively. Once you're in "expression mode", you stay there until you exit it ...


8

You can use standard functions in the rendered statement <apex:outputLink value="/page" styleClass="btn" id="register" rendered="{!IF(AND(Category__c == 'data1',article.Custom_URL == ''), TRUE, FALSE)}">Register</apex:outputLink>


7

It is perfectly fine to negate the contains result. Boolean isValueNotInSet = !someSet.contains(someValue); Notice, however, that it is not necessary to check for yourself if the Set already contains a value when adding to it. Straight from the documentation: add(setElement) Adds an element to the set if it is not already present.


7

Don't do either: when adding to a set, the values are automatically deduplicated. // Adds the value if not already present in the set. cgUsersToDeleteSet.add(cgm); Also, there's a convenient method called removeAll that lets you avoid doing the initial IF statements. You could use it like this: cgUsersToDeleteSet.addAll(memberIds); cgUsersToDeleteSet....


7

Remember that the IF function syntax is IF(logical_test, value_if_true, value_if_false). So if you want an "else if" clause, put another IF function in place of value_if_false. IF(condition1, 'value 1', IF(condition2, 'value 2', 'value 3')); The above is functionally equivalent to the following Apex: if (condition 1) { return 'value 1'; } else if (...


7

Yes, I would say there is a much better way. Use the Id.getSObjectType method. public String getAddress(Id recordId) { if (recordId == null) return null; SObjectType idType = recordId.getSObjectType(); // further logic } Now, if you can set up your helper classes to just use an empty constructor, you could dynamically instantiate them based on ...


6

This is just another syntax for creating an IF() statement. It is known as a ternary conditional operation. Take a look here for some more info on boolean and conditional statements. THIS return (profileId == null) ? initializeView() : initializeUpdate(); Says the same thing as THIS if(profileId == null){ return initializeView(); } else { return ...


6

I think you're referencing an SObjectField token. Make sure you're referencing a record's record type name: if(someRecord.RecordType.Name == 'Record Type 1') { // ... Using the other form is technically allowed, but will never be true: if(Account.RecordType.Name == 'Record Type 1') { // Always false


6

You cannot check for multiple strings in a single variable like you did. You need to split the expression. Additionally you are missing two percent-signs for the elseif-part. So the following part: @CustomerType == ("Commercial" OR "Architect" OR "Builder") is changed to this: (@CustomerType == "Commercial" OR @CustomerType == "Architect" OR @...


5

You aren't allowed to use angle-brackets inside a merge expression. Why not just use an apex:outputLink? <apex:outputLink value="/{!legalRequest.Id}" rendered={!AND(legalRequest.Request_Type__c == 'Sales', legalRequest.Service_Type__c == 'New Business')} > {!legalRequest.Name} </apex:outputLink>


5

That clause returns true if any of the fields are null. Here's a simple truth table for that statement: record.Email == null || record.Phone == null Email Null? | Phone Null? | Either Null? -------------------------------------------------- true | true | true true | false | true false | true | true ...


5

You can use rendered property to display them conditionally: <apex:outputText value="{!item['text_1']}" rendered="{NOT(ISBLANK(item['text_1']))}"/> <apex:outputText value="{!item['text_2']}" rendered="{NOT(ISBLANK(item['text_2']))}"/> **Added: Use IF condition along with blank check in value property, here is a correct syntax: <apex:...


5

This is what we call "Dynamic SOQL". Basically, you just build a raw string and pass it to Database.query: String[] filters = new String[0]; if(gender != null) { filters.add('Gender__c = :gender'); } if(veteran != null) { filters.add('Veteran__c = :veteran'); } // etc... SObject[] results = Database.query( 'SELECT Id, ... FROM Object WHERE '+ ...


5

You have two basic options: Use the Set.contains method Join complete logical clauses The first strategy would look like: Set<Integer> multiplesOf4 = new Set<Integer>{0,4,8,12,...}; for (Integer i = 0; ...) { if (multiplesOf4.contains(i)) { // do stuff } } The second strategy would look like: if (i == 0 || i == 4 || i == ...


5

This code is very confused. Let's pull out the IF expression: {!IF(sortExpression=='Phone', IF(sortDirection='ASC', '?', '?'), '')} This IF results in one of two values. If sortExpression is 'Phone', the whole IF evaluates to '?'. The inner IF() function effectively does nothing, returning "?" regardless of whether it is true or ...


5

Use empty to determine if something is empty (or, in this case, not empty): {!not(empty(v.guid))} However, I'm not sure you can do all this with the "default" attribute, since it's not meant to be used this way. The documentation says: The default value for the attribute, which can be overwritten as needed. When setting a default value, expressions ...


4

If you do not have Read access to the field, it will always appear false (or perhaps null would be more accurate). As a side note, you do not need two outputPanel tags. Just use: <apex:outputPanel> {!IF(response.Checkbox__c, 'The checkbox is true', 'The checkbox is false')} </apex:outputPanel>


4

Try using something like this for(contact j : i.Contacts){ string tempName = (j.Name == null) ? 'No Contact Name Associated' : j.Name; temp.add(tempName); } This is know as a ternary conditional statement. From the docs..... There is also a ternary conditional operation, which acts as short hand for an if-then-else statement. The syntax is ...


4

Wrap the code you want within an apex:outputText: <apex:repeat value="{!some-record-list}" var="record"> <apex:outputText rendered="{!CONDITION_A}"> <!-- Lots of code here that processes various sObject fields on the record and displays various info, requires a lot of memory --> </apex:outputText> <apex:...


4

We use the coding convention that the curly brackets can be skipped if the condition is placed on a single line to make these common cases less cluttered looking. (Such conventions generally cause great debate though.) So in your case it would be: if (postIds.size() > 0) PostProperty(postIds); if (putIds.size() > 0) PutProperty(putIds); Your logic ...


4

LWC is not supporting any conditional operators or expression evolution methods in markup. To achieve this you should develop a child component and pass the data and index attributes to child component based on condition render the data in child component's markup Parent.cmp: <template if:true={navigation.data} > <template for:each={...


3

You can in fact used the rendered attribute to do this. For the : <apex:pageblocksection title="Order infos" showheader="true" collapsible="true" columns="1"> you need to put logic in the controller to check the columns of each row and you can then use that variable on the columns. The next one is easy: <apex:pageblocksection title="Shipment ...


3

The syntactic convention of {! ... } is SFDC syntax meaning evaluate the contents as an SFDC formula, merging in values (like pli.Print__c) from the controller. SFDC will evaluate all references to controller variables within a single {!..} without you needing to add extra ! in front of each controller variable - note this is a common mistake. For example:...


3

Yes, they're two separate sets of branch logic. You've written the code correctly. If-then logic look like this: if ( condition ) { expression-or-block } [ else { expression-or-block } ] Your whitespace might be confusing you a bit, but you can definitely see that your first if statement follows the form perfectly. For future reference, you should try to ...


3

I solved it with this line: href="{! IF( $Network.Name=='partners', '/partners/resource/B2B_Favicon' , '/customers/resource/B2B_Favicon') }" i.e. by changing to single quotes.


3

Solution I am a fool. There was nothing wrong with my Promises or their resolve callbacks. The conditional component I was rendering would automatically redirect the page back to the original component. In other words, any time I thought I was rendering the conditional child component, it would immediately instantiate a new parent. Hence why my attributes ...


3

I would think the simplest way to achieve is to just write 3 different aura:if blocks. Something as below? <aura:if isTrue="{!v.selectedVal == 'Phone'}"> .. do something .. </aura:if> <aura:if isTrue="{!v.selectedVal == 'Email'}"> .. do something .. </aura:if> <aura:if isTrue="{!v.selectedVal == 'None'}"> .. do ...


3

Your end statement should just be "endif" That would work IF Syntax here


3

You have 3 options how to fix your code. They are sorted by the most preferred solutions. Refactor the component and move the logic into the helper and check only one boolean aura:attribute Use nasted expression functions and(and(v.userCountry != 'France', v.userCountry != 'Canada'), v.userCountry != 'Suisse')) Use corresponding logical operators v....


Only top voted, non community-wiki answers of a minimum length are eligible