Configure Business Rules for Jobs

You can create default and validation rules in these Jobs pages:

  • Create Jobs
  • Duplicate Jobs
  • Update Jobs
  • Correct Jobs

Here are the default and validation rules you can create in these pages:

  • Default a value for an attribute
  • Job Name validation
  • Job Code validation

Examples

Example 1: Default Full time or Part time field with value as Part time

To default the Full time or Part time field with the value as Part time:

  1. Navigate to the Redwood job page.
  2. Select the Edit Page in Visual Builder Studio task in the Settings and Actions menu.
  3. Select your project or create a new one. Ensure that you are in Express mode.
  4. Click the Configure Fields and Regions button in Business Rules.
  5. Under Extension Rules, click the + icon to create a business rule.
  6. In the Create Business Rule window, enter the rule details and click Create.
  7. In the Regions and Fields section, navigate to the Basic details region.
  8. Select the FullPartTime field and enter Part time in the Value column.
  9. Preview and publish your changes.

Example 2: Prevent special characters in job name

Advanced Expression

/* eslint-disable dot-notation */
define([], () => {
'use strict';


/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $objectContext, $fields, $modules, $user, $value } = context;
let regex = /^[A-Za-z0-9\s\_]+$/;

if ($fields['jobsV2']['JobName'].$value() && !regex.test($fields['jobsV2']['JobName'].$value())) {
return true;
}

return false;
}

return { runCondition };
});

Example 3: Validate that Job code contains 6 characters with no special characters

Advanced Expression

/* eslint-disable dot-notation */
define([], () => {
'use strict';


/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $objectContext, $fields, $modules, $user, $value } = context;
let jobCode = $fields['jobsV2']['JobCode'].$value();

if (jobCode && jobCode !== null && ($fields['jobsV2']['JobId'].$value() === null || $fields['jobsV2']['JobId'].$value() === undefined)) {
let regex = /^[a-z]{3}[\d]{3}$/i;
if(jobCode.length !== 6 || !(regex.test(jobCode))){
return true;
}
}

return false;
}

return { runCondition };
});