Relationship value visibility depends on another selection of a relationship value?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marcel
    Junior Member
    • Jul 2025
    • 23

    #1

    Relationship value visibility depends on another selection of a relationship value?

    Hi all,

    I have 3 Entities:

    1. CContract (Many-to-One relation to CProductLine and CContractType)
    2. CProductLine (One-to-Many relation to CContractType)
    3. CContractType

    I am in the Layout of the CContract Entity and when I am selecting a CProductLine (e.g. Insurances) under CContractType every ContractType that is related to the selected ProductLine should be selectable in the dropdown list. Is that possible? So based on the selected ProductLine the values under ContractType are filtered/visible.

    Click image for larger version

Name:	image.png
Views:	64
Size:	30.6 KB
ID:	119985

    I read something about a select-handlers and created the following.

    /.../client/custom/src/handlers/select-related/contract-type-by-product-line.js

    PHP Code:
    define('custom:handlers/select-related/contract-type-by-product-line', ['handler'], function (Dep) {

        return 
    Dep.extend({

            
    filterData: function () {
                const 
    productLineId this.model.get('productLineId');

                if (!
    productLineId) {
                    return 
    null;
                }

                return [
                    {
                        
    type'equals',
                        
    field'productLineId',
                        
    valueproductLineId
                    
    }
                ];
            }

        });
    });
    ​ 
    But that does not seem to work.

    Thanks!
  • Marcel
    Junior Member
    • Jul 2025
    • 23

    #2
    Hi,

    does anyone has an idea or direction for me?

    Thanks!

    Comment

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1719

      #3
      I guess custom filter will do, look for that

      Comment

      • calvinmatteo
        Junior Member
        • Aug 2025
        • 1

        #4
        Yes, it is possible to filter the dropdown list of CContractType based on the selected CProductLine. This can typically be achieved using a combination of JavaScript (for client-side filtering) and possibly server-side logic (if your data is being loaded dynamically sprunki).

        Comment

        • Marcel
          Junior Member
          • Jul 2025
          • 23

          #5
          And a custom filter would also do it? How am I creating it?

          Thanks!

          Comment

          Working...