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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

require user to save form after certain field filled in

(0) ShareShare
ReportReport
Posted on by 40

I am looking for a way to prompt or force the user to save a record after a specific field is filled in. And then if they fill in another specific field in mind I again want to prompt or force the user to save the record again. Any tips would be greatly appreciated. Thank you. GERALD DAHL

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Gerald Dahl,

    You can save the current record by calling the below JavaScript code on the on change event of the specific field.

    Xrm.Page.data.entity.save();

  • Suggested answer
    Fubar Profile Picture
    2,761 on at

    If you want to ask the user first, then you could use openConfirmDialog set to trigger on the onChangeEvent of the relevant field

    docs.microsoft.com/.../openConfirmDialog (and also put the save() suggested by Adrian inside the success  callback )

  • Suggested answer
    Inogic Profile Picture
    707 on at
    Hi Gerald,

    Please follow the below steps in order to save the record after certain field filled in.

    1.       Create a function which will trigger on change of targeted fields

     

    function saveRecordOnChange(executionContext){

        try{

            // Form Context

            let formContext = executionContext.getFormContext();

     

            // If Form Context is valid

            // Then save record

            if(formContext){

                // Save the Record

                formContext.data.save();

            }

        }

        catch(ex){

            throw new Error(ex.message);

        }

    }

                                        OR
    If you want to prompt user for confirmation than you can use below code and put save() method inside the success function of Confirm Dialog as below:

     

    function saveRecordOnChange(executionContext) {

        try {

            // Form Context

            let formContext = executionContext.getFormContext();

     

            // If Form Context is valid

            // Then save record

            if (formContext) {

     

                let confirmStrings = { text: "This is a confirmation.", title: "Do you want to save this record?" };

                let confirmOptions = { height: 200, width: 450 };

     

                // Open Confirm Dialog

                Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(

                    function (success) {

                        if (success.confirmed) {

     

                            // Save the Record

                            formContext.data.save();

                        }

                    });

            }

        }

        catch (ex) {

            throw new Error(ex.message);

        }

    }

     2.       After creating function add the function to the OnChange event of targeted fields using the form properties as shown below:

    5th-Dec-2020.jpg

    3.       Click on Save and Publish the forms.

    Hope this helps!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 72 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 29 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans