Skip to content

Commit aaf822a

Browse files
Create Auto populate short description
1 parent 69c730d commit aaf822a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
if (isLoading || newValue === '') {
3+
return;
4+
}
5+
6+
// Define category-to-short description mapping
7+
var categoryToShortDescription = {
8+
'hardware': 'Hardware Issue - ',
9+
'software': 'Software Issue - ',
10+
'network': 'Network Issue - ',
11+
'inquiry': 'Inquiry/Help - ',
12+
'database': 'Database - '
13+
};
14+
15+
// Convert the selected value to lowercase for matching
16+
var selectedCategory = newValue.toLowerCase();
17+
18+
// If category exists in mapping, update the short description
19+
if (categoryToShortDescription.hasOwnProperty(selectedCategory)) {
20+
var existingDesc = g_form.getValue('short_description') || '';
21+
var prefix = categoryToShortDescription[selectedCategory];
22+
23+
// Only add prefix if it's not already there
24+
if (!existingDesc.startsWith(prefix)) {
25+
g_form.setValue('short_description', prefix + existingDesc);
26+
g_form.showFieldMsg('short_description', 'Short Description auto-updated based on category.', 'info');
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)