Validate data with Smart rules

Smart rules are conditions that generate warning or error messages to users. They are set to respond to three types of user input: Add, Set, or Delete. When a user performs one of these actions and it does not meet your defined condition, a warning or error message is received. Smart rules only generate warning and error messages, so the audit trail does not capture triggered Smart rule information.

Smart rules are the key to building compliance into your business processes. Using Smart rules, you can ensure that the business practices you want are enforced within your organization.

To view the Smart rules list, go to Customization Services or Platform Services > Object customizations > Smart rules. From the Smart rules list you can edit an existing Smart rule or add a new one.

If a Smart rule was added as part of a package, it has a package name, and you can only view the Smart rule. To change a Smart rule that's part of a package, contact the package creator.

Add or edit a Smart rule

The Smart rules wizard walks you through the process of designing your Smart rule.

  1. Choose an object to extend
  2. Select rule properties
  3. Save (deploy) the rule
The Accounts Receivable payment field Payment group {!(ARPAYMENT.PRBATCH)!} does not currently support Smart rule customizations.

1. Choose an object to extend

Smart rules are applied to an object. The Owner Object dropdown menu gives you a list of objects to which you can add a Smart rule.

  1. Select Owner object and select the object to which you want to add a Smart rule.

    If you select Order Entry transaction detail, Inventory Control transaction detail, or Purchase Order transaction detail for your Object, a second selector field for Document type appears. The document type represents the transaction definitions to which the customization is added. You can configure a customization to apply to multiple transaction definitions at once.

  2. Select Next.

2. Select rule properties

The Smart rule Properties define when and how a response is sent back to the user. The different properties are as follows:

  • Type: The type of response to the user, either Error or Warning.

    • An Error message requires the user to go back and change something before they can proceed. An Error message could be used to require field input.
    • A Warning points out the rule violation but allows the user to continue with the operation. The warning could remind users to make sure that an external document is in place, such as a work order, for the created record.

      Creating a Smart rule for Project invoices?

      Set the rule type to Error, rather than Warning. Warnings currently do not apply to invoices generated from the Projects application.

  • Events (required): Events cover the three things that a user can do with a record:

    • Add: The rule is checked any time a new record is created.
    • Set: The rule is checked any time a record is changed.
    • Delete: The rule is checked any time a record is deleted.

      Warnings are not supported for Delete

      Warnings are not currently supported for Delete events. Warnings are converted to errors instead.

  • You can choose any or all of these options.

  • Condition (required): The rule that is to be met so that an error or warning message is NOT sent.

    Because blank conditions always evaluate as true, leaving a Smart rule condition blank would never generate a warning or error message.

    For instance, if the rule is that customers with addresses outside the United States require prepayment of invoices, the condition would be written to state that the Bill-to Contact Country is equal to United States or the Invoice Amount Due equals zero. The condition would extend the Invoice and be written:

    Copy
    ({!ARINVOICE.BILLTO.CONTACT.MAILADDRESS.MAILADDRESS.COUNTRY!} 
    == "United States") || 
    ({!ARINVOICE.TOTALDUE!} == "0")

    If this condition, either country equals United States or total due equals zero, is not met, a warning or error will be displayed.

    If you want to bring up a warning message every time an Add or Set Event occurs, set the condition to evaluate a required field for the owner object as blank. You can find out if a field is required by looking it up in the Catalog. If the Required column for the item is set to true, the item is required.

    For instance, if you wanted a warning message to appear any time an AP purchase invoice was added, you could write the condition:

    {!APBILL.WHENCREATED!}==''

    Because an AP purchase invoice always has a Date, this condition will always evaluate as false and trigger a warning.

    For more information on writing conditions, see Write conditions.

  • Error message (required): The text message that is displayed when this rule is violated. The Error Message may contain Injections (see Injections).
  • You can use Field lookup to insert injections from Intacct instead of adding them manually.

