Control fields not triggered

Hello,

We struggle with a field that is not triggered anymore when it should be. We have checked our modeling and compared with other control fields but cannot find where the issue stands.

Here’s the context:
The purpose is to show the IDNo field when CountryEmploy is “CZ”, NationalCitizen is false and EUCitizen is true. The data comes from another application (external <PROJECT_NAME> to internal <PROJECT_NAME>).

But when we load the form in internal <PROJECT_NAME>, we can see that IDNo field is not displayed.

Here’s the redux state of the document when it’s loaded:
ReduxState.txt (15.7 KB)

In the SME, we use UIDependency fields so in a Computation Rule we set one field IDNoHideHelpField and one computation field IDNoHideHelpCalc like this:

{
  "type": "Field",
  "id": "field_e8688",
  "name": "IDNoHideHelpField",
  "internalDescription": [
    {
      "locale": "en",
      "text": "Help field to hide the IDNo by country, VN if National Citizen false and CZ if EUCitizen = / NationalCitizen True, PRT if EUCitizen = false"
    }
  ],
  "Field": {
    "fieldType": {
      "type": "ConfirmType"
    }
  }
},
{
  "type": "Computation",
  "id": "computation_08ae0",
  "name": "IDNoHideHelpCalc",
  "internalDescription": [
    {
      "locale": "en",
      "text": "Help Calc to show and hide the IDNo VN if National Citizen false and CZ if EUCitizen = false / NationalCitizen True, PRT if EUCitizen = false"
    }
  ],
  "Computation": {
    "computedFieldId": "field_e8688",
    "computationAlternatives": [
      {
        "operation": "True",
        "precondition": "(FieldValueIncludedInValueList(../../../Contract/CountryEmploy, \"AUT\", \"FR\", \"GER\"))\r\nOR\r\n(FieldValueIncludedInValueList(../../../Contract/CountryEmploy, \"VN\") AND [../../../PersonalData/NationalCitizen] == False)\r\nOR\r\n(FieldValueIncludedInValueList(../../../Contract/CountryEmploy, \"CZ\") AND \r\n(([../../../PersonalData/EUCitizen] == False)\r\nOR\r\n([../../../PersonalData/NationalCitizen] == True)))\r\nOR\r\n(FieldValueIncludedInValueList(../../../Contract/CountryEmploy, \"PRT\") AND [../../../PersonalData/EUCitizen] == False)"
      }
    ],
    "errorMessage": [
      {
        "locale": "en",
        "text": "error text for computation of IDNoHideHelpCalc"
      },
      {
        "locale": "de",
        "text": "error text for computation of IDNoHideHelpCalc"
      }
    ]
  }
}

Prettier view of the computation:

In the Form Model, in data configuration we have a dependency on IDNo:

In the SME preview, the trigger works well

But in the actual client UI:

I would have liked to debug internal A12 code at the moment the computation runs so that I know what is wrong, maybe you can lead me for that?
Or if you have any idea, don’t hesitate to ask for more information (full json for models, call for demonstration…)

Thank you in advance

You could temporarily add your helper field “IDNoHideHelpField” to your form in order to directly see the result of the computation.
Then you can play around with the controls and check whether you get the intended result.

NationalCitizien and EUCitizen seem to be Boolean fields. Boolean fields can be empty, false and true.
Your preconditions only compare with true or false. You might want to take the empty case into account by using FieldFilled or FieldNotFilled.

Which A12 version are you using?

