Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RuleContext and ValuesManager

    Hello, if I have a series of DynamicForm components managed by a ValuesManager, and I want to apply the same *When condition to each form, there is no reference to the ValuesManager in the RuleContext of each DynamicForm. Would it be possible to add it?

    Otherwise, I see that it's possible to use {fieldName: "dataSourceName.fieldName", operator: ... }, but this requires the fieldName to be present in every single DynamicForm. Is it the recommended approach indeed?

    #2
    If you use the DataSource-based reference to the field value, by the ruleContext priority rules, your VM’s values should be the values in question.

    Does that work? That would generally be better as it allows you to write the rule generically, without scoping to any particular active means of editing (form, VM, or even grid).

    Comment


      #3
      Hello, in the ruleContext of a form managed by a ValuesManager, the DataSource contains only the values declared in the form. This means it works only if the referenced field is also declared in the form (even if hidden). Do you mean that it should have access to all field values available in the VM?

      Comment


        #4
        We mean that if you refer to the ruleScope value by the DataSource ID (for example dsID.fieldName) then by the precedence order of ruleScope, you should find that those values are the current values for the overall VM, regardless of what fields are declared in which member forms.

        Comment


          #5
          Ok, please try this test case in the showcase (latest 13.1):

          Code:
          isc.ValuesManager.create({
              ID: "vm",
              dataSource: "worldDS"
          })
          
          isc.DynamicForm.create({
              ID: "form",
              width: "100%",
              height: 100,
              valuesManager: "vm",
              items: [
                  {name: "countryCode"}, {name: "countryName"}
              ]
          })
          
          vm.fetchData()
          you may see that form.getRuleContext().worldDS is:

          Code:
          {countryCode: 'BD', countryName: 'Bermuda'}
          while vm.getValues() contains:

          Code:
          {
              "continent":"North America",
              "area":50,
              "capital":"Hamilton",
              "gdp":1700,
              "government":"dependent territory of the UK",
              "countryCode":"BD",
              "member_g8":false,
              "pk":1,
              "countryName":"Bermuda",
              "population":62099
          }
          Last edited by claudiobosticco; 6 Feb 2025, 14:42.

          Comment


            #6
            You have definitely found a hole here - ValuesManagers should work like forms, and contribute the full set of values under the dataSourceId, but they don't right now.

            We're going to adjust this and clarify the docs.

            In the meantime, you might manually publish data to the ruleContext under another prefix, or just temporarily use event handlers instead of declarative *When rules for this particular area of your app.

            Comment

            Working...
            X