Skip to content

Commit bcb27a8

Browse files
authored
Field Review of User Record when on form using action button (#2499)
* Create README.md * Add files via upload * Create actionButtonScript.js
1 parent 41d2d10 commit bcb27a8

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed
80.1 KB
Loading
105 KB
Loading
67.7 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Field Review of User Record when on form using action button
2+
3+
Displays informational messages suggesting improvements to field formatting on the User Table (**sys_user**) form when the **Fields Check** button is clicked.
4+
5+
- Helps maintain consistency in user data by checking capitalization of names and titles, validating email format, ensuring phone numbers contain only digits, and preventing duplicate phone entries.
6+
- Also suggests users not to leave the **user_name** field empty.
7+
- Shows Info messages below each field highlighting fields that may need attention.
8+
- Simple Prerequisite is that: when form loads give Info message to check **Field Check** button to bring user's attention
9+
- Uses a Client-side UI Action (**Fields Check**) that to review entered data and display friendly suggestions
10+
- Name: Fields Check
11+
- Table: User (sys_user)
12+
- Client: true
13+
- Form button: true
14+
- Onclick: onClickCheckDetails()
15+
16+
---
17+
18+
### Grab user's attention on Field Check Button using Info message at top
19+
20+
![Field Review on User Table_1](Field_Review_userTable_1.png)
21+
22+
---
23+
24+
### After clicking Field Check Button where suggestions are displayed below fields
25+
26+
![Field Review on User Table_2](Field_Review_userTable_2.png)
27+
28+
---
29+
30+
### When user fixes the suggested issues and click the **Fields Check** button again, a message confirms that all fields are correctly formatted
31+
32+
![Field Review on User Table_3](Field_Review_userTable_3.png)
33+
34+
---
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function onClickCheckDetails() {
2+
// Friendly helper for field normalization guidance
3+
g_form.hideAllFieldMsgs();
4+
g_form.clearMessages();
5+
6+
// --- Get Field values ---
7+
var firstName = g_form.getValue('first_name');
8+
var lastName = g_form.getValue('last_name');
9+
var title = g_form.getValue('title');
10+
var userId = g_form.getValue('user_name');
11+
var email = g_form.getValue('email');
12+
var businessPhone = g_form.getValue('phone');
13+
var mobilePhone = g_form.getValue('mobile_phone');
14+
15+
// --- Regex patterns ---
16+
var capitalRegex = /^[A-Z][a-zA-Z\s]*$/; // Names & titles start with a capital
17+
var emailRegex = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
18+
var phoneRegex = /^\d+$/;
19+
20+
var suggestions = [];
21+
22+
if (firstName && !capitalRegex.test(firstName)) {
23+
g_form.showFieldMsg('first_name', 'Suggestion: Start the name with a capital letter.', 'info');
24+
suggestions.push('First Name');
25+
}
26+
27+
if (lastName && !capitalRegex.test(lastName)) {
28+
g_form.showFieldMsg('last_name', 'Suggestion: Start the name with a capital letter.', 'info');
29+
suggestions.push('Last Name');
30+
}
31+
32+
if (title && !capitalRegex.test(title)) {
33+
g_form.showFieldMsg('title', 'Suggestion: Titles usually start with a capital letter.', 'info');
34+
suggestions.push('Title');
35+
}
36+
37+
if (!userId) {
38+
g_form.showFieldMsg('user_name', 'Suggestion: Do not keep the User ID empty.', 'info');
39+
suggestions.push('User ID');
40+
}
41+
42+
if (email && !emailRegex.test(email)) {
43+
g_form.showFieldMsg('email', 'Suggestion: Please use a valid email format like name@example.com.', 'info');
44+
suggestions.push('Email');
45+
}
46+
47+
if (businessPhone && !phoneRegex.test(businessPhone)) {
48+
g_form.showFieldMsg('phone', 'Suggestion: Use digits only avoid letters.', 'info');
49+
suggestions.push('Business Phone');
50+
}
51+
52+
if (mobilePhone && !phoneRegex.test(mobilePhone)) {
53+
g_form.showFieldMsg('mobile_phone', 'Suggestion: Use digits only avoid letters.', 'info');
54+
suggestions.push('Mobile Phone');
55+
}
56+
57+
/
58+
if (businessPhone && mobilePhone && businessPhone === mobilePhone) {
59+
g_form.showFieldMsg('phone', 'Work and mobile numbers appear identical, use different Numbers!', 'info');
60+
suggestions.push('Phone Numbers');
61+
}
62+
63+
if (suggestions.length > 0) {
64+
g_form.addInfoMessage('Quick review complete! Please check: ' + suggestions.join(', ') + '.');
65+
} else {
66+
g_form.addInfoMessage('looks good! Nicely formatted data.');
67+
}
68+
}

0 commit comments

Comments
 (0)