Questions tagged [if]
The if tag has no usage guidance.
89
questions
0
votes
2answers
9 views
Advance formula field nested condition not working
I want a formula like this:
IF (
(Field1 = 'Value1' AND Field2 = 'Value2')
OR
( NOT (ISBLANK (Field3)))
),
"Output1", "Output2")
This is my actual formula:
IF(
(...
0
votes
1answer
21 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
0answers
11 views
Conditional Math Equation in Report
I have a Report that includes a calculation for "days overdue" of a Case (Due Date - Closed Date). SFDC is calling this field CDF1.
I want to add a calculation for the average days overdue ...
0
votes
1answer
56 views
how to concatenate lookup fields given certain circumstances
I finished up this batch but came across an unforeseen scenario and can't seem to figure out how to code in the case it occurs. Here is my current code:
global class Batch implements Database....
0
votes
2answers
55 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
1answer
42 views
Nested IF AND formula: Error when encoding row-level formula: Syntax error. Extra ','
I'm trying to create a row-level formula to calculate the following:
I have a custom object called 'Car Transaction', with the following fields: 'Sign Up Fee' and 'Success Fee'
Here is what I want the ...
0
votes
0answers
21 views
Validation rule that requires fields to be filled out before change of Opp stage except for particular country
This is the Validation Rule I have created so far, what I need is to include - VAT field on the Account can't be blank except when the Account Country field says USA
AND(
NOT(ISBLANK( Account....
0
votes
0answers
18 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
29 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
194 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
54 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
32 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
149 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
34 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
0answers
16 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 ...
0
votes
1answer
31 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 ...
1
vote
1answer
64 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
32 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
27 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
672 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
318 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
24 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
91 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
49 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
454 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
188 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
59 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
472 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
53 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
411 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
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
647 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
143 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
52 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
2k 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
39 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
43 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
54 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
6k 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 ...
-1
votes
1answer
26 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 ...
7
votes
1answer
25k 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
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 ...
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 ...