I am working on a validation rule on the Opportunity object. The goal is to bypass a validation rule if an item from a Multi-Select picklist is selected, otherwise the code should fire
Here's what I have so far - everything works except the exception portion - NOT(CONTAINS('Campaign_Tactic__c','Call Monitoring')))
So the validation rule should fire unless the Call Monitoring multi-select is chosen.
The Validation Rule should prevent an Opportunity Save if:
Opportunity Record Type = True
Opportunity Stage = Closed Won or Proposal Request
Landing Page Setup Field = blank/no data
Campaign Tactic Multi-Select field = does not contain the Call Monitoring Option
AND (
RecordType.DeveloperName = "New_Opportunity",
OR (
ISPICKVAL(StageName, "Closed Won"),
ISPICKVAL(StageName, "Proposal Request")
),
AND (
ISBLANK(TEXT(Landing_Page_Setup__c))
),
(!CONTAINS('Campaign_Tactic__c','Call Monitoring'))
)
From the Salesforce Formula Function Reference, it's important to note
The CONTAINS function does not support multi-select picklists. Use INCLUDES to see if a multi-select picklist has a specific value.
Additionally, the first argument you're providing to CONTAINS() is a quoted string literal, not a field reference, and the outer parentheses are extraneous:
(!CONTAINS('Campaign_Tactic__c','Call Monitoring'))
Your final clause should use INCLUDES(), as:
!INCLUDES(Campaign_Tactic__c, 'Call Monitoring')
Note also that AND() with a single argument can be replaced by the argument alone, so
AND (
ISBLANK(TEXT(Landing_Page_Setup__c))
),
reduces to
ISBLANK(TEXT(Landing_Page_Setup__c)),
You need the TEXT() call only if that field is a picklist.
Related
I have the following validation rule in my controller
"holder_name" => 'required_if:paymentMethod,==,credit_card',
That is, if paymentMethod = credit_card then holder_name is required / mandatory.
Now I need one more condition to be checked.
I'll give the example as it would be in pure php, using if
For example I need to check if (paymentMethod = credit_card and card_id! = Null)
I already tried using two required_if:
'required_if:paymentMethod,==,credit_card'|'required_if:card_id,!=,null'
But it does not work.
Use the following rule for your validation.
The required_with rule mandates a field if any of listed ones are non-empty.
'required_if:paymentMethod,credit_card|required_with:card_id'
As part of an email step in our Flow, we are creating an HTML table, where certain rows are hidden using css.
So our expression formula (in the body of the Outlook - Send an email from a Shared Mailbox step looks like this:
if(
And(
Or(
equals(triggerBody()['DD_Artwork']['Value'], 'Bargain New Store')
, equals(triggerBody()['DD_Artwork']['Value'], 'Home & Fashion')
,equals(triggerBody()['DD_Artwork']['Value'], 'Home Store'))
, #empty(triggerBody()?['StoreOpeningDate']))
,'tr.StoreOpenDate {display:visible}', 'tr.StoreOpenDate {display:none}')
this part, checking the Date Selector field StoreOpeningDate is not working:
, #empty(triggerBody()?['StoreOpeningDate']))
we have also tried:
, Not IsBlank(triggerBody()?['StoreOpeningDate']))
and
, Not IsEmpty(triggerBody()?['StoreOpeningDate']))
and even:
, Not equals(triggerBody()?['StoreOpeningDate']), '')
but we always get the error message The expression is invalid
so what's the right way to go about this?
I faced a similar problem. The TriggerBody() function is doing the damage. Just use
Empty(item()?['DateField']) not equal to false in the condition.
I have an existing (WIP) pyramid project, with the simplistic forms all being done by hand. As the user requirements have been steadily increasing in complexity, I wanted to integrate deform forms to simplify my own maintenance/programming tasks.
My initial test was to try for an interfield form[1], the purpose being to ensure that a certain date predates another date in the form. Here's the simplified definition for the schema and validator:-
class Schema(colander.MappingSchema):
startdate = colander.SchemaNode(colander.Date())
enddate = colander.SchemaNode(colander.Date())
def validator(form, value):
if value['enddate'] - value['startdate'] < 0:
exc = colander.Invalid(form, 'Start date must precede End date')
exc['enddate'] = 'Must be after %s' % value['startdate']
raise exc
schema = Schema(validator=validator)
form = deform.Form(schema, buttons=('submit',))
I then pass the form to my mako template and call:-
${form.render() | n}
This renders the form properly, and my date selectors work (of course, after I had to mess around with loading the correct CSS and javascripts). However clicking submit doesn't do any validation (not even the basic 'you didn't enter a value'), instead it goes right back to my view_config.
What could I be missing?
[1] - https://deformdemo.pylonsproject.org/interfield/
It turns out deform doesn't handle the validation automatically, and I have to actually call validate, something like below:-
try:
appstruct = form.validate(request.POST.items())
except deform.ValidationFailure as e:
return {'form': e.render()}
I'm having some trouble using the Former plugin for Laravel, to handle forms & fields.
The use-case is an "edit"-form for a given model.
Former::text('title')
->label('Title')
->value( $title );
Former::text('description')
->label('Description')
->value( $description );
Rules:
The title must always exist and be at least 10 chars long.
The description may be empty.
Expected behaviour:
When loading the edit form, I expect the form to show the values of $title and $description in the fields.
Whenever submitting a the form with invalid field-values, I expect the submitted values to be shown in the fields, instead of the values of $title and $description.
Problem:
This works only when submitting non-empty strings!
When submitting an empty-string, it's like Former handles it like the field-hasn't even been submitted, and therefore uses the value given by $title or $description instead.
I thought Former was able to do this "smart", and take the value($variable) value only if the posted data does not contain the field. But it seems Former is taking the variables value also when the submitted was empty.
Why is this a problem?
Imagine you edit both fields, and actually want to change the title and remove the description entirely, which is valid according to the rules. Then, because you entered a too short title, the validation does not pass, and title will get the new (too short) title as field-value, while the description value will fall back to the value of the $description variable, instead of showing an empty field, which was posted.
It feels like $_POST['description'] = "" is treated like $_POST['description'] = null or is not set - even though the empty field is part of the post.
In your view
//replace
Former::text('title')
->label('Title')
->value( $title );
//with
Former::text('title')
->label('Title')
... and in your controller
//add
Former::populate($model);
$model beeing the model in question :)
$model->title must ofc exist and have the same value as $title in your original code.
if you use ->value($somevalue) with Former, $somevalue will allways be used.
In CodeIgniter, how do i validate phone numbers containing '+' and '-' symbols?
You cannot enter a number with "-" since you defined integer as the validation rule. Therefore, the validation will fail. You need to work with RegEx so that you can create more complex validation. See the topic on validations in the CI manual for more info.
Your validation rule:
$this->form_validation->set_rules('foo', 'Number', 'callback_number_validation');
Note how the keyword callback_ is used to identify CI your function for validation.
Your callback function:
//$str will be the value you want to verify
function number_validation($str) {
return preg_match("your_regex", $str) ? true: false;
}