Creatio has a great mobile app that lets you work with your data on-the-go. In some situations, you may want specific business logic implemented on the Creatio mobile app. Validation rules enforce that logic.
For example, you may need to make certain fields required to ensure proper data collection for reporting purposes. We can take advantage of some pre-built Creatio libraries so our business rules can translate to proper validation processes in the mobile app.
For this example, we can customize the Activity page to implement a couple of business requirements:
- An Activity should always have a contact associated with it so that we know who the is the person related to the activity. We’ll need to make the Contact column required.
- A sales rep will typically set up an Activity for a Case or an Opportunity. So, we need either one to be specified in addition to the Contact field requirement mentioned above. This way, the CRM records the person as well as whether the Activity was related to a service request, Case, or a sales-related Opportunity.
Implementing these changes requires first setting up a module that contains the needed validation configurations and then attaching it to the MobileApplicationManifestDefaultWorkplace module so it gets integrated into the mobile app codebase.
Normally, the system will automatically set up the MobileApplicationManifestDefaultWorkplace if you’ve previously made any changes to your mobile client. If you haven’t made changes yet, feel free to use the Mobile Application Wizard to make a small change, and then undo it. When the save operation is performed, all the basic modules needed to record mobile customizations will get created in the system.
Once this step is done, use the Advanced Settings area to view the files created. It will show the necessary mobile configuration modules that have been created.
The next step is to create a new module that contains the validation components for the two described requirements. To do this use the Add+Module menu item.
Setup the module with an appropriate name like UsrMobileValidation.
Once this is done, the module code needs to be set up. The code contains two validation sections that are configured using the built-in Creatio addBusinessRule method.
In both cases, the “ruletype” specified will be “Terrasoft.RuleTypes.Requirement” indicating that this is a validation rule that enforces the requirement of data.
The “requireType” value, however, has two different values.
- Terrasoft.RequirementTypes.Simple indicates that we just need one specific field to be required.
- Terrasoft.RequirementTypes.OneOf indicates that one of a set of fields is required. When implementing this, notice how the “columnNames” parameter indicates the set of fields that we are scanning to make sure at least one of them has a value. In our example, the columnNames say [“Case”, “Opportunity”] which means that either one has to have a value when filling out the Activity screen in the mobile client.
Here is the code that you can copy and modify as needed:
After the above code update is finished and saved, the final step is to tell the mobile platform that this new module needs to be incorporated into the mobile platform along with all the standard features. This is done by editing the MobileApplicationManifestDefaultWorkplace module and adding a reference to “UsrMobileValidation” in the “CustomSchemas” area.
For reference, here is the full codebase of the MobileApplicationManifestDefaultWorkplace:
Once this is done, publish your changes and the Activity screen should now show a set of new fields as being required. The Contact field only has a message “Required field”, but for the Case and Opportunity fields, the system will automatically indicate that “One of the fields has to be filled in”.