- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 08:53 PM
I have the submit client script below but message is disappearing after loading. Any assistance is appreciated. Thanks, Chad
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 11:43 AM
Hello All,
I want to thank everyone for their responses. We were able to resolve this. Below is the solution.
Ask
Filter Whitespace from 2 fields(Asset Tag and Serial Number) on Alm Asset.
Solution
Create 2 OnChange Client Scripts AND Before BR on Insert and Update with condition gs.Interactive for editing from list view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 10:08 PM
@purdue
Please try with below script:
function onSubmit() {
var assetTag = g_form.getValue('asset_tag');
var serialNumber = g_form.getValue('serial_number');
var regex = /\s+|\u200b/g;
var messageShown = false;
if (assetTag.match(regex)) {
var trimmedAssetTag = assetTag.replace(regex, '');
g_form.setValue('asset_tag', trimmedAssetTag);
g_form.showFieldMsg('asset_tag', 'Whitespace was removed', 'info');
messageShown = true;
}
if (serialNumber.match(regex)) {
var trimmedSerialNumber = serialNumber.replace(regex, '');
g_form.setValue('serial_number', trimmedSerialNumber);
g_form.showFieldMsg('serial_number', 'Whitespace was removed', 'info');
messageShown = true;
}
// Optional: delay submission so the user sees messages
if (messageShown) {
return true; // or return false if you want to prevent submission and prompt user
}
}
Please mark correct/helpful if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 08:26 AM
Unfortunately this did not work. Thanks for the reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 08:28 AM
Hey all, thanks for the replies. I thought I would try a new approach pop the message then setWait for 2 seconds then allow the submit. What do you think?
Thanks,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 08:44 AM
How about this -
Trim the values silently in the onSubmit client script.
Show the message after the form reloads, using a server-side Business Rule with gs.addInfoMessage().
1. Client Script (Type: onSubmit)
function onSubmit() {
var assetTag = g_form.getValue('asset_tag');
var serialNumber = g_form.getValue('serial_number');
var regex = /\s+|\u200b/g;
if (assetTag && assetTag.match(regex)) {
g_form.setValue('asset_tag', assetTag.replace(regex, ''));
}
if (serialNumber && serialNumber.match(regex)) {
g_form.setValue('serial_number', serialNumber.replace(regex, ''));
}
return true; // allow form to submit normally
}
2. Business Rule (Server-side) — Shows message after save
Name: Show trimmed message
Table: Your table
When: After
Insert and Update: Check both
Condition: You can check if the asset tag or serial number was trimmed by comparing current and previous (optional).
Script:
(function executeRule(current, previous /*null on insert*/) {
var regex = /\s+|\u200b/g;
var trimmed = false;
if (current.asset_tag.changes()) {
var oldTag = previous.asset_tag.toString();
var newTag = current.asset_tag.toString();
if (newTag.replace(regex, '') !== oldTag.replace(regex, '')) {
trimmed = true;
}
}
if (current.serial_number.changes()) {
var oldSerial = previous.serial_number.toString();
var newSerial = current.serial_number.toString();
if (newSerial.replace(regex, '') !== oldSerial.replace(regex, '')) {
trimmed = true;
}
}
if (trimmed) {
gs.addInfoMessage("Extra whitespace was automatically removed from the asset tag and/or serial number.");
}
})(current, previous);
Result:
Form submits with clean data.
User sees the info message after the form reloads.
No JS tricks, no submit delays, and it works in all UI scenarios.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 09:31 AM
Hello,
I tried this but no message was received. Any idea?
Thanks again,
Chad