Skip to Content
Technical Articles

Using Rules and Validations in SAP C4C

 

SAP C4C application has slowly gained richness in the features and functionality it offers. Especially in the Key User Tools (KUT) arena the richness of features is amazing. One such robust tool is the Rule Editor feature which enables us to configure rules and validations.

Rules are written using Ruby script made easy with a set of operators and functions. These rules are of great use while working with visibility of fields, sections, and other user interface components. One of the very useful feature of rules has been described in this blog post: Driving Field default values with Value type rules in SAP C4C

Validations sit on top of rules and gives us the power to make the system alert the user on an incorrect input of data. We could also use validations to add a hard stop instead of just an alert.

 

Validations%20in%20SAP%20C4C

In this blog post, we are going to talk specifically about Validations including what are those, how those are configured and what uses these can be put from a system as well as business perspective. Before we jump into details let’s consider a simple business scenario where certain custom flag must be checked by the user.

Validations in SAP C4C

Let’s now try to understand how this can be achieved.

Step 1 – Let’s head to Adaptation Mode

Click on your name on the top right and click on Start Adaptation

Adaptation%20In%20SAP%20C4C

Adaptation In SAP C4C

Step 2 – Now we need to find the Implementation option (by clicking on Back arrow till we hit implementation)

Rules%20and%20Validations

Rules and Validations

. Then hit Implementation to go to Rules and Validation

 

Step 3 – As I mentioned earlier, Validations sit on top of rules and hence before we create and apply validations, we need a rule in place for our requirement. So, let’s create it first.

Create%20A%20Rule%20in%20SAP%20C4C

Create A Rule in SAP C4C

Let’s click on Add Rule and add script it using operators and functions as shown in the screenshot below. We are using the BOOL function to check if the indicator is marked as Yes or No. Now we want to create a validation if the indicator is marked as NO . Hence we are using NOT. Based on your business requirement, you can play around in the script

 

Sample%20Rule%20in%20SAP%20C4C

Sample Rule in SAP C4C

Save the rule.

Step 4 – Now, we go back to Implementation and head to Add -> Validation

 

Create%20Validation

Create Validation

Here let’s specify a relevant Validation name (continuous text), Description (descriptive text), Severity (Error, Warning, Information) and the message that we want to display on the User Interface.

Sample%20Validation

Sample Validation

 

Severity decides how the system would behave when validation is triggered on user action and is governed by it’s values viz. Error, Warning and Information

Severity%20on%20Validation%20message

Severity on Validation message

 

While Error results in a hard stop for the user, Warning and Information allow the user to proceed with the action with a soft message. For the purpose of this blog post, let’s use a Error (process to set up an warning and information is similar).

Sample%20_validation_in%20_SAP_C4C

Sample _validation_in _SAP_C4C

Once the message is set, we go ahead and select the rule created earlier and hit apply to the validation we just created.

Applying%20Rule%20to%20The%20Validation

Applying Rule to The Validation

This completes the set up for Validation in SAP C4C system. Now let’s look at how it impacts the system behavior and meet the business requirements.

 

We open an opportunity and set the flag as No and see how system reacts. When the flag is set as No, the system gives a warning

Validation_message

Validation_message

 

Now if we set the flag to Yes, there is no warning on competitor information

Validation_not_triggered_due_to_flag_condition

Validation_not_triggered_due_to_flag_condition

 

We can also limit the validation to certain business roles by using MYROLES function. Based on the business requirement and using the functions provided by SAP, we can design these validations

 

I hope this blog post has helped you in understanding how to use the Validations and make use of the functionality to achieve the Business requirement of validating certain fields entry. If you are looking for more information on how to use Rules and Validation , click here to read from SAP HELP 

If you have any questions, please feel free to ask or leave your feedback.

 

4 Comments
You must be Logged on to comment or reply to a post.