Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

How to notify users based on changing value

Posted on by 428

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

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: How to notify users based on changing value

    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:

    • Create a numeric field on Item entity to hold count of Sub-Items. Place it on the form and keep it hidden or locked (if needed).
    • Create a custom code activity (custom workflow step) to get the count of the sub items (out argument should be a numeric value).
    • Create a rea-time workflow to which triggers on Create of Sub-Item, gets the count of all Sub-items (based on the related Item) and updates the count in Item (new field we created).
    • Because, your main form is not aware of count change, you need to refresh the form based on subgrid changes.
    • Add a Business Rule or Javascript on the Item form to prevent user from selecting X = None when count is 0, if it s not zero prompt the user to change the value.

    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:

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/256849/using-odata-in-crm-to-determine-whether-specific-entity-has-children-or-not/719553

    Creating a custom code activity:

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/workflow/tutorial-create-workflow-extension

    Refresh form based on sub-grid:

    https://stackoverflow.com/questions/59929848/reload-form-on-reload-refresh-of-subgrid-in-dynamics-365-crm-unified-interface

    Evaluate your options, and feel free to discuss further.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans