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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Javascript in form in ...
Power Apps
Unanswered

Javascript in form in model-driven app gets overruled

(0) ShareShare
ReportReport
Posted on by 72

In a model driven app i am attempting to set a view of a subgrid using Javascript on onload form. When the page load I see the view fllcking back and forth between the default view and the view I am trying to set, sometimes settling on one or the other. 

This is my JS file:

function fnChangeViewOfSubgrid(executionContext) {
 "use strict";
 var oFormContext = executionContext.getFormContext();
 var parameter = oFormContext.data.entity.attributes.get('cr84b_parameter').getValue();
 var viewSelector = oFormContext.getControl("Subgrid_new_3").getViewSelector();
 switch(parameter){

 case 100000000:
 var DynamiskView = {
 entityType: 1039, // SavedQuery
 id: "8397137f-a65e-ed11-9561-6045bd90516a",
 name: "Suspenderede stoffer"
 };
 break;
 case 206200000:
 var DynamiskView = {
 entityType: 1039, 
 id: "f44c6642-a65e-ed11-9561-6045bd90516a", //id på view
 name: "pH"
 };
 default:
 var DynamiskView = {
 entityType: 1039, 
 id: "07f4d2c7-a65e-ed11-9561-6045bd90516a",
 name: "Ammonium-N"
 };
 }
 viewSelector.setCurrentView(DynamiskView);

 

}

 

Any idea of what I am doing wrong or missing?

Categories:
I have the same question (0)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard