web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Can I create child-parent (N:1) business rules?

(0) ShareShare
ReportReport
Posted on by 10

Hi, I'm going to explain this as best I can because I'm relatively new to this! I don't think what I want to do is possible (not without coding anyway), but I just wanted to double check.

On our CRM, we have a custom entity called Project Support Package (PSP), and the Account entity has a 1:N relationship with it (so multiple PSPs can be hooked up to one Account). We are wanting to prevent our colleagues from accidentally creating other PSPs related to an account, for example, that we have had issues with in the past (aka they have unpaid debt). The method we have come up with so far is this:

We have an option set field on PSP called 'PSP Status'. I've added an option named 'Speak to management before contacting'. However, our issue is that our colleagues won't necessarily be looking at each PSP attached to a problem account before creating a new one, so this could be missed. 

The idea I came up with was to create a business rule or workflow where some red text would appear at the top of the Account form when any of its PSPs had the 'Speak to management before contacting' status. However, I'm not sure I'm able to do this as in the past it's only let me create workflows with 1:N entity relationships, not the other way around. It's not a specific PSP that needs to have that status set to trigger the text to appear, it's if any at all have that status. So I'm not sure if that makes it possible at all?

If there's any workaround that anyone knows I'd be very grateful. Please let me know if you need any more information, as I say I've explained it as best I can but it's very possible I've missed out crucial info!

Thanks, Robyn

I have the same question (0)
  • Verified answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi,

    If i understand the need correctly then you want to show Notification Account form if any related PSP records have status "Speak to management before contacting".

    If it correct then we can achieve this by using CRM based script under this will use the form level notification, WEBAPI.

    Link for form level notification:

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-ui/setformnotification

    WebAPI:


    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi

    Just to ease your work.

    I have tried the same scenario by creating one custom entity as PSP and added one PSP Status Field with multiple options(i.e. one option is this "Speak to management before contacting)

    After this i have created below code using WebApi and formlevel notification:

    Typescript Code:

    namespace CRM {
        export namespace Library {
            export class Account {
                onLoad(executionContext: any) {
                    try {
                        let formContext = executionContext.getFormContext();
                       
                        formContext.ui.clearFormNotification("100");
                        accountObj.getActivePSPRecord(formContext);
    
                    } catch (error:any) {
                        alert(error.message);
                    }
                }
    
                getActivePSPRecord(formContext: any) {
                    try {
                        let accountId = formContext.data.entity.getId();
                        let fetchXML = "?fetchXml=" 
                        "" 
                          "" 
                          "" 
                          "" 
                          "" 
                          "" 
                            "" 
                            "" 
                            "" 
                          "" 
                        "" 
                      "";
    
                        //@ts-ignore
                        Xrm.WebApi.retrieveMultipleRecords("new_projectsupportpackage", fetchXML).then(
                            function success(result) {
                                if (result != undefined &&
                                    result.entities.length > 0) {
                                    formContext.ui.setFormNotification("Some Project Support Package record(s) have staus as Speak to management before contacting.", "WARNING", "100");
                                }
                                else
                                {
                                    formContext.ui.clearFormNotification("100");
                                }
    
                            },
                            function (error) {
                                console.log(error.message);
                                // handle error conditions
                            }
                        );
                    } catch (error) {
                        alert(error.message);
                    }
                }
            }
        }
    }
    
    let accountObj=new CRM.Library.Account();

    JavaScript Code:

    function onLoad(executionContext) {
        try {
            var formContext = executionContext.getFormContext();
            formContext.ui.clearFormNotification("100");
            getActivePSPRecord(formContext);
        }
        catch (error) {
            alert(error.message);
        }
    };
    
    
    function getActivePSPRecord(formContext) {
        try {
            var accountId = formContext.data.entity.getId();
            var fetchXML = "?fetchXml="  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                ""  
                "";
            
            Xrm.WebApi.retrieveMultipleRecords("new_projectsupportpackage", fetchXML).then(function success(result) {
                if (result != undefined &&
                    result.entities.length > 0) {
                    formContext.ui.setFormNotification("Some Project Support Package record(s) have staus as Speak to management before contacting.", "WARNING", "100");
                }
                else {
                    formContext.ui.clearFormNotification("100");
                }
            }, function (error) {
                console.log(error.message);
                // handle error conditions
            });
        }
        catch (error) {
            alert(error.message);
        }
    };

    Result:

    Account Record with PSP records:
    pastedimage1631731706601v1.png

    Form Level notification using above script code:
    pastedimage1631731792374v3.png

    Thanks,
    Pradeep.

    Please mark this as VERIFIED if it helps. 

  • rhickman97 Profile Picture
    10 on at

    Hi Pradeep,

    This is fantastic, thank you very much!! This really helped. Many thanks :)

    All the best,

    Robyn

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 107 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 94

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans