Skip to main content 3 月 5 日~ 6 日にサンフランシスコで開催される TDX (Salesforce+ でも配信) で「Developer Conference for the AI Agent Era (AI エージェント時代に向けた開発者向けカンファレンス)」にぜひご参加ください。お申し込みはこちら

#Validation Rule2 人がディスカッション中

Looking for some ideas about how to create create and utilize promotion or discount codes in NPSP.  We will be utilizing an Experience Cloud site with a registration flow where users will be able to choose a membership level and submit payment through the flow.  We will want to be able to create and provide promotion/discount codes to some users, so that they can enter them in the flow and receive an immediate discount.  Some of the codes will be one-use codes and others will be provided to multiple people at a time. Thank you for any input! 

6 件の回答
  1. 2023年11月23日 21:46

    @Elissa Stern I've seen this done in an Event App with custom metadata. 

     

    Essentially you create a custom metadata object called "Discount Codes". You add to it a field that stores the code "20OFF". You also can create a field that stores the percentage off, or dollar amount off. (you can do both, but it gets a little more complicated). Then a field for the expiration date.  ( There is no reason you can't do a similar thing with a custom object, particularly if you have a large volume of these.) Something to keep in mind is that you are gonna want the "20OFF"  to be a unique identifier within the expiration timeframe.  

     

    The tricky part is going to be providing a good UX in flow to actually check the discount.  Without a custom LWC, it will be hard to mimic the UX you are familiar with at most checkouts.  Click a button and get immediate feedback. ( It can be done though! but might not scale well if you have a large number of these active at one time.)

     

    Anyway, the sketch of it would be, to take the discount code entered by the end user. Attempt to retrieve the custom metadata object (done using the standard GET records node), check if you found one, and that the expiration hasn't passed. If so apply the discount. If not display a message telling the user that the code doesn't exist or is expired!

     

    Hope that helps!

0/9000
Hello again. I'm trying to write a validation rule that will prevent our sales people from moving an opportunity stage backward to "Prospect" after it has advanced past that stage. We have many stages, so the rule is rather lengthy. Please bear with me.

 

This is what I have so far:

 

OR(

 

ISPICKVAL( StageName, "Deferred Opportunity"),true, 

 

ISPICKVAL( StageName, "Webex Complete"),true,

 

ISPICKVAL( StageName, "Id. Decision Makers"),true,

 

ISPICKVAL( StageName, "GM/DP Webex needed"),true,

 

ISPICKVAL( StageName, "second Webex set"),true,

 

ISPICKVAL( StageName, "Second WX Complete"),true,

 

ISPICKVAL( StageName, "Third WX"),true,

 

ISPICKVAL( StageName, "Proposal/Price Quote"),true,

 

ISPICKVAL( StageName, "Onsite Visit Requested"),true,

 

ISPICKVAL( StageName, "Onsite Visit Completed"),true,

 

ISPICKVAL( StageName, "Negotiation/Review"),true,

 

ISPICKVAL( StageName, "Pending Installment Approval"),true,

 

ISPICKVAL( StageName, "Installments Approved"),true,

 

ISPICKVAL( StageName, "Closed or Won"),true,

 

ISPICKVAL( StageName, "Closed or Lost"),true,

 

IF(

 

ISPICKVAL(StageName, "Prospect"),true,false))

 

I'm not getting any syntax errors, but it won't let me place the opportunity into any stages other than "Prospect" when I'm testing it. Any stage other than "Prospect" throws the error message. Obviously we want to advance the stages forward, just not back to "Prospect".

 

As always, your help is greatly appreciated.

 

 

145 件の回答
  1. 2011年10月27日 18:17

    Here's one I wrote using a CASE function and some basic math that you can hack up and use. 

     CASE( StageName , 

     "Prospecting",1, 

     "Qualification",2, 

     "Needs Analysis",3, 

     "Value Proposition",4, 

     "Id. Decision Makers",5, 

     "Perception Analysis",6, 

     "Proposal/Price Quote",7, 

     "Negotiation/Review",8, 

     "Closed Won",9, 

     "Closed Lost",9,0) 

     < 

     CASE(PRIORVALUE(StageName) , 

     "Prospecting",1, 

     "Qualification",2, 

     "Needs Analysis",3, 

     "Value Proposition",4, 

     "Id. Decision Makers",5, 

     "Perception Analysis",6, 

     "Proposal/Price Quote",7, 

     "Negotiation/Review",8, 

     "Closed Won",9, 

     "Closed Lost",9,0)

0/9000

I am trying to configure a validation rule in my screen flow for the input of the address component. This consists of the Mailing Street, City, State, and Country. There is no "required" field to click on this component, so I am hoping to use a validation rule to make sure that all necessary fields are filled. Initially I had it set to check that all of the above fields were not blank, but in my testing I remembered that some countries do not have states. I have the list of countries with states, and I'm hoping to make a validation rule that considers the following:

 

If the country is one with states, then validate that all address fields are filled in. Else if the country is one without states, make sure that all fields except state are filled in. 

 

I am struggling to put the if, else statement in my head into a validation rule for the flow.

 

Also, validation rules in flow are different than fields within Salesforce, as the statement should return true if valid.

 

#Flow

11 件の回答
  1. Steven Trumble (Skie) Forum Ambassador
    2024年3月1日 20:39

    Sure, try this.

    Start with all the fields that should not be blank - street, city, country.

     

    Then you hvae two conditions. Either there is a Country with states (province), then state should have a value. or a country without states, then you don't need a value.

    AND(

    NOT(ISBLANK({!Address.street})),

    NOT(ISBLANK({!Address.city})),

    NOT(ISBLANK({!Address.country})),

    OR(

    AND(

    ISBLANK({!Address.province}),

    CASE({!Address.country},

    "Australia", 1,

    "United States", 1,

    "Mexico", 1,

    0

    ) = 0

    ),

    AND(

    NOT(ISBLANK({!Address.province})),

    CASE({!Address.country},

    "Australia", 1,

    "United States", 1,

    "Mexico", 1,

    0

    ) = 1

    )

    )

    )

0/9000

I have a validation rule that is currently enforcing end date to be at least a year from start date and am using End_Date__c < ( Start_Date__c + 365 )

 

I need further validation so that the end date can only be in increments of 1 year. In other words if start date is October 2nd 2024, end date can only be October 22nd 2025, or October 22nd 2026 and so on.

 

Can this be achieved with a validation rule ?

 

#Validation Rules  #Validation Rule  #Creating Validation Rules

4 件の回答
  1. Eric Praud (Activ8 Solar Energies) Forum Ambassador
    2024年10月22日 15:42

    Hi,

     

    The issue with 365 is leap years. I also assume there was a typo and instead of October 2nd 2024 you meant October 22nd 2024

    If so, try this:

    ADDMONTHS(Start_Date__c ,12*(YEAR(End_Date__c)-YEAR(Start_Date__c)))<>End_Date__c
0/9000

Hi there , 

I am trying to figure out the best way to keep users from putting any internal mailbox addresses in the to/cc field when they are replying to the client or forwarding the new email cases to other internal teams. We have separate process to transfer cases to the other teams (Via screen flow). However, I am still seeing the examples where users are putting the mailbox addresses in the to/cc fields. 

 

There is now a flow that throw out the custom error when users put any internal team address in the field. The starting object is Email Message. All the email-to-case mailbox addresses are baked into Custom metadata (field: Transfer mailbox address) that flow fetches to show error if it finds one.   

 

Issues with email addresses string in the flow.

However,  it is not triggering when users are typing multiple email addresses (that also includes internal mailbox addresses) in to/cc field as this condition is not passing because whatever custom metadata record flow is finding it only matching to one email address and the to/cc field is represented as string (with multiple emails address, when present such as : 123@abc.com;675@abc.com,ourmailbox@xyz.com). I can't use CONTAINS in below Get Records condition direction [Transfer email address CONTAINS Record>toadderess) as I need to find a way to reverse to  [Record>toadderess CONTAINS Transfer email address ). OR find another way to find the mailbox adderss value from the to/cc address string. I think formula would help. Any help is greatly appreciated. Thank you, Mit  

 

email addresses.png

 

#Flow  #Formulas  #Salesforce Developer  #Automation  #Validation Rule

2 件の回答
  1. Mikey Brown (SETGO Partners) Forum Ambassador
    2024年6月21日 18:23

    Hey Mit, 

     

    I wonder if you could do something that checks to see if the To Address and CC Address contains a ;. If so, that would indicate there are multiple addresses. 

     

    You could then have the flow essentially "loop" through that string, parse out each email address and check those individually. I've shared a response here that details how you can use flow to cycle through a comma separated string, or in this case semi-colon separated: https://trailhead.salesforce.com/de/trailblazer-community/feed/0D54V00007BID5hSAH

     

    Thanks,

    Mikey

0/9000

Hello there!

 

I'm having troubles with a validation rule and maybe someone can give me some advice or support.

 

I have three fields for Budget planing. 

  • Field 1 (Total Budget) indicates the total available Budget. 
  • Field 2 (Amount spent) indicates the total amount that will be spent. 
  • Field 3 (Remaining Budget) indicates the total remaining Budget.

So, I have created an easy validation rule, that restricts the Field 2 to be greater than Field 1. 

 

Field 2 >= Field 1

Logic, right? But now I'm having the problem, that I get an error message from the system if I try to spent the total available budget, so that Field 3 could be = 0 EUR. So, to avoid the validation error, I have to safe 1 EUR. 

 

In conclusion, I need to be able to spent all the Budget without exceeding the available amount, but no more... So why? What I'm missing?

 

Thanks in advance for your support :) 

 

