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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Model driven app and a...
Power Apps
Suggested Answer

Model driven app and a subgrid

(0) ShareShare
ReportReport
Posted on by
Hello' I have a model driven app and there is a subgrid that shows related records. In the record there is allocation column that should total 100. If child rows don't equal 100 I need to give an error to the user.  It has to be instant to the user to calculated columns are not an option any ideaa
I have the same question (0)
  • Suggested answer
    QuentinDURIEZ Profile Picture
    577 Moderator on at
    Hi,

    The best way to do it is using a JavaScript handler in the OnLoad property of the form

    Just create a JS function that will retrieve all related records and show a notification if the le total of allocation column is not 100 

    Here is a sample function for you to start : 
     
    async function myFunction(executionContext){
    	const formContext = executionContext.getFormContext();
    	 if(formContext.ui.getFormType() === 1) return;
    	 formContext.ui.clearFormNotification("ID");
    	 const id = formContext.data.entity.getId().replace(/[{}]/g, '')
    	 let retrieve = await Xrm.WebApi.retrieveMultipleRecords('related_table_name', `?$select=[allocation_column]&$filter=_[main_table_lookup]_value eq ${id}`);
    	 if(retrieve.entities.length > 0 ) {
    			const allocation_sum = retrieve.entities.reduce((acc, val) => acc.allocation_column + val , 0);
    			if(allocation_sum === 100) return;
    	 }
    	 formContext.ui.setFormNotification("text", "ERROR", "ID");
    }

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard