Hi,
I have the scenario as:
Given:
Two entities "ITEM" and a related entity "SUB-Item" relationship 1:N.
On ITEM entity form I have given users a related sub-grid so they are able to add as many SUB-item as are applicable.
I also have an option set field "X" displayed on entity ITEM
X= High, Low, Medium, None etc which users can select value and save.
Required:
1) When there is no SUB-Item, set X = None
2) Each time when a SUB-item is created users should be prompted to review the value in X and set it accordingly, they could also delete the SUB-item and again because it is a change in the number of SUB-item they should be warned to re-evaluate the value in field X
3) As per the 1) requirement above when there is no SUB-item X is set to None, hence when user changes the value of X from None to any other value of X, they should get a warning that without adding a SUB-item they cannot change the value..
Thanks,
PS
Hi,
Thank you for your query.
There are multiple approaches to design this logic and all of it requires write some code.
Furthermore, you cannot use roll-up field (for the count) because you need real-time validations.
I would recommend following:
Another approach is to use JavaScript totally to get the count using WebApi and set X value appropriately. The benefit of this approach is that you do not need to refresh the form on subgrid changes, and you will have all the values in real-time. However, Javascript won't trigger when a Sub item is added or deleted by a Process, Plugin or API.
Here are few links for your reference:
Obtaining count of child records using WebAPI:
Creating a custom code activity:
Refresh form based on sub-grid:
Evaluate your options, and feel free to discuss further.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156