Thank you for your answer,
I tried everything you suggested, adding the “IDNoHideHelpField” in the form, logging in the values as follows (boolean “Hide” has the exact same conditions as in the “IDNoHideHelpCalc”:

const country = candidateProcessDocumentData.document.Candidate.Contract.CountryEmploy;
const nationalCitizen = candidateProcessDocumentData.document.Candidate.PersonalData.NationalCitizen;
const euCitizen = candidateProcessDocumentData.document.Candidate.PersonalData.EUCitizen;
console.log(`Country:${country}`);
console.log(`NationalCitizen:${nationalCitizen}`);
console.log(`EUCitizen:${euCitizen}`);
const hide =
	["AUT", "FR", "GER"].includes(country) ||
	(country === "VN" && nationalCitizen === false) ||
	(country === "CZ" && (euCitizen !== true || nationalCitizen === true)) ||
	(country === "PRT" && euCitizen === false);
console.log(`Hide:${hide}`);

image
I also tried to change the calc by using FieldNotFilled and FieldFilled but that didn’t change anything.

You noticed that at this step our form is readonly, later we can change the values, but I changed the code so that I could change it directly when we receive data from External <PROJECT_NAME>.
So when loaded, the state of the document is this one:

{
  document: {
    Candidate: {
      PersonalData: {
        Disable: false,
        NationalCitizen: false,
        EUCitizen: true,
        DisableConsort: false,
        NationalityCalc: 'Czech',
        GenderCalc: 'male',
        FirstName: 'CZ',
        LastName: 'Test',
        EmailPrivate: 'a@a.cz',
        PhonePrivate: 'test',
        Title: 'Mr',
        Nationality: 'Vienameses',
        BirthPlace: 'test',
        Birthdate: new Date(497145600000),
        AddressPermanent: {
          AddContactAddress: false,
          Country: 'Test',
          PostalCode: 'test',
          City: 'test',
          Street: 'test',
          HouseNo: 'test'
        },
        InsureTax: {
          SocialSecurityNoExist: true,
          SocialSecurityNo: 'test',
          Insurance: {
            PensionInsur: false,
            CompPension: false,
            CompPensionConsult: false,
            HealthInsurInGER: true,
            AdditionalHealthInsurPRT: false
          },
          MultiEmployment: {
            MultiEmploy: false
          },
          Tax: {
            TaxAlleinverdiener: false,
            TaxFamily: false,
            TaxPendler: false
          }
        },
        DependentInfo: {
          Dependent: false
        },
        Permits: {
          WorkPermit: false
        },
        StudentsInterns: {
          NonEUEmployCalendarYear: false,
          NonEUDaysConfirm: false,
          SemesterLeaveTrueFalse: false,
          IsStudent: false
        },
        IdentificationInfo: {
          PassportCountry: null,
          IDNo: 'test'
        },
        Education: {
          SchoolEnd: new Date(946684800000),
          HighestQuali: 'NonVoc',
          HighestSchoolCZ: 'Test',
          HighestQualiOther: null,
          SchoolName: 'test'
        },
        Bank: {
          AccountNo: 'test',
          BankCode: 'test'
        },
        AddressContact: {
          PostalCode: null,
          City: null,
          CountryContact: null,
          HouseNo: null,
          Street: null
        }
      },
      Contract: {
        ContractSignPlace: 'Prague',
        ProbationDurationMonths: 3,
        CountryEmploy: 'CZ',
        Group: 'mgm tp',
        FirstDayDate: null,
        CompanyCalc: 'mgm technology partners s.r.o.',
        EntryDate: new Date(1724544000000),
        ContractSignDate: new Date(1714348800000),
        ContractType: 'employee',
        InternTypeDetails: null,
        ContractUnLimited: 'indefinite',
        ExitDate: null,
        Compensation: {
          SalaryProbation: false,
          CurrencyCalc: 'Kč',
          SalaryHourly: null,
          SalaryHourlyLettersLocal: null,
          SalaryHourlyLettersEn: null,
          SalaryHourlyDecimalPartLettersLocal: null,
          SalaryHourlyDecimalPartLettersEn: null,
          SalaryMonthlyAfterProb: null,
          SalaryMonthlyAfterProbLettersLocal: null,
          SalaryMonthlyAfterProbLettersEn: null,
          SalaryMonthlyAfterProbDecimalPartLettersLocal: null,
          SalaryMonthlyAfterProbDecimalPartLettersEn: null,
          SalaryMonthlyParttimeAfterProb: null,
          SalaryMonthlyParttimeAfterProbLettersLocal: null,
          SalaryMonthlyParttimeAfterProbDecimalPartLettersLocal: null,
          SalaryMonthlyParttimeAfterProbLettersEn: null,
          SalaryMonthlyParttimeAfterProbDecimalPartLettersEn: null,
          SalaryMonthlyParttime: null,
          SalaryMonthlyParttimeLettersLocal: null,
          SalaryMonthlyParttimeLettersEn: null,
          SalaryYearlyAfterProb: null,
          SalaryYearlyAfterProbLettersLocal: null,
          SalaryYearlyAfterProbLettersEn: null,
          SalaryYearlyAfterProbDecimalPartLettersLocal: null,
          SalaryYearlyAfterProbDecimalPartLettersEn: null,
          SalaryYearlyParttimeAfterProb: null,
          SalaryYearlyParttimeAfterProbLettersLocal: null,
          SalaryYearlyParttimeAfterProbDecimalPartLettersLocal: null,
          SalaryYearlyParttimeAfterProbLettersEn: null,
          SalaryYearlyParttimeAfterProbDecimalPartLettersEn: null,
          SalaryMonthly: 666,
          SalaryMonthlyLettersLocal: 'šest set šedesát šest celých nula nula',
          SalaryMonthlyLettersEn: 'six hundred and sixty-six point zero zero',
          SalaryMonthlyDecimalPartLettersLocal: null,
          SalaryMonthlyDecimalPartLettersEn: null,
          SalaryMonthlyParttimeDecimalPartLettersLocal: null,
          SalaryMonthlyParttimeDecimalPartLettersEn: null,
          SalaryMonthlyCalcLettersLocal: null,
          SalaryMonthlyCalcLettersEn: null
        },
        HoursAbsences: {
          VacationParttime: null,
          VacationParttimeHours: null,
          WeekHoursHHMM: null,
          VacationFulltime: 20,
          FullPartTime: 'Full',
          WeekHours: null
        },
        Organisational: {
          JobDescriptionCalc: 'not applicable',
          Subsidiary: 'prg',
          JobTitleContract: 'ITSpec'
        }
      },
      Hire: {
        JobTicket: false,
        OSChoice: 'win',
        OSExp: null,
        KeyboardChoice: 'en'
      },
      MetaData: {
        IsPublished: true,
        Ext<PROJECT_NAME>UserId: '9ca118b2-47cc-4be9-9873-d919e987cb7d',
        EmployeeUUID: '9df861c9-f69b-4ecb-9cbd-c159bd711c2b',
        Process: {
          Status: 'OnboardFormSent',
          CreationDate: new Date(1718091440000),
          DeclineReason: null,
          ReviewType: 'NO_PEER_REVIEW',
          OfferSentOnDate: new Date(1718064000000),
          OfferSentDueDate: new Date(1719273600000),
          Ext<PROJECT_NAME>ProcessStatus: 'ONBOARDING_FORM_SUBMITTED',
          LatestOfferSentOnDate: new Date(1718064000000),
          Assignees: {
            ResponsibleHrId: 'timUsr-dvadmin',
            ResponsibleHrName: '<PROJECT_NAME> Admin',
            ResponsibleHrEmail: '<PROJECT_NAME>+admin@<INTERNAL_LINK>',
            ResponsibleHrPhone: null,
            DefaultTaskAssigneeId: 'timUsr-dvadmin',
            DefaultTaskAssigneeName: '<PROJECT_NAME> Admin',
            TaskAssigneeId: 'timUsr-dvadmin',
            TaskAssigneeName: '<PROJECT_NAME> Admin',
            PeerReviewerName: null
          },
          Comment: {
            HasNewComment: false
          },
          Decisions: {
            NeedsReedit: false,
            NeedsArchive: false,
            ReviewResult: null,
            OfferLetterReviewResult: null,
            OfferLetterDecision: 'Accepted',
            OfferDecision: null,
            StatusHistories: [
              {
                Status: 'ContractDraft',
                Index: 1
              },
              {
                Status: 'OfferLetterNoReview',
                Index: 1
              },
              {
                Status: 'OfferLetterSent',
                Index: 1
              },
              {
                Status: 'OnboardFormSent',
                Index: 1
              }
            ]
          }
        },
        Workflow: {
          Task: {
            DueDate: new Date(1719280800000)
          }
        },
        UIDependency: {
          MultiEmployOtherHideHelpField: true,
          VacationParttimeHideHelpField: true,
          WeekHoursHHMMHideHelpField: true,
          PassportHideHelpField: false,
          HourlySalaryHideHelpField: true,
          DistributionHoursHideHelpField: true,
          MonthlySalaryAfterPropHideHelpField: null,
          MultiEmployTableHideHelpField: true,
          StudentDetailsHideHelpField: true,
          SocialSecurityNoExistHideHelpField: false,
          MonthlySalaryParttimeHideHelpField: null,
          YearlySalaryAfterPropHideHelpField: true,
          MonthlySalaryHideHelpField: false,
          WorkPermitShowHelpField: false,
          HiringForm: {
            IDNoHideHelpField: true,
            DeclinedByShowHelpField: 'hide',
            DeclineReasonShowHelpField: 'hide',
            OfferLetterDecisionShowHelpField: false,
            OfferDecisionShowHelpField: false,
            DateFromBirthdateHelpField: 3,
            YearFromBirthdateHelpField: 1985,
            MonthFromBirthdateHelpField: 10
          },
          OnboardingForm: {
            OnboardFormSentDecisionShowHelpField: true
          }
        }
      },
      OfferContractFiles: {
        OfferContractsGenerated: [
          {
            ContractTemplate: 'CZ-TP-Employee-Fulltime-Indefinite-2024-02',
            CreationDate: new Date(1718091686000),
            ContractAmendment: null,
            PersonSignature: 'Person_1',
            OfferContractFile: {
              content: null,
              attachment_id: '29159fad-59d7-464b-9b89-5a8213084661',
              internal_filename: '2024-06-11_CZ_Test_offer_mgm_V1.pdf',
              original_filename: '2024-06-11_CZ_Test_offer_mgm_V1.pdf',
              size: 872267,
              mime_type: 'application/pdf'
            }
          }
        ],
        OfferContractsSent: [
          {
            OfferContractSyncStatus: 'SENT',
            BatchNumber: 1,
            FileType: 'MainContract',
            SentOnDate: new Date(1718098602000),
            DueOnDate: new Date(1719308202000),
            CreationDate: new Date(1718091856000),
            OfferContractFile: {
              content: null,
              attachment_id: 'c0184b12-a27a-4236-bca9-13a5441d364d',
              internal_filename: 'test.pdf',
              original_filename: 'test.pdf',
              size: 183937,
              mime_type: 'application/pdf'
            }
          }
        ]
      }
    },
    a12wf: {
      workflowsInternalDocumentStatus: 'NON_EMPTY',
      processDefinition: {
        key: 'Process_Onboarding',
        name: 'OnboardingProcess'
      },
      process: {
        id: '039b4585-27c6-11ef-8136-703217c31384',
        businessKey: 'CandidateBusiness',
        initiator: 'timUsr-dvadmin'
      },
      taskDefinition: {
        key: 'Task_UpdateOnboardFormSentFeedback',
        name: 'Update Onboard Form Feedback',
        formKey: 'Task_UpdateOnboardFormSentFeedback'
      },
      task: {
        id: '76bcff1b-27c6-11ef-8136-703217c31384',
        creationDate: new Date(1718091882000),
        dueDate: null,
        assignee: null
      }
    },
    id: 'CandidateDMProcess/2',
    modelId: 'CandidateDMProcess'
  }
}

You can see that NatoinalCitizen is false, EUCitizen is true, CountryEmploy is CZ and IDNoHideHelpField is true when hide is false in the code.

When I unselected EUCitizen and then selected it back, I had these diffs:
EUCitizen to false:

EUCitizen to true:


And now my IDNo field is displayed.

I really don’t understand what’s wrong here.

Hi @alexis-raw-iron,
Thanks for the extra information.

I’ve re-modeled your use-case and I don’t see anything wrong with the models. The problem appears to be your data, more specifically if your data has been recomputed.

The data that you posted showed

{
  document: {
    Candidate: {
      PersonalData: {
        ..
        NationalCitizen: false,
        EUCitizen: true,
        ...
        }
      },
      Contract: {
        ...
        CountryEmploy: 'CZ',
        ... 
        }
      },
      ...
      MetaData: {
        ...,
        UIDependency: {
          ...,
          HiringForm: {
            IDNoHideHelpField: true,
            ...
          },
          ...
          }
        }
      }
...

This means that when you load the data into the form, the value for “IDNoHideHelpField” is true and the “IDNo” field is hidden.

If you recalculate the data, like you did in the console log, then you can see that the value for “IDNoHideHelpField” should be null. Interacting with the form and changing a Field Value triggers a recalculation of the Computation Rules and this is how you got to the correct state.

With pre-existing data or data from an external database, you need to trigger a recalculation of the document in the backend. A developer should be able to do this for you. Alternatively, you can open the data yourself, change a field value like you did in the post above and then resave the document. When you open the form, the dependency should now work as expected as the value for “IDNoHideHelpField” should now match the data.

I moved the discussion on recalculating in the backend to a new thread.

Hi @alexis-raw-iron,
After chatting with @jan-static-daemon we see that there are two solutions to your issue. I’m presenting the modeling solution here. @jan-static-daemon will post the developer solution on How do I recompute an existing document in the backend?

As I already mentioned, the problem is that your computed field is pre-filled with the wrong value. With a computed Confirm Field, we only have the option to define the condition, when this field is set to true. This is normally sufficient as the Field starts off as empty (and the Form Engine works it’s magic when a user enters data).

In your case, strictly defining the negative case would be beneficial. With a Boolean, we can define the preconditions for the true and false values. This is stricter and will mean that both true and false are recomputed in the front and backends. If you leave the precondition for true as you have it and then model the following the Calculation of false for a Boolean field, you should enforce a recalculation.
Precondition:

FieldValueNotIncludedInValueList(../CountryOfEmployment, "AUT", "FR", "GER")
And ((FieldValueIncludedInValueList(../CountryOfEmployment, "VN")
        And [../NationalCitizen] != False)
    Or (FieldValueIncludedInValueList(../CountryOfEmployment, "CZ")
        And ([../EUCitizen] != False
            Or [../NationalCitizen] != True))
    Or (FieldValueIncludedInValueList(../CountryOfEmployment, "PRT")
        And [../EUCitizen] != False))

Calculation:

False

Please remember:

  1. This solution is more complicated as your requirement is more complicated than normal. This is only required if your Computed Trigger Field is pre-filled in the backend
  2. Take care with the preconditions for the true and false values. They must be mutually exclusive!
  3. There is an alternate solution to clear the field in the backend (see linked post)

Hello Malcolm and thank you for this solution,

I’d like to try it but in the SME, I’ve got an error when trying to add this computation with “False” in calculation:

It is only allowed to compare equality of a field of type confirm with another field of type confirm or to compare equality or unequality with the constant True. [MVK_INVALID_COMPARE_TO_YES]

You just need to change the Field Type of your computed Field to Boolean.

Thank you it worked.