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

Saving form before setting all my fields on form required

(0) ShareShare
ReportReport
Posted on by 1,290

Hello All,

I have a following requirement where on the click of button in the ribbon, there are around 20 fields should be converted to "Business Required" on the form. Currently these fields are "Business Recommended".

However, I would also like to save the form before setting them required.

I am able to set the 20 fields to "Business Required" but because the fields are required it wont save the form.

For Example: 

I am filling out the form and i have filled out 7 fields details and I would like to save those 7 fields information on the click of the Submit button. Below is the JS code which i am using to convert the fields into business required. But i am having hard time saving the records. 

function setRequiredLevel(primaryControl)
{ debugger;
var formContext = primaryControl;
formContext.data.entity.save();
afterSave(formContext);
}
function afterSave(formContext)
{

var currentForm = formContext.ui.formSelector.getCurrentItem();
if(currentForm.getLabel() == "Commercial Form"){
var intakeFields = ["ibc_opportunitytoahaintakeid",
"ibc_lineofbusiness",
"ibc_statusofrequest",
"ibc_dateofinitialintakeformsubmission",
"ibc_duedate",
"ibc_effectivedate"];
}

for(var i=0; i<intakeFields.length; i++)
{
var intakeField = intakeFields[i];
if(formContext.getAttribute(intakeField) != null)
{
formContext.data.entity.save();
formContext.getAttribute(intakeField).setRequiredLevel("required");
}
else
{
formContext.getAttribute(intakeField).setRequiredLevel("required");
}

}

}

Please let me know if there's any workaround where i can save the form first, so i dont lose the information in the fields which i have already filled

Any help would be much appreciated.

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

    Hi,

    Please use the following save method docs.microsoft.com/.../save and on success callback try to make the the empty fields business required.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    HI,

    You can update the record with field data using Web API and this way you don't have to take care of mandatory field error validation.

    Once you save the data using web api then make those field mandatory.

    If found helpful, Please mark my answer verified.

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 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

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

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans