Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
16 views

NULL IF Statement is making a linebreak

I have a section on our Opportunity that creates a Text formula based on if a box in column A is ticked and the same box in column B is not. For example, if we request Item 1, we tick the first box, ...
0
votes
1answer
17 views

Empty String check not working

I am developing an Apex class which is making a webservice callout by supplying Account number as the request payload. If the Account is not found in the external system, the webservice is returning a ...
0
votes
1answer
16 views

Error saving formula - IF statement needs revision

I need to simplify my code, due to the IF formula being too long. This formula is being used in a visualforce page that populates a pagesection based on user input choices. Can someone help me with ...
1
vote
1answer
22 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....
0
votes
2answers
48 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 ...
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&...
0
votes
1answer
51 views

Else if part getting skipped Salesforce Apex

I wrote this class with a method that sends an email from Sendgrid based on each template id. It works fine except, I have an if else statement which only runs the if and else part and not the else if....
0
votes
2answers
29 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
61 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
29 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
28 views

Question related to Process builder field update based on conditions

I am working on a scenario where we have a custom object which has standard Name field and an Autonumber field and 3 record types. I am trying to update the Name field based on the record type as ...
0
votes
0answers
14 views

Formula IF with territory field / salesforce lightning

Good afternoon, I want to display "East", if territories are: New England Northeast Mid-Atlantic Southeast Midwest Hearthland I want to display "West", if territories aren't these ...
1
vote
1answer
40 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 ...
-1
votes
1answer
31 views

string.isempty doesn't appear to work when trying to retrieve price list Name

it appears my if statement with String.isEmpty doesn't seem to be working. What i want it to do is check if a price list entry doesn't exist it creates a new one, and if it does it updates that one. ...
0
votes
1answer
25 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="...
1
vote
1answer
265 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 ...
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 - ...
1
vote
2answers
209 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, ...
0
votes
0answers
23 views

Never left if condition

I've got a tricky question, my code doesn't work - suprise. I would like to return only a list of 'filtred' data but my code never leav a if condition. So when if condition return true and my script ...
2
votes
2answers
58 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 = ...
0
votes
1answer
28 views

Creating a formula field using IF statement with Text return [duplicate]

I am creating a Formula field that returns texts when: 1Picklist_Status = Activated, the return text should be A else null 2Picklist_Status = Sold, the return should be B else null ...
-2
votes
1answer
268 views

If condition for Values in Map<string,List<string>in apex

I have below snapshot where i just wanted to check if map is having the value 20 in it or not. How i can write if condition for list of string values map<string,List<string>> getmap=new ...
3
votes
1answer
175 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
1answer
58 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 ...
0
votes
3answers
230 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
40 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
307 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
37 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
541 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 ...
1
vote
2answers
132 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 ...
0
votes
1answer
51 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
1answer
1k 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
1answer
37 views

multiselect pick list custom field

I have a long if(includes formula that is aggregating a few common responses into the same text values. (It's longer than below but that is enough for my question). There are actually 3 outcomes I ...
0
votes
1answer
27 views

IF(CONTAINS) question from an MPL

I am trying to aggregate data from an MPL into a separate field with fewer values. When I run the formulas, it is only returning the first value. Is there a way to rewrite the formula so that all true ...
0
votes
1answer
42 views

Execution enters IF loop, even if the condition is not satisfied

if(User.FirstName != NULL && User.MiddleName != NULL && User.LastName != NULL) { User usr = [SELECT FirstName,MiddleName,LastName FROM User WHERE ...
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
0answers
41 views

If condition in HTML email template not working. Weird

I have a HTML email template with IF loop which is not working. {!IF(NOT(ISNULL(pba__Closing__c.Buildings_survey_booked_To__c)),' to '+pba__Closing__c.Buildings_survey_booked_To__c,' ')} There is ...
2
votes
4answers
5k 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 ...
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 ...
0
votes
2answers
1k views

Unique Random String Generator in APEX- SOLVED

What needs to be added (an SOQL query perhaps) in the 'else if' statement which checks the value within the c.Name column and tells if the generated random string already exists, and if so add break/...
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 ...
-1
votes
1answer
24 views

Visualforce email template IF condition for Second Opportunity Owner field

I have an email alert that goes out when an Opportunity is changed to Closed Won and it says who the Opportunity Owner is. Sometimes, a second salesperson is involved in the deal, so I have a field ...
6
votes
1answer
21k 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 ...
1
vote
1answer
57 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 ...
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 ...
0
votes
1answer
109 views

Populate HTML only if data in a field exists

I have a custom object that I am trying to display using visualforce. Some of the fields in the custom object may not have data. I want to check this and only if the data exists, then print the html ...
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(...
0
votes
1answer
91 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 ...
1
vote
1answer
207 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 ...
0
votes
2answers
263 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 ...