how to display alert message if field is empty on incident form when user tries to update the form

Arjun Reddy Yer
Tera Guru

Can anyone help me as I need to display a alert message on incident form as mentioned in below screen shot.

When the field is empty and user tries to Update the from then alert message should display and should stop the form to update or save.

As tried with Business Rule and Client Script but didn't get the actual resul. @Ankur Bawiskar @AnveshKumar M @priyasunku @Vasantharajan N 

 

Alert Message to display as below:

ArjunReddyYer_0-1680766092287.png

 

Written Business Rule:

ArjunReddyYer_1-1680766257968.png

ArjunReddyYer_2-1680766305889.png

ArjunReddyYer_3-1680766367606.png

 

1 ACCEPTED SOLUTION

@Arjun Reddy Yer -

Step 1: if you are running UI policy to make the field "Caused by" mandatory then do disable it and

Step 2: Use the onSubmit client script shared by other contributors in this forum or use the below onSubmit script.

 

try below code snippet

function onSubmit() {

    if (g_form.getValue('u_caused_by_change') == 'true' && g_form.getValue('caused_by') == '') {
        g_form.addErrorMessage("Please fill in the ‘Change’ detail in Related Records, as this incident is Caused by Change");
        g_form.setMandatory('caused_by', true);
        return false;
    }

}

 


Thanks & Regards,
Vasanth

View solution in original post

12 REPLIES 12

Vasantharajan N
Giga Sage
Giga Sage

@Arjun Reddy Yer - You should not use g_form API at Server side running scripts like BR. 

 

VasantharajanN_0-1680769223036.png

Please try use the below script and check

(function executeRule(current, previous /*null when async*/) {

	var cbc = current.getValue('caused_by');
	if(cbc.nil()){
		gs.addErrorMessage("Please fill in the change details");
		current.setAbortAction(true);
	}

})(current, previous);

 


Thanks & Regards,
Vasanth

Should show message as "Please fill in the ‘Change’ detail in Related Records, as this incident is Caused by Change" .

 

it is not showing as expected it's showing below error message

ArjunReddyYer_1-1680770124853.png

 

 

 

@Arjun Reddy Yer -

Step 1: if you are running UI policy to make the field "Caused by" mandatory then do disable it and

Step 2: Use the onSubmit client script shared by other contributors in this forum or use the below onSubmit script.

 

try below code snippet

function onSubmit() {

    if (g_form.getValue('u_caused_by_change') == 'true' && g_form.getValue('caused_by') == '') {
        g_form.addErrorMessage("Please fill in the ‘Change’ detail in Related Records, as this incident is Caused by Change");
        g_form.setMandatory('caused_by', true);
        return false;
    }

}

 


Thanks & Regards,
Vasanth