Validation Rules Salesforce - salesforce

I need to make validation rules like this:
Create a validation rule that displays an error message and prevents the user from creating or updating a contact if both conditions are true.
Create a validation rule:
Rule name: Contact_must_be_in_Account_ZIP_Code
Operator: AND (returns true if both conditions are true)
Define two error conditions:
The contact is associated with an account ID
Hint: use the ISBLANK and NOT functions.
The zip code for the contact's address is different than the zip code for account submissions.
Tip: Use the API names (MailingPostalCode and ShippingPostalCode) and the <> operator (Not equal to).
Enter an error message for the validation rule
?
I'm in training and I've tried everything to solve it but nothing worked

Related

how to add validation rule to an email field in jsf page?

ADF Client side validation – Email validation:
I want to add a validation rule to an email field so it doesnt accept invalid emails when entered (but remains not required, so its either empty or valid).
I used a Validate Regular Expression on the Email field in the jsf page with these arguments:
Pattern: ^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)#[A-Za-z0-9]+(\.[A-Za-z0-9]+)(\.[A-Za-z]{2,})$
Message: You have entered an invalid email address. Please try again.
The problems are:
1- When entering an invalid email, it works but when entering a valid email the error message still appears.
2- The email field becomes mandatory even though its not.

Codename One - Validate only one input at a time

A problem of the Validator class is that it validates all the inputs to which a constraint is added (that means that an error message is shown in not already filled inputs or selected pickers):
Validator val = new Validator();
val.addConstraint(title, new LengthConstraint(2));
val.addConstraint(price, new NumericConstraint(true));
In this example, the validator will show an error for both title and price even if the user didn't entered a price yet.
It would be more intuitive that an error is shown only after the user has given the input, that means to show an error for the price only after that a price is given.
I didn't find a code to implement this behavior.
My first thought was just create a validator which will check if something was modified and add it to the validation chain. However, that would mean the input could be valid if you didn't enter everything.
This is a feature that should be implemented in the rendering logic for this class. In Validator itself. You can file an RFE for that or just implement it in a pull request.

Drupal how to add form validate true to a form

I am getting
"An illegal choice has been detected. Please contact the site
administrator."
when I am trying to give term which doesn't exist in select box filter. I added validate true to the form_alter function for the particular its working and returning all data.How to add it dynamically without specifying the field name in the function.
$form['field_industry']['#validated'] = TRUE;
Else Is there any option to add form validate true in views
Thanks in advance
I got this message when trying to select certain Industries in a list. Some Industries worked, some generated the "illegal choice" message. The problem turned out to be that some Industry names had ampersands in them and others didn't. When I changed the ampersands to "and" that fixed it.

Show and hide server-side errors in AngularJS 1.3+ forms

I'm using the Angular framework with Angular Material controls in my recent application. I'm looking for a good solution for the following problem:
A form form with an input field named nickname is shown to the user. After the user has chosen a nickname and submitted the form, the server checks whether the nickname has already been taken. In that case, it returns an error to the Angular client.
To show an appropriate error to the user, the code then calls form.nickname.$setValidity('nicknameTaken', true). The new ngMessages module is used to display the error to the user. Further form.$isInvalid is used to disable the form controls to prevent the user from resubmitting the invalid nickname.
My problem is now the following: I'd like to have the error nicknameTaken automatically being removed as soon as the user begins to edit the form fields again. What is a good way to do this? Is there a predefined route to go when it comes to server-side validation errors of this kind? (Note that I am not asking for asynchronous validation because I only want to contact my server when the form is actually being submitted.)
I would write a normal validator directive instead. Something like
<input blacklist="takenNickNames" .../>
This directive would simply add a validator to the input, and this validator would make the input invalid if the model value is contained inside the given takenNickNames array (and valid if it's not present).
The takenNickNames array would be empty initially. When the form is submitted and the error comes back, the controller would add the invalid nick name to the array.
So, every time the user would enter something, the validator would be triggered, and would set the field valid or not, based on the taken nicknames stored in the array.
Here is a working example.

Using Drupal rules to email users with a role but only once

We have been trying for a while to solve a Drupal Rules problem.
The situation is;
On every cron run we would like to check for Users who have a certain Role.
We will then send an email to those Users.
But we only want this email to go once.
We are thinking therefore that we will create a new custom/hidden User field called 'email sent'. Then the rule will;
EVENT: On every cron run
CONDITION: Check for Users who have the role AND have a null value in that field
ACTIONS: Send an email to the
users AND set the value of the user 'email sent field to 1.
We think this is possible but we can't see how you can set up a rule to do this.
Any help really appreciated
I think that you can resolve your problem via a custom module where create an action rule that set this fields. In situation like yours I follow this method. Search hook_rules_action_info().
Or if you use profile2 module you can see if there is a rule that can be set this value. I think that there is because Profile2 support Rules.
M.

Resources