Skip to content

Commit d4703f1

Browse files
Merge branch 'main' into Currency-conversion
2 parents 772a5cf + c990397 commit d4703f1

File tree

267 files changed

+8968
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+8968
-496
lines changed

Client-Side Components/Catalog Client Script/Allow 10digit Fax Number/Allow 10digit Fax Number.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Allow 10digit Fax Number/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function onChange(control, oldValue, newValue, isLoading) {
2+
if (isLoading) {
3+
return;
4+
}
5+
6+
var maxChars = 100;//count of charaters
7+
var currentLength = newValue.length;
8+
9+
// Clear previous messages
10+
g_form.clearMessages();
11+
12+
// Show info message
13+
g_form.addInfoMessage('Character count: ' + currentLength + ' / ' + maxChars);
14+
15+
if (currentLength > maxChars) {
16+
// Show error message
17+
g_form.addErrorMessage('Character limit exceeded! Please shorten your text.');
18+
g_form.showFieldMsg('short_description', 'Too many characters!', 'error');
19+
20+
// Make field mandatory to block submission
21+
g_form.setMandatory('short_description', true);
22+
} else {
23+
// Remove mandatory if valid
24+
g_form.setMandatory('short_description', false);
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This onChange Catalog Client Script displays the current character count for a text field and enforces a maximum limit by showing error messages and making the field mandatory to prevent form submission when exceeded.

Client-Side Components/Catalog Client Script/Real-Time Character Counter for Text Fields

Lines changed: 0 additions & 1 deletion
This file was deleted.

Client-Side Components/Catalog Client Script/Regex Validation/script.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**Set and Lock Variable by Group**
2+
3+
This solution provides a secure and dynamic way to control data entry on a Service Catalog form based on the user's group membership. It is typically used to pre-fill and lock certain justification or approval bypass fields for authorized users (like managers or executive staff), improving their efficiency while maintaining an accurate audit trail.
4+
5+
This functionality requires a combined Client-side (Catalog Client Script) and Server-side (Script Include) approach to ensure the group check is done securely.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// onload Catalog Client Script with Catalog Name
2+
function onLoad() {
3+
var variableName = 'bypass_approval_reason';
4+
var targetGroupName = 'ServiceNow Support'; // The group authorized to skip this step
5+
var ga = new GlideAjax('UserUtils');
6+
ga.addParam('sysparm_name', 'isMemberOf');
7+
ga.addParam('sysparm_group_name', targetGroupName);
8+
ga.getXMLAnswer(checkAndLockVariable);
9+
function checkAndLockVariable(response) {
10+
var isMember = response;
11+
if (isMember == 'true') {
12+
var message = 'Value set and locked due to your ' + targetGroupName + ' membership.';
13+
var setValue = 'Bypassed by authorized ' + targetGroupName + ' member.';
14+
g_form.setValue(variableName, setValue);
15+
g_form.setReadOnly(variableName, true);
16+
g_form.showFieldMsg(variableName, message, 'info');
17+
} else {
18+
g_form.setReadOnly(variableName, false);
19+
}
20+
}
21+
}
22+
23+
//Script Include
24+
var UserUtils = Class.create();
25+
UserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
26+
isMemberOf: function() {
27+
var groupName = this.getParameter('sysparm_group_name');
28+
var isMember = gs.getUser().isMemberOf(groupName);
29+
return isMember.toString();
30+
},
31+
32+
type: 'UserUtils'
33+
});

Client-Side Components/Catalog Client Script/Special Characters/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Special Characters/script.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)