#Validation Rule

5 件の回答
  1. Steven Trumble (Skie) Forum Ambassador
    2024年8月12日 16:06

    Could be. Do you have any other validation rules running on this object or these fields?

    Make sure you do thorough testing before deploying to production, but I'm quite confident the formula is correct.

0/9000

Step not yet complete in ----- Playground

 

An unexpected error occurred while inserting Opportunity records and we couldn't check your work. Make sure Opportunity records can be inserted in this org, and click "Check Challenge" again. If this continues, contact the Trailhead Help team.

47 件の回答
  1. 2023年12月19日 14:11

     https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007UpAE7SAN 

     

    Hello, I have resolved my error. #Validation Rule

    here are the steps:-

    • First click setup then open object manager.
    • Second click opportunity then open field dependencies.
    • Third edit field dependencies and make sure every lost and won values are included then save it then check your challenge.

    One more point I'm adding... There are two pages in the lost and won... So try to select all and not only the 1st page values...

0/9000
4 件の回答
  1. 2023年10月3日 20:49

    @Anmol Gupta Yes, that should not be a problem. You can access the Parent field something like this: Parent__r.FieldAPIName

0/9000

How do I write a validation rule to require a multiselect picklist field?

 

I cannot find this information anywhere please help!

 

The field in question is 'Market Group'

 

Thanks!

 

@Who owes me a beer?!? #Validation Rule @Steve Molis

10 件の回答
  1. 2024年6月11日 12:51

    This formula is a little bit wonky, you don't really need that OR clause

     

    You could just use

     

    AND(

    ISNEW(),

    ISBLANK( Market_Group_s__c )

    )

    That will trigger if a User creates a new record and leaves the Market Group field empty

0/9000

I could have sworn I had this working in sandbox at one point but did a refresh and lost it and now I'm stumped as to how I did it.

 

When a user adds product to an opportunity IF the product is only available in one location a flow will set that SKUs opportunity product record as that location for example Toronto

 

IF the SKU is available in multiple locations the flow will set the location as --OM will Select---

this field is ONLY used when a PO is being processed... its not required for anything else.

 

I created a validation rule at teh Opportunity product object with the rule:

 

AND(

ISPICKVAL(Opportunity.StageName ,"OM PO Process"),

OR(

ISPICKVAL(ERP_Company_Name_PL__c ,"--OM will Select--"),

ISPICKVAL(ERP_Company_Name_PL__c ,"")

)

)

 

but when I change the Stage at the opportunity object it will not trigger this validation rule. if I set the Stage to OM PO process and then go and edit the products at the opportunity product level and hit save then the validation rule works but I need it to trigger when OM changes the stage.

 

when I try and create the validation rule at the Opportunity level I don't have the ability to include fields from the Opportunity product object

 

I'm 99% sure this was working in the past and I don't recall it being an issue when I set it up a while back so I'm a bit confused

 

#Validation Rule  #Salesforce Admin

2 件の回答
  1. 2024年6月11日 0:14
    So as my code shows tge validation rule at the opportunity product objective has no errors but when I change the stage to om po process it does t show the error at the opportunity product unless I edit tge opportunity products.
0/9000