cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mvdb
Advocate I
Advocate I

Can i save a model-driven form automatically when a field is filled in?

I have a main form with a primary field and a look up field. When clicked on the look up field, a QuickCreate form appears. That QuickCreate form also contains a look up field to the table of the main form. But as long as the main form isn't saved I cannot find the primary field of the main form in the look up field of the QuickCreate form.

Can someone help? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
cchannon
Super User
Super User

Yes, you can trigger a save automatically on any form event.

 

What you're looking for is a piece of formscript that sits on the onChange event for the field you are targeting and when it fires, it checks null, sets submit mode, and refreshes the page with save True. There will be a small flicker while the page reloads which users might complain about but probably they will never notice.  The script then would look something like:

 

if (typeof (myScript) === "undefined") { var myScript= {}; }

myScript.execute = function(executionContext) {
    'use strict';
    var formContext = executionContext.getFormContext();
    if(formContext.getAttribute("myAttribute").getValue != null)
    {          
        formContext.getAttribute("myAttribute").setSubmitMode("always");
        formContext.data.save().then(function (result) { }, function (error) { });
    }
}

 

 

View solution in original post

1 REPLY 1
cchannon
Super User
Super User

Yes, you can trigger a save automatically on any form event.

 

What you're looking for is a piece of formscript that sits on the onChange event for the field you are targeting and when it fires, it checks null, sets submit mode, and refreshes the page with save True. There will be a small flicker while the page reloads which users might complain about but probably they will never notice.  The script then would look something like:

 

if (typeof (myScript) === "undefined") { var myScript= {}; }

myScript.execute = function(executionContext) {
    'use strict';
    var formContext = executionContext.getFormContext();
    if(formContext.getAttribute("myAttribute").getValue != null)
    {          
        formContext.getAttribute("myAttribute").setSubmitMode("always");
        formContext.data.save().then(function (result) { }, function (error) { });
    }
}

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (3,188)