How to make fields mandatory in ui action
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2020 03:38 AM
I have to make work notes and closed notes mandatory when I click on closed in Problem.So I have created a ui action for this.How can I add the conditions to make fields mandatory in this ui action.This is not working Can anyone please suggest and I am also not able to get the field name for work notes
Labels:
- Labels:
-
Scripting and Coding
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2023 06:11 AM
UI Action
Active : true
Show update : true
Client : true
List v2 Compatible : true
List v3 Compatible : true
Onclick: setM();
function setM() {
var c = 0;
var arr = ['fieldname1','fieldname2','variables.variablename1','variables.variablename2'];
for (var i = 0; i < arr.length; i++) {
if (g_form.getValue(arr[i]) == '') {
g_form.setMandatory(arr[i], true);
c++;
}
}
if (c>0){
alert('Please fill Mandatory fields');
}
var mrvs = g_form.getValue('mrvs_name');
var data = JSON.parse(mrvs);
if (data.length == 0) {
alert('MRVS cannot be empty!');
}
if (c == 0 && data.length > 0) {
g_form.setValue('state', 'submit');
g_form.save();
}
}