How to Put Restriction for Work notes Characters length?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 05:29 AM
I have created one onsubmit client script for checking work notes text atleast 20 characters else not abel to submit the form it is working fine whenever submit the form but not working whenever using post button under work notes then directly updated the work notes not checking the length
script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 06:40 AM
That Post button is a sticky wicket. You can get rid of the Client Script. In the example of the Work Notes field on the incident table, what you need is 2 Business Rules to prevent the journal entry table record from being created, then to delete the activity filter record which shows the work note was added, even though there's no journal entry for it. This will also work when updating the incident record and not using the Post button.
The first Business Rule is on the sys_journal_field table, before Insert and Update:
(function executeRule(current, previous /*null when async*/) {
if (current.value.toString().length < 20) {
current.setAbortAction(true);
}
})(current, previous);
The second Business Rule is on the sys_history_set table, after Insert and Update with the Filter Conditions = Table is incident:
(function executeRule(current, previous /*null when async*/) {
var histGR = new GlideRecord('sys_history_line');
histGR.addQuery('set.id', current.id);
histGR.addQuery('field', 'work_notes');
histGR.addQuery('type', 'audit');
histGR.orderByDesc('update_time');
histGR.query();
while (histGR.next()) {
if (histGR.getValue('new').length < 20) {
histGR.deleteRecord();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 02:27 AM
Hi @Brad Bowman There is any possiable the restriction for post button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 03:39 AM
You can hide it when this form loads or something changes. This uses DOM manipulation, so ensure the Isolate script box is unchecked after the script is saved.
function onLoad() {
var postBtn = document.getElementsByClassName('activity-submit');
postBtn[0].hide();
}