0

This new field will be called "Line item Total Test" on Opportunity Product.

This Formula is not working-

IF(CreatedBy.Profile.Name = "Standard User", TotalPrice),
IF(CreatedBy.Profile.Name = "Administrative User", Grand_Total__c),
'0' 
)
)

Our Goal is if the opportunity or product is created by someone who belongs to the "Standard User" profile than the number in the Total Price field (standard field on opportunity product) will show. If the opportunity or product is created by someone who belongs to the "Administrative User" profile than the number in the Grand_Total__C field (custom formula on opportunity product) will show

7
  • 1
    this is your 3rd formula field question, unless I am mistaken, you seem to have frequent syntax errors, have you considered learning the basics? Trailheads perhaps, and further more reading the documentation? An Introduction to Formulas
    – glls
    Commented Jul 5, 2018 at 22:32
  • I'm learning as I go. I'll read the info on the link you provided to further my limited knowledge.
    – jlh123
    Commented Jul 5, 2018 at 22:37
  • Should I not post on here anymore? I did post three questions but two posts were the same (I just didn't know how to ask it correctly) I mean will anyone help me write this/ explain it?
    – jlh123
    Commented Jul 5, 2018 at 22:39
  • I am simply recommending you learn the basics and understand what you are doing rather than post a quesiton here everytime something "doesnt work" This forum is not intended to teach you the basics nor is it a free coding service. We are here to help you with specific problems you are facing after having demonstrated an effort in trying to resolve this by your own. If you tried, and read the documentation, feel free to link it and highlight the part you dont understand alongside what you are attempting.
    – glls
    Commented Jul 5, 2018 at 22:49
  • 1
    There is nothing wrong with trying to learn, however, note that there are resources that are specifically tailored to do so such as trailhead, there is also a help poratl portal where you can actually "search" for salesforce related resources,. I am not trying to discourage you from using this site, and I do hope you find the above links i posted useful, I am merely pointing out that there are other resources for you to learn the basics.
    – glls
    Commented Jul 5, 2018 at 23:08

1 Answer 1

0

Formulas can be highly counterintuitive if you don't have a background in some kind of code-based discipline.

Here's a couple of key concepts that are in play here.

A function in a formula always looks like this:

FUNCTION_NAME(list, of, parameters)

The parameters can be literals (values you write out, like 2.0), merge fields, expressions like Amount * 0.5, or other functions to evaluate. They're always separated by commas.

Different functions require specific sets of parameters. IF() takes 3: a comparison, a value to use when it's true, and a value to use when it's false.

Functions within functions always nest cleanly with matched parentheses:

FUNCTION_ONE(2.0, Id, FUNCTION_TWO(ParentId)

meaning that the outermost function closes last, and fully encloses all of its parameters in its parentheses. Inner function expressions must nest similarly, always with a balanced set of parentheses around the parameters for a single function.

Here, what you need to do is nest your IF() statements so that when the outer one's first parameter is false, its value (the third parameter) is the result of another IF() function - which must itself have 3 parameters (condition, when true value, when false value).

That should be enough to express your objective. See if you can stitch the values you're working with into that structure, and make use of the formula editor's Check Syntax button. It will tell you when something's wrong at the code level, as opposed to the behavior level.

Resources

2
  • Thank you, David. I checked out the materials you suggested and was able to write it. For anyone with less experience reading this here is what worked for me- IF( Opportunity.RecordTypeId = "012390000005zTL", TotalPrice, IF(Opportunity.RecordTypeId = "01239000000Uaso", Grand_Total__c, null))
    – jlh123
    Commented Jul 8, 2018 at 15:01
  • I am very glad this helped! I hope you feel more confident tackling complex formulas - please don't hesitate to continue asking formula questions. See if you can get to the valid syntax point and you'll have an easier time working through any behavior challenges that arise.
    – David Reed
    Commented Jul 8, 2018 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .