Questions tagged [conditional]
The conditional tag has no usage guidance.
97
questions
6
votes
2answers
680 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
1answer
338 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
1answer
271 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
1answer
552 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 ...
4
votes
2answers
2k 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)) {
...
3
votes
1answer
12k 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=...
3
votes
1answer
458 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
1answer
6k 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}"/>
...
3
votes
1answer
7k 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 ...
3
votes
1answer
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:...
2
votes
2answers
904 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
2answers
796 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
1answer
59 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
1answer
271 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
1answer
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
1answer
807 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
2answers
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
1answer
30 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
2answers
946 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
2answers
795 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
1answer
66 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 ...
2
votes
1answer
114 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
1answer
43 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
2answers
342 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
2answers
1k 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 ...
2
votes
1answer
37 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
0answers
119 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 ...
2
votes
1answer
2k 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 ...
2
votes
0answers
151 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 ...
1
vote
3answers
1k 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
1answer
94 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
2answers
2k 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
1answer
53 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
2answers
3k 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
1answer
42 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
2answers
554 views
Appending text to Date field-Visualforce
I have to append a text PUNS to a date field (weird customer requirement!) if a custom field "Material Group" material_group__c in Object Order Line has certain values A, AB, C.. Since changing this ...
1
vote
1answer
1k 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....
1
vote
1answer
46 views
If/else Statement not evaluating issues
I have something weird going on with my code. I have a Data Extension name “DEXT Seeds”. I am checking the DataSourceName_ to see if this list is picked by a user. I have an if/else statement that ...
1
vote
1answer
53 views
Nested Parentheses in an If condition
I'm refactoring legacy code and I'm having a challenging time unraveling the order in which these conditions are evaluated. I'm assuming the two most nested conditions take precedence but I haven't ...
1
vote
2answers
287 views
Inline Conditional Visualforce
I have a simple question that seems to be escaping me at the moment...
The typical way I use inline conditionals is: {!IF(booleanValue,"SOMECONTENT-IF VALUE IS TRUE", "SOMEOTHERCONTENT-IF VALUE IS ...
1
vote
2answers
4k views
Apex trigger to throw error message
I have below Apex trigger code which fails to enter first if condition which it should do. Can someone suggest me a way out if by maps or other kind of developments?
Please note
System.debug('@@@...
1
vote
1answer
65 views
Conditional OR not working as expected
I am not sure what I am missing, I am trying to execute something only if the value of 2 parameters are not empty. So if 1 or both are empty, excecute code a, if both values are not empty, excecute ...
1
vote
3answers
3k 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
...
1
vote
1answer
607 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 ...
1
vote
1answer
73 views
Conditional Visualforce Component call from Visualforce Page
We have to visualforce components. I wanted to call the components based upon a flag on the custom object.
I ended up with the following visualforce page, which works, but since I am not really a ...
1
vote
2answers
245 views
disable apex:commandButton is not working
Apex class:
public Integer sCount {get;set;}
Attachments = [SELECT Id,Name FROM Attachment WHERE Parentid =:caseId ];
Integer sCount = Attachments.size();
Vf page:
<apex:commandButton ...
1
vote
1answer
2k views
Apex Command Button onclick condition
This is a generic question
Can I add <apex:commandbutton onclick="if condition? result 1 else result 2">
I would really appreciate a simple example if this is possible.
Thanks in advance
1
vote
1answer
244 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 ...
1
vote
1answer
149 views
Formula Field to get most current year from 3 fields
I have 3 different fields that track year in the form of text (4 characters). I'm trying to create a new formula field that would give me the latest year out of all 3 fields.
For example: field1= ...
1
vote
1answer
47 views
Conditional Checkbox to change following field type
I have a requirement where by I would like to have a field type following a checkbox change to a Master-Detail Relationship if the checkbox is check.
E.g
Employee
Visitor (tick as ...