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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Save form as Draft without filling all mandatory fields

(0) ShareShare
ReportReport
Posted on by 20

Hi there,

I have a CRM form which has a lot of fields, now user cannot fill all these fields in one go. Hence, we have introduced another button which is Save As Draft, which will allow user to complete the application in pieces.

Now for this button, I want to let the user save the form and do not want to take out the mandatory check from the fields which will be required for completion of the application.

How can I achieve this via javaScript in D365?

I have the same question (0)
  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi Faran,

    You can try below script to make required field optional just before save operation and applying requirement level after save completion.

    function saveAsDraft(formContext) {
        let requiredAttributes = [];
        formContext.ui.controls.forEach(control => {
            if (control["getAttribute"]&&control.getAttribute()?.getRequiredLevel()&&control?.getAttribute()?.getRequiredLevel()==="required") {
                requiredAttributes.push(control.getName())
                control.getAttribute().setRequiredLevel("none")
            }
        });
        formContext.data.save().then(() => {
            requiredAttributes.forEach(attribute => {
                formContext.ui.controls.getByName(attribute).getAttribute().setRequiredLevel("required");
            })
        });
    }

    Thanks,

    Ketan

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi FaranSaleem91,

    How about using the business rule?

    When the status reason is draft then make the columns optional, else make it required.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans