log in to a Power Apps using “Make.powerApps.com”.
In Power Apps dashboard navigate to Solutions
In the solution navigate to Web resources & create a new web resource by using following steps.
In my scenario fathername is non mandatory field.
Write the below code in Visual Studio or Visual Studio Code and save as .js document in your system
function onchange(executionContext)
{
var formContext = executionContext.getFormContext();
if (formContext !== null && formContext != ‘undefined’)
{
var jobtitle = formContext.getAttribute(“crmonce_lookup2”).getValue();
var jobtitlecontrol = formContext.getControl(“crmonce_lookup2”);
console.log(‘job title’+ ‘job title’);
if (jobtitle == null)
{
formContext.ui.setFormNotification(“fathername Mandatory- Error notification.”, “ERROR”, “fathernameMandateNotification”);
jobtitlecontrol.setNotification(“fathernameMandatory- Error notification.”, “fathernamecontrolnotification“);
}
else
{
formContext.ui.clearFormNotification(“fathernameMandateNotification”);
jobtitlecontrol.clearNotification(“fathernamecontrolnotification”);
}
}}
In Powerapps window Webresources->New->More->Webresource
In Web resources choose the file from system that we have saved.
Give display name and schema name to the webresource and select JavaScript type and Save&Publish the webresource.
Now navigate to tables->select table->forms->mainform.
After opening the main form.
Go to form libraries -> add library-> select webresource that you have created.
After adding the web resource to the form libraries.
Then Select field->events->eventhandlers->select library->enter function that you have used in js ->passexecution ->click done
Save & Publish the customizations.
Now go to Apps in navigation bar and select your app.to test the customizations.
At finally we see that fatherName will be manditory with waring message.