Associate Products and Containers in an Assortment Line Relationship

As an administrator, you can associate product and container with each other in assortment line relationship. They must belong to same assortment. Create triggers to ensure that product and container from different assortments can't be associated with each other.

To create triggers to ensure that products and containers from different assortments aren't associated with each other in an assortment line relationship:

  1. Ensure that you're in an active sandbox.

  2. Go to the Application Composer.

  3. Select Common from the Application list.

  4. Expand Custom Object > Assortment Line Relationship

  5. Click Server Scripts.

  6. Navigate to the Triggers tab and click Action > Add to create the new trigger.

  7. On the Create Object Trigger page, specify the following two triggers:

    • Trigger: Before Insert in Database

      Trigger Name: ValidateAssortmentLineRelationship_BeforeInsert

      In Trigger Definition, paste the following script from this document and click Save and Close:

      def fromAssort = __ORACO__FromAssortmentLine_Obj_c?.__ORACO__ProductAssortment_Id_c
      def toAssort = __ORACO__ToAssortmentLine_Obj_c?.__ORACO__ProductAssortment_Id_c
      if(fromAssort != toAssort)
      {
      throw new oracle.jbo.ValidationException("Product and container should belong to the same assortment")
      }
      
    • Trigger: Before Update in Database

      Trigger Name: ValidateAssortmentLineRelationship_BeforeUpdate

      In Trigger Definition, paste the following script from this document and click Save and Close:

      if(isAttributeChanged('__ORACO__FromAssortmentLine_Id_c') || isAttributeChanged('__ORACO__ToAssortmentLine_Id_c')) {
      
      def fromAssort = __ORACO__FromAssortmentLine_Obj_c?.__ORACO__ProductAssortment_Id_c
      def toAssort = __ORACO__ToAssortmentLine_Obj_c?.__ORACO__ProductAssortment_Id_c
      if(fromAssort != toAssort)
      {
      throw new oracle.jbo.ValidationException("Product and container should belong to the same assortment")
      }
      
      }
  8. Publish the sandbox.

Triggers ensure that a product and a container from different assortments aren't associated with each other in an assortment line relationship.