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.