Questions tagged [conditional]
The conditional tag has no usage guidance.
166
questions
9
votes
2
answers
3k
views
Ternary Operator Compile Failure. Incompatible types in ternary operator
Assume we have some code in Apex:
APEX
Boolean isString = true; // or false
List<String> labels = new List<String>{ 'Label' };
Object entity = isString
? labels.get(0)
: ...
7
votes
1
answer
6k
views
LWC: Do I have to use a template element with if:true?
The Lightning Web Components Dev Guide gives this example in the article titled Render HTML Conditionally, where a conditionally-rendered div element is wrapped in a template element containing an if:...
7
votes
1
answer
37k
views
Using arithmetic comparison in if:true statement in Lightning web component [duplicate]
I came to a situation where I want to render a text based on there index value. So, Let's assume I am having a loop which is having an index variable and I want to show some specific text if the index ...
6
votes
2
answers
28k
views
How do I check if a record exists in Flow Builder?
I have an autolaunched flow to create a record with particular field values, unless a record with the same values already exists. This answer offers a method for interactive flows. This answer says ...
6
votes
2
answers
2k
views
In Apex, is it possible to use Polymorphism and Overloading to mitigate the need for conditional logic?
While working-on/playing with the Build a Restaurant-Locator Lightning Component Trailhead, I wanted to develop a more clever (possibly read over-engineered) way of selecting address from either the ...
5
votes
4
answers
4k
views
Conditional rendering based on key in for:each
I'm stuck on how to conditionally render (let alone apply styles) while in a for:each according to an expression.
<lightning-layout-item padding="around-small">
<div class="header-column"...
5
votes
1
answer
839
views
How to Implement "Else If" In Merge Field?
It is possible to write two individual if statements in a style tag for an <apex:column>?
I would like to do something like this:
<apex:column headerValue="Priority" style="{!IF(AgentInfo....
5
votes
1
answer
877
views
Failing to conditionally render Lightning component after setting value from Promise callback
The Goal
I am trying to conditionally render a component after a user successfully uploads a CSV file. Here is the markup for the conditional rendering. Details have been omitted:
<!-- Create ...
5
votes
1
answer
2k
views
Two separate 'if' statements in one Apex method
I'm fairly new at Apex and have two fields that need to be set based on different criteria. I want both sets of If/Else to run, but based on looking at examples I am suspicious that maybe the second ...
5
votes
1
answer
1k
views
CPQ quoteline conditional custom action
I am trying to set up a conditional Custom Action on a CPQ Quote Line. I only want the Desegment Line Custom Action to appear when a custom field "Segmentation_Editable__c" has a value of true.
I ...
4
votes
2
answers
5k
views
Can you use a NOT on Set Contains method?
Is it OK to use a NOT on (negate) a Set.contains() method, or should I use an if/else, or does it not really matter?
Use NOT on contains():
if (!psxAssigneeIds.contains(cgm.MemberId)) {
...
4
votes
1
answer
16k
views
Adding multiple conditions in rendered argument
I have a link that I want to display when Category = 'data1' AND Custom URL = 'data2'.
I know how to do this with only one condition, how can I do this with two conditions?
<apex:outputLink value=...
4
votes
1
answer
17k
views
lightning component empty field check?
<aura:attribute name="guid" type="String" default="{!v.simpleRecord.Loan_Guid__c}"/>
<aura:attribute name="fileCreated" type="Boolean" default="{!v.guid != '' ? true : false}"/>
...
4
votes
1
answer
4k
views
Conditionally Render A Lightning Quick Action? [closed]
I've have a component that implements force:lightningQuickAction but would like to have conditional rendering (i.e only display on the page layout if a bool field == true). I've been researching, but ...
3
votes
1
answer
561
views
Need help understanding conditional statement syntax
Can anyone describe, what the colon and question mark syntax between the two methods is for?
public PageReference initialize() {
String profileId = ApexPages.currentPage().getParameters().get(...
3
votes
1
answer
307
views
replacing visualforce conditional rendering formulas in LWC
so I'm migrating a visualforce component into LWC. In that component, there is a table rendered, and a lot of columns are rendered differently depending on data field values and/or some other ...
3
votes
3
answers
9k
views
Display tabs conditionally in record page
In the custom record page for an object, can I show or hide tabs based on record type? For example, I want to show a tab "Incident Details" if record is an Incident and "Service Request Details" if ...
3
votes
1
answer
21k
views
Aura if - isTrue parameter and multiple conditions
I'm trying this code :
<!-- an exemple :
isTrue='{!and(v.valueOneIsTrue, v.valueThreeIsTrue)}" >-->
<aura:if isTrue="{!AND((v._candidateDetails.contact.Nationalite__c != null), (v....
3
votes
1
answer
2k
views
if condition in visualforce
I am new to salesforce, apex and vf so please bear with me. Below is my code:
<script type="text/javascript">
function updateSplash(){
UpdateUser();
}
</script>
<apex:...
3
votes
1
answer
2k
views
Is it possible to conditionally set the value of an input component?
I tried to create an input component as follows:
<aura:attribute name="dataTotal" type="Map" />
<aura:attribute name="myBoolean" type="Boolean" />
<lightning:input type="number" value=...
3
votes
1
answer
3k
views
How to conditionally render inside a datatable in lightning?
I have a lightning datatable and into one column called 'Set Primary Contact' I want to display an icon if the custom field IsPrimaryContact__c has the value TRUE, or a button 'Set primary contact' if ...
2
votes
3
answers
4k
views
IF with && and || condition SalesForce Apex
I have a trigger that checks the stage of an OPP before it updates.
What I want to do is check if the new Stage is 'X' then the Old Stage is not 'Y' or 'Z' there could be 4 more stages, so if a new ...
2
votes
2
answers
929
views
What is the purpose of this conditional markup?
I am trying to sort records and I encountered the below markup in a Visualforce Page:
<apex:commandLink action="{!ViewData}" value="Phone{!IF(sortExpression=='Phone',IF(sortDirection='ASC','?','?')...
2
votes
2
answers
1k
views
How to render after an if statement with visual force page
I have this code
<apex:outputText value="{!item['text_1']}" />
<apex:outputText value="{!item['text_2']}" />
But item['text_1']} could be empty, if this is empty show text_2
I tried ...
2
votes
1
answer
78
views
Using multiple criteria for IF/THEN function
I am trying to display relevant content to users of a certain type (pro or commercial), but I do have some users that are marked as both. in that case i am using another field (customer type) to ...
2
votes
1
answer
2k
views
How to cover condition referencing record type name in apex test class?
I'm having a hard time covering the condition in my class wherein it is checking for a specific record type name. In my test class, I've already inserted the record type desired, but there's a portion ...
2
votes
1
answer
2k
views
Visualforce IF Statement
The code below is a section in a VF email template that should conditionally output a link to all the Legal Request records where Request Type == Sales AND Service Type == New Business, but something ...
2
votes
1
answer
819
views
List.add( value || 'default value')?
After querying for Account sObjects, I'm adding all the fields into a List. The problem is that some Account sObjects have certain fields and others do not. While adding the fields to my list, I'd ...
2
votes
2
answers
2k
views
Multiple conditions in visualforce
I have the following code within my visualforce page, this ensures only users with the Portal profile can see the page, otherwise they are shown the SFDC page.
<apex:page standardController="...
2
votes
1
answer
1k
views
Aura if and order of execution on conditions
I'm working on showing a component if he is not admin, nor from France, Suisse or Canada :
v.userProfile --> true for admins, false otherwise.
Even for Swiss users, the component was displayed.
I ...
2
votes
2
answers
1k
views
Conditional Cell Color in VF dataTable
I'm using a custom controller to query OpportunityFieldHistory to find changes to Close Date within a given timeframe. Then, the query results are displayed in a VF dataTable. I can display OldValue ...
2
votes
3
answers
4k
views
Can I write a validation rule to make a field enabled or disabled based on picklist value?
Note: in standard page layout
is it possible to write a validation rule to make a field enabled or disabled based on picklist value?
i have a picklist - values
cycle - monthly
...
2
votes
1
answer
600
views
Illegal conversion from List<String> to List<Beverage__c>
I have trouble with a component in an Experience site.
I'm doing a search bar, which makes a search in the information of two components.
It has to show the coincidence or a message like "there's ...
2
votes
1
answer
4k
views
My LWC radio button select is not working - not getting selection
I have a Lightning Web Component with a radio button group. If I select one, I need to capture the selection and conditionally display a div based on that selection. I can't seem to get it working - ...
2
votes
1
answer
495
views
Simple conditional statement
%%[IF AccountNumber == "12345" THEN]%%
html
%%[ELSE]%%
html
%%[ENDIF]%%
Explodes when attempting to validate:
Error 1: Script IF Statement InvalidAn error occurred when
attempting to resolve a ...
2
votes
2
answers
1k
views
Hide Visualforce component based on field in account layout
On my account layout, one of the sections has a visualforce component in there that will only appear if another field on the account layout has a value in it. When there is no value it displays a HTTP ...
2
votes
1
answer
2k
views
LWC Conditional rendering: alternative for fetching the initial database value?
Looking for a conditional rendering solution in lwc, which uses the initial value of a field in the database to decide whether to render or not. I have found a way to get it working, but it seems like ...
2
votes
1
answer
178
views
Only the first IF condition works, and the rest doesn't when nested in Process Builder formula
GOAL: I'm trying to create this criteria in Process Builder where I can detect phone number like (000) 000-0000, 000-000-0000 and 000.000.0000 and turn them into +1 0000000000 format.
I tried to ...
2
votes
1
answer
3k
views
LWC: Use data from outer iteration in inner iteration to conditionally render?
let's say I'm building a Kanban board using LWC, and I have the following markup:
<template>
<div class="kanban-container slds-border_left slds-p-around_medium">
<template ...
2
votes
2
answers
982
views
Apex class: if objType = Project do nothing else proceed?
Forgive me but I'm a bit of a newb when it comes to Apex and found below that was written by a previous developer who worked for my company. Handler creates a task after user inserts an attachment. ...
2
votes
0
answers
263
views
Visualforce conditional rendering formula not evaluating to True
It seems like my rendered If statement is not evaluating as expected (at least my expectations). Basically, I have 2 Id fields pulled from apex, and if they equal each other, it conditionally displays ...
2
votes
0
answers
15k
views
Check if Date field is empty
How can I check if a Date field is empty or blank?
I tried this statement:
if(project.Current_Launch_Date__c==null)
But I don't get the desired result, even if I delete the date value, it still does ...
1
vote
2
answers
3k
views
LWC Get record field values and render DOM elements conditionally
I want to create a custom component for a record page that gets a field value for the record, determines if the value is null or not. If it is null, some content will be shown and some will be hidden. ...
1
vote
3
answers
4k
views
IF Statement AMPscript
Error I'm getting: "An IF statement is not closed with the required ENDIF statement"
Please help!
%%[IF @EventType=='Lunch n' Learn' THEN]%%
SET @Image = Image('b3272b99-f070-4e84-a65e-2a6cae73c794')...
1
vote
2
answers
11k
views
Conditional Rendering in Lightning Component with more than Aura:If(True, ELSE)
I have a lightning:select picklist on a Lightning component called "Best Method of Contact" which is a required picklist, but the required picklist defaults to a blank 'placeholder' value that the ...
1
vote
1
answer
163
views
Build a Query from User Input - Too Many Permutations of If Logic
I have a Visualforce page that allows users to filter a list records based their filter criteria.
My issue is that I end up having to make a permutation for every possible combination of their ...
1
vote
2
answers
3k
views
How to restrict a column to display value if value exists
I have a pageblocktable that is inside pageblocksection. The pageblocktable has many columns. I want 1 of the columns to appear only if it exist.
Following is my code...
<apex:...
1
vote
1
answer
60
views
Is there a way a more efficient way to write the IF statement
Is the there a more efficient way to write the below IF statement so I only need 2 lines of code or can this be solved with a ternary operator ?
if(postIds.size()>0) {
PostProperty(...
1
vote
1
answer
54
views
Dynamic Visualforce generation without components
I am currently very stuck on some logic concerning a visualforce page and it's controller.
Say I have the following code (I don't have any example code because I am stuck without any idea of how to ...
1
vote
2
answers
397
views
Make Reminder Flow work when Event.DueDate changes
I have a Time-Triggered Flow that reminds people one week before the Meeting Due Date. That is easily implementable.
But now I also want to cover the use case where somebody changed the Due Date. In ...