You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of Epic avniproject/avni-product#1507 and Story #1171, we encountered an issue while evaluating rules for Goonj organisation, for creation of Distribution.
We are linking Activities to a distribution, by doing a search and select of Subject. This is then used within FormElement rule to initialize certain fields. For this purpose, we make use of individualService.getSubjectByUUID() call in the rules.
RuleEvaluationService in webapp has a problem while fetching a different individual using its uuid.
The rule written for client, assumes that individualServiceFacade will always be able to fetch the individual in a synchronous manner, which works fine there as its connected to the realm DB. But on the web-app, we need to fetch the individual from the backendServer asynchronously as a remote call.
This results in 2 Major behaviourial changes:
Within any rule, whenever we need to fetch the Subject, we would need to figure out a way to handle the Promise returned by the async facade service fetch calls on the webapp, while simultaneously working correctly on the client in a synchronous manner.
Provide ability to invoke RuleEvaluationService in an asynchronous manner, to be able to invoke an async call and resolve it.
Acceptance Criteria
We are able to run the same FormElement rule which uses following services methods in both webapp and client.
Needs more Technical evaluation.
Current solutions for each of the above problem:
In this scenario, we could run a string replace query on the rule content to replace all "individualService.getSubjectByUUID(" with "await individualService.getSubjectByUUID(" in webapp at runtime.
Also, we need to make the rule function async by prefixing the keyword "async" only in webapp.
For this, we would prefer to only make the RuleEvaluation related entities data init, update and rule execution to be encapsulated within the FormWizard and run in Asynchronous manner, while rest of the Webapp working as is in a synchronous manner.
Additional Information
The list of impacted Orgs and Elements with rules that need asynchronous api calls is as per below attached file. InstancesOfRuleInDB.txt
The text was updated successfully, but these errors were encountered:
mahalakshme
changed the title
Handle Async fetch of related entities during Rule Evaluation in DEA
[DEA] Handle Async fetch of related entities during Rule Evaluation
Jun 13, 2024
Motivation
As part of Epic avniproject/avni-product#1507 and Story #1171, we encountered an issue while evaluating rules for Goonj organisation, for creation of Distribution.
We are linking Activities to a distribution, by doing a search and select of Subject. This is then used within FormElement rule to initialize certain fields. For this purpose, we make use of individualService.getSubjectByUUID() call in the rules.
RuleEvaluationService in webapp has a problem while fetching a different individual using its uuid.
The rule written for client, assumes that individualServiceFacade will always be able to fetch the individual in a synchronous manner, which works fine there as its connected to the realm DB. But on the web-app, we need to fetch the individual from the backendServer asynchronously as a remote call.
This results in 2 Major behaviourial changes:
Acceptance Criteria
We are able to run the same FormElement rule which uses following services methods in both webapp and client.
Service Methods
individualService.getSubjectByUUID
individualService.getSubjectsInLocation
addressLevelService.findAddressLevelByUUID
Tech Approach
Needs more Technical evaluation.
Current solutions for each of the above problem:
In this scenario, we could run a string replace query on the rule content to replace all "individualService.getSubjectByUUID(" with "await individualService.getSubjectByUUID(" in webapp at runtime.
Also, we need to make the rule function async by prefixing the keyword "async" only in webapp.
For this, we would prefer to only make the RuleEvaluation related entities data init, update and rule execution to be encapsulated within the FormWizard and run in Asynchronous manner, while rest of the Webapp working as is in a synchronous manner.
Additional Information
The list of impacted Orgs and Elements with rules that need asynchronous api calls is as per below attached file.
InstancesOfRuleInDB.txt
The text was updated successfully, but these errors were encountered: