Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9
votes
2answers
3k views

Best Practice discussion: Difference between SWITCH and IF/ELSE-IF/ELSE? [closed]

NOTE: This is not an opinion-based question. Developers often debate the best way to code ways to do the same thing. Please don't close this as opinion-based. It's a good reference for people choosing ...
6
votes
1answer
17k 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
2answers
3k views

IF Statement on the VF page to display/hide Related list(s)

How can I display/hide related list(s) table on a VF page for a custom object using IF statement? I am currently displaying 3 separate related lists on my VF page using HTML markup, one of those: <...
3
votes
1answer
158 views

An error occurred while checking the query syntax. Errors: Old style JOIN (ANSI JOINs) syntax is not allowed. Please use standard syntax

I've had a few different kinds of query return the following error message, quite often when I'm using 'case when': "An error occurred while checking the query syntax. Errors: Old style JOIN (...
2
votes
2answers
2k views

comparing and assign values to a variable on same line

I saw this kind of logic somewhere in an apex code and got curious about how this can be done. The code is a one liner and does variable check and assignment in the same line. It uses the <> ...
2
votes
4answers
4k views

Multiple OR (||) Conditions in If Statement

Can anyone explain why the following If statement does not work with multiple OR conditions. The goal is when this trigger runs, if the user's Id who is updating the record is not equal to a specific ...
2
votes
1answer
402 views

IN in an IF condition

This may sound silly but I was wondering if we can use an IN in a IF condition. I know we can do this in a query but suppose if I need to run multiple IF conditions on a particular object, it doesn't ...
2
votes
1answer
63 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
56 views

IF and AND statements within Visualforce page

I'm a Visualforce newbie so forgive me if my question comes across as a bit ignorant... I'm trying to render a Visualforce page based on specific conditions. I got it to work with one condition but ...
2
votes
1answer
273 views

Inline If statement not working

Inline if not working with inputfield...using two properties from the controller...compiler error: Syntax error. Missing ')' <apex:inputField id="inpModelValue" value=" {!IF(wrap....
2
votes
2answers
56 views

Help with Formula field IF

I am creating a Formula field that returns texts when: Picklist_Status = Activated, the return text should be A else null Picklist_Status = Sold, the return should be B else null Picklist_Status = ...
2
votes
0answers
193 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
1answer
7k views

Using AND OR in AmpScript IF THEN statement

I am can't figure out something I think is pretty simple. I have an if/then statement and I want to evaluate three things: %%[if @PromoCode == "XXXX" OR @Tier == "XXX" AND @Price == "100" then]%% ...
1
vote
3answers
949 views

Logically comma separating address field to form a String

I am trying to create a string of address in this format: Street, City, State, Country, Zip. Assume that there is an Address object called addr which has account's shipping address. Address addr = ...
1
vote
2answers
110 views

Apex Unit Test for if == null and return statements

I have a simple helper method in my Apex Code that loads an external ID from a field on the related Case.Contact. I have problems to write a proper unit test that covers the last three lines, ...
1
vote
2answers
775 views

Aura :iteration and :if, WARNING: Performance degradation..

I'm receiving a WARNING: Performance degradation: Multiple items were set in iteration message. This occurs in the code below when the aura:if element is there, but not when it isn't. Each group ...
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
80 views

Help with JavaScript Button with If Statement

I know next to nothing about javascript so don't beat me up too much if this is utter garbage, but here is my attempt at a somewhat simple button that looks at 2 values and kicks a flow off or ...
1
vote
1answer
232 views

NullPointerException: Attempt to de-reference a null object in a batchclass

I have this batchclass with which I want to update some checkboxes on account with the values of related assets checkbox values. When running the class I get an System.NullPointerException: Attempt to ...
1
vote
1answer
4k views

Custom Button Formula URL IF condition

IF( NOT(ISNULL(Submission__c.DPM_Project__c)), ahttps://url.aspx?PROJECTID={!Opportunity.Name}&LOCATIONID={!Opportunity.Location__c}&INNCODE={!Opportunity.Inn_Code__c}&BRANDCODE={!...
1
vote
1answer
492 views

How to subtract apex variable in IF condition of Visualforce page

<td style="text-align:center"> {!IF(Project.pse__Planned_Hours__c - {!grandtotalAH})> 0,Project.pse__Planned_Hours__c-Project.Total_Billable_Hours__c,0)} </td> I want to subtract {!...
1
vote
2answers
109 views

IF Statement Ampscript ignores 6th IF statement

I have an email that is in build with a large amount of IF statements contained within the email. The concept of the email is that if the 10 item fields are populated then show all 10 within the body ...
1
vote
1answer
53 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
143 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
1answer
26 views

If Formula to populate Website between 1 of 2 fields

Trying to populate the Website field on the Account if it's blank. Using an IF formula within a workflow to populate when ISBLANK(Website). The WFR is working for the first field, which is Core ...
1
vote
1answer
4k views

Nested IF formulas for a simple logic field on the opportunity

Can you please cast your eyes at my formula and spot the mistake? I've been trying to crack this but to no avail. Looked through example nested formulas and this forum as well... I know I'm just ...
1
vote
1answer
88 views

LWC conditional display on load of component not working

Based on the field values of the Account, I want to display/hide parts of the component when it loads for the first time. I have tried so many things unsuccessfully and am hoping someone can help me ...
1
vote
1answer
29 views

How can I type two If Condition?

I have two promocodes, one is for X Bank and the another one Y Bank, I have just one DE with X Bank Subscribers and Y Bank Subscribers. I want to create one function that shows Promocode X Bank to the ...
1
vote
1answer
902 views

If statement in an html template

I'm trying to add some logic to our templates but there doesn't seem to be much documentation about this topic. The syntax I'm using is the following: {!IF(QA_Ninjas__c.Entities_Agregados__c>0,"...
1
vote
1answer
19 views

Using IsPickVal() function inside Email Templates

I tried using the following ISPICKVAL formula within an email template as shown: MQP Type is a pick list on the Task Object. I have run integration code(Python under AWS) which sets the pick list ...
0
votes
2answers
59 views

IF this or this or this?

I am trying to implement the below code, but I get this error: OR operator can only be applied to Boolean expressions Code: public class Segment { static List<Map<String, Object>> ...
0
votes
1answer
31 views

Ternary Operator error - Error: Compile Error: expecting a colon, found ')' at line

(!GWB_Utility.isNull(cust.FinancialIndicator)?cust.FinancialIndicator == 'Y'? 'Yes':cust.FinancialIndicator == 'N'? 'No':null); Idea - the value will be either Y/N/Null - If it's Y show Yes , N show ...
0
votes
1answer
48 views

Syntax error in this IF statement?

I'm having issues with the following IF statement - it's causing the cloudpage it's on to report an internal server error. I'm assuming the issue is a syntax error somewhere, because I can't see ...
0
votes
3answers
64 views

What happens with an IF formula with multiple TRUE conditions?

I have a multi nested IF statement like below - what happens if a field meets more than one condition - is there a rule to determine which value gets returned? IF(CONTAINS( Custom__Name__c , "/cs/"), ...
0
votes
1answer
1k views

How to write a trigger handler with trigger new [closed]

I am having some trouble to translate my trigger to a trigger handler how do I deal with the for(Invoice__c record:Trigger.new) part? Trigger: trigger UpdateAutoNumber on Invoice__c (before insert) ...
0
votes
2answers
67 views

if condition in apex class to execute when we are execute test class

Source_System_Configuaration__c systemconfig; if(Test.isRunningTest()){ system.debug('systemconfig'+systemconfig); systemconfig=[SELECT Id, System_Id__c, Source_Confidence__c ...
0
votes
1answer
35 views

'Attempt to de-reference a null object' with Field__c.contains()

When I use contains, I get Attempt to de-reference a null object: for(Gear__c g : gears{ if(toolsMap.get(g.Id).Status__c == 'Off' || toolsMap.get(g.Id).HelpText__c.contains('Hello there!')){ ...
0
votes
3answers
49 views

IF Formula on Opportunity Date

I'm sure this is ridiculously simple. I'm trying to put Opportunities into groups based on Age This is the formula I've written IF(Opportunity_Age__c < 100, "Short Term", IF( OR( ...
0
votes
1answer
76 views

Why does the trigger always read my if statement as null? [duplicate]

See the code below from an APEX trigger. For some reason, my trigger always reads nextRenewalDate (field from Account object) as null, regardless of whether or not it is blank. Racking my brain here ...
0
votes
2answers
202 views

Error saving formula field because IF statement is too long

I'm trying to create a formula field that will tell me the region which a country is part of. Problem is that there are too many. The code below is just for European Union and Europe and I'm already ...
0
votes
1answer
1k views

How to compare dates lightning component

I currently have the following comparison in a Lightning Component: <aura:iteration items="{!v.opleidingenList}" var="opleiding"> <aura:if isTrue="{opleiding.Createddate__c >= v....
0
votes
1answer
15 views

Formula field needs to determine where today is in an opportunity's period of performance (PoP)

Not worrying about leap years, I need an if/case statement for: if (today() < start_date__c+364), then PoP_location__c='Base year' if ((today() >= start_date__c+365) and (today() < ...
0
votes
1answer
1k views

Using IF statement in a VisualForce page's For(repeat) loop?

I am trying to display fields with some static text based on another field's value. <apex:repeat value="{!caseHistory}" var="casHistory"> <div class="section1"> ...
0
votes
1answer
335 views

How to place an IF statement in a title attribute on a Visualforce page

I have a syntax issue with this line of code: <apex:sectionHeader title="{!if(!PP_IsOwner,!$Label.D1,!$Label.D2)} /> Here is the relevant line of code from the controller: public Boolean ...
0
votes
1answer
22 views

Custom Button URL using IF condition found on Salesforce doc but not working

I am trying to create a custom button redirecting either to : the correct LinkedIn profile if the LinkedIn ID is filled a LinkedIn search using First Name & Last Name So far, here is what I have ...
0
votes
1answer
24 views

formula field with lots of nested Ifs and Ands - confusion

having a little trouble following the necessary logic to get this formula field syntax correct. i need to accomplish the following: If source_system__c="Adobe" AND If type__c="...
0
votes
1answer
19 views

Control going inside 'If' block even when it should not (only for 1 value)

I am trying to count the number of weekdays (Monday - Friday) by taking the number of days since 01-07-1900 (7th January, 1900), for a given date, and checking the modulus by 7. For modulus values 0 - ...
0
votes
1answer
32 views

Image formula field render issue

I have a formula that is rendering a static resource based on checkboxes on my Contact record. The issue I am seeing is that when the image loads, it appears super tiny - the static resource is not ...
0
votes
1answer
205 views

Redirect to a url on a click of custom button through if condition

Hey i am trying to redirect on a url on a click of custom button which will create a new quote in which name will be prepopulate as same as parent opportunity name but it is not redirecting on a page....
0
votes
1answer
404 views

Conditional custom button on page direct to URL if condition = true, display message if false

I have a custom button on a custom object page from which I generate a VisualForce PDF document (Content Source = URL). There are conditions, however, where the PDF should not be generated based on ...