3. Deploy your rule

In the Deployment Options step, you name your Smart rule and describe what it does. The options for deploying your Smart rule are:

  • Smart rule ID (required): This is the name that will be used to find and edit your Smart rule. Characters for the ID are limited to alpha-numeric and underscore with no spaces.
  • Description: Add a description that will help the user understand the purpose of this Smart rule and how you intend it to be used.
  • Status: The status of the Smart rule is Active by default. You can change it by choosing Inactive from the dropdown menu.

Smart rule examples

Aside from the following fictional case, you can find several Smart rule examples in Sage Intacct Developer portal (Legacy XML API).

A controller at a construction company wants to limit the size of transactions certain employees can enter. To do this, he sets up a currency type custom field, USER_BILL_LIMIT, on the user record so he can set the transaction amount per user. He then sets up a rule that compares the current transaction amount with the limit on the user record. This rule is created as follows:

  1. On the "Select Owner Object" step, set the properties to:

    • Owner object: AP bill
  2. Select Next.
  3. On the "Select Rule Properties" step, set the properties to:

    • Type: Error
    • Events: Add and Set
    • Error message: {!CURRENTUSER.LOGINID!} may not enter AP purchase invoices for an amount greater than {!CURRENTUSER.USER_BILL_LIMIT!}. This AP purchase invoice total is {!APBILL.TOTALENTERED!}
    • Condition: {!CURRENTUSER.USER_BILL_LIMIT!} == '' || {!APBILL.TOTALENTERED!} <= {!CURRENTUSER.USER_BILL_LIMIT!}
  4. Select Next.
  5. On the "Select Deployment Options" step, set the properties to:

    • Smart link ID: VALIDATE_BILL_LIMIT
    • Description: Rule that displays a warning when the user tries to enter an AP purchase invoice that exceeds their transaction limit.
    • Status: Active.
  6. Select Save.

Format dates in a Smart rule

Use this format: 'YYYY.MM.DD'

For example, if you use a merge field to verify that a General Ledger entry is made on or after December 25, 2022, it would look something like this: {!GLENTRY.ENTRY_DATE!}>='2022.12.25'

Copy a Smart rule to a different company

You can copy a Smart rule from one company to another using a custom package file. Export the definition of the Smart rule, include the exported definition in a package file, then import that package file in the target company.

Export the definition of a Smart rule:

  1. Depending on your subscriptions, do one of the following:

    • Go to Customization Services > All >Object customizations > Smart rules.

    • Go to Platform Services > All >Object customization > Smart rules.

  2. On the Smart rules list, select Edit next to the Smart rule you want to export.
  3. In the Choose object to extend step, select Export def.

    The definition is exported to an XML file.

Prepare the package file:

Next, change the package to make it ready to import to the second company.

  1. Open a text editor and paste the following XML wrapper text into a new file:

    Copy
    <?xml version='1.0' encoding='UTF-8'?>
    <customErpPackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <packageDescription>
    <name>INSERT NAME HERE</name>
    <description>INSERT DESCRIPTION HERE</description>
    <author>AUTHOR NAME</author>
    </packageDescription>
    <smartLinks>
    <!-- Paste exported definition here -->
    </smartLinks>
    </customErpPackage>
  2. Open the exported XML file in a different window and copy its contents.
  3. Paste the copied code into the XML Wrapper, overwriting <!-- Paste exported definition here -->.
  4. Replace the following with your own information:

    INSERT NAME HERE

    INSERT DESCRIPTION HERE

    AUTHOR NAME

  5. Save the file with a new name, for example, item-to-import.xml.

    The new file looks similar to this example:

Import the package file:

  1. Log in to the target company.
  2. Depending on your subscriptions, do one of the following:

    • Go to Customization Services > + Custom packages.
    • Go to Platform Services > + Packages.
  3. Select the Choose file button, go to your package file, and select Open.

    The file now appears in the Packages page.