Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9
votes
2answers
4k 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 ...
7
votes
1answer
26k 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
4k 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
192 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
3k 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
7k 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
65 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
60 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
280 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
1answer
20 views

Changing the colours of the fields depending on a formula?

I have two number fields on opportunity layout. A and B. I want to create a formula field and when A>B the formula field will be red or just an indication that people will notice it right away when ...
2
votes
2answers
143 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
209 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
9k 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
1k 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
371 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
788 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
54 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
141 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
259 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
5k 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
551 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
1answer
23 views

IF AND OR together in one formula

I want to write a formula for the following: Return Value A IF: Intake__c.Personal_Care__c contains 'toileting/bathing' OR Intake__c.Safety__c contains 'entering or exiting' AND Intake__c....
1
vote
2answers
148 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
62 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
286 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
28 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
5k 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
16 views

Am I just missing a parenthesis somewhere?

IF( ISPICKVAL(FPLHW_Brands__c,"NEH"), IF( RecordType.Name <> "NEH Realtor Enrollment", IF( whw_Renewal__c = False, "a2b29000000yBA7AAM","a2b29000000yBhmAAE&...
1
vote
1answer
837 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
946 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
91 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
56 views

How to check object name by objectId?

trigger CreateTask on ContentVersion (after insert) { List<Task> insertTask = new List<Task>(); Task newTask = new Task(); Schema.DescribeSObjectResult k=Contact.sObjectType.getDescribe();...
0
votes
2answers
68 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
34 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
53 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
2answers
287 views

Unexpected token error in If statement in LWC Javascript controller

This is a basic javascript question. FYI the context is: It is in a Javascript controller for a Salesforce Lightning Web Component, editing in Visual Studio. The code is for selecting a set of table ...
0
votes
2answers
34 views

Conditional display of style

I was trying to display style conditionally based on an attribute. In the below example I am trying to display first 2 elements in the list in blue color and the other 2 elements in green color. When ...
0
votes
3answers
607 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
2k 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
79 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
22 views

Expression cannot be assigned: when trying to use multiple if statements in a for loop

There is an object tm__c which contains LinkedIn URl(URL field),two picklist fields: Backgroundcheck(Yes, NO) and Verification(Pending, Not started, Done) I want to create a batch class so that I have ...
0
votes
3answers
223 views

Null check condition for User object SOQL query

Below is the query I have used :- User singleUser= [SELECT id,name,alias FROM user WHERE alias = 'random' AND name = 'Random Name' LIMIT 1]; In the IF condition I want to check for the null ...
0
votes
1answer
39 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
1answer
3k views

Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 4

I keep getting Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 4 Can anyone advise on where its pulling the 4? IF ( $UserRole.Name = "x", IF( AND (Quantity >...
0
votes
3answers
50 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
118 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
347 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
2k 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....