Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

Different entity field make mandatory on parent entity using javascript in crm 365 online

Posted on by 2,665

Hi All,

I need to make field mandatory for which am using below script

On Lead form in a tab we are showing form component control of fields from different entity ex application entity.

Which is working fine until unless am clicking on the tab is there any way without clicking tab it should throw notification for making field mandatory.

And how can we check the control null /undefined ? like if( FormContext.getControl(attributes.PRODUCTAPPLICATION).getAttribute(attributes.APPLICATIONFORMNO) !== null && FormContext.getControl(attributes.PRODUCTAPPLICATION).getAttribute(attributes.APPLICATIONFORMNO) !== undefined) Is it correct as while debugging its not working

/// Make Application fields mandatory based on lead status Push to onboarding
Deal_Retail.makeMortgageApplicationFieldsMandatory = async function () {
"use strict";
try {
if (FormContext !== undefined && FormContext !== null) {
var formType = common_Retail.getFormType();
if (formType === 2) {
var lineofbusiness = common_Retail.getAttributeValue(attributes.LINE_OF_BUSINESS);
if (lineofbusiness !== null && lineofbusiness !== undefined) {
var lineOfBusinessVal = common_Retail.getAttribute(attributes.LINE_OF_BUSINESS).getValue()[0].name;
if (lineOfBusinessVal === LOB.MORTAGAGE) {
var leadStatusAttribute = FormContext.getControl(attributes.Header_ProspectSubStage).getAttribute();
if (leadStatusAttribute !== undefined && leadStatusAttribute !== null) {
var leadStatusValue = leadStatusAttribute.getValue();
if (leadStatusValue !== undefined && leadStatusValue !== null) {
var leadStatusName = leadStatusValue[0].name;
}
}
if (leadStatusName === "Push to Onboarding") {
var applicationEntity = FormContext.getAttribute(attributes.PRODUCTAPPLICATION);
if (applicationEntity !== null && applicationEntity !== undefined) {
var prodAppID = applicationEntity.getValue()[0].id.replace("{", "").replace("}", "");
if (prodAppID !== null && prodAppID !== undefined) {
setTimeout(function () {
FormContext.getControl(attributes.PRODUCTAPPLICATION).getAttribute(attributes.APPLICATIONFORMNO).setRequiredLevel("required");
FormContext.getControl(attributes.PRODUCTAPPLICATION).getAttribute(attributes.APPLICATIONDATE).setRequiredLevel("required");
}, 200);

}
}
}
}
}
}
}
} catch (e) {
common_Retail.openAlertDialog("Ok", e.message);
}
};

pastedimage1672729657609v1.png

Thanks,

Jharana

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans