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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,641)