Message is Disappearing

purdue
Kilo Sage

I have the submit client script below but message is disappearing after loading.   Any assistance is appreciated.  Thanks, Chad

function onSubmit() {
var assetTag = g_form.getValue('asset_tag');
var serialNumber = g_form.getValue('serial_number');
var regex = /\s+|\u200b/g;

// Check if asset_tag is not empty and trim whitespace
if (assetTag.match(regex)) {
var trimmedAssetTag = assetTag.replace(regex,'');
g_form.setValue('asset_tag', trimmedAssetTag);
g_form.addInfoMessage("We have trimmed your white space");
}

// Check if serial_number is not empty and trim whitespace
if (serialNumber.match(regex)) {
var trimmedSerialNumber = serialNumber.replace(regex,'');
g_form.setValue('serial_number', trimmedSerialNumber);
g_form.addInfoMessage("We have trimmed your white space");
}

}
1 ACCEPTED SOLUTION

purdue
Kilo Sage

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.

assettag.pngBusiness Rule.pngserial number.png

View solution in original post

18 REPLIES 18

Hello @Juhi Poddar 

Just sharing: g_modal is not a standard globally available ServiceNow API.


Hope that helps!

@Vishal Jaswal 

You can refer to the serviceNow documentation: g_modal client

 

Thank You

Juhi Poddar

Hello,

This did not work said g_modal is not defined.   Looking at doc it looks like is used for UI Action.

Thanks,
Chad

purdue
Kilo Sage

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.

assettag.pngBusiness Rule.pngserial number.png