- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 01:12 PM
I have a requirement to add a pin field on the user table, I used a client script to control the accepted character in the field to be numeric but when I added the same field to the service portal view and I navigate to service portal profile page to input data. This field accept string data even though the accepted character is only numeric.
The above picture is the user table field and this field only accept numeric only.
The picture above is the service portal view which accept alphabet which is not meant to.
Please how can I make the service portal field to act exactly the same as the back end field?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 09:56 PM
Understood your issue now. Tried reproducing it on my PDI and you're right. The client script is not working when we make an update from Service Portal. It's may be as the update is happening via the User Profile widget. To overcome this, I tried creating a Before Insert or Update Business rule and it is working as expected. Refer below steps :
1. Make a Before Insert/Update Business rule as shown below and with the script as :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var pinId = current.u_pin_id;
// Check if the value is not exactly 5 characters
if (pinId.toString().length != '5' || isNaN(pinId) == true) {
// Display an alert message
gs.addErrorMessage('Pin ID must be 5 numeric numbers.');
current.u_pin_id = '';
}
})(current, previous);
2. Navigate to Service Portal -> User Profile. Try Updating the pin with wrong input. It will give the below error message and will clear the Pin field value :
Please give this a try. Also, ensure that you mark your On-Submit Client Script In-active to avoid collisions.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 09:23 PM
Hi @showmiro1
Is the Global Checkbox checked for your client script ? If not, please check it and retry.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 10:10 PM
@showmiro1 , Check If your current Client script is designed for any Particular view , If this is not on any Specific check Global is Checked on Client script
Also if your checking this on any Portal , UI type should be Set to ‘ALL’
Check this settings and let me know if still see any Issue
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 10:21 PM
May be script logic not supporting in Portal. Please share script logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 04:46 AM
@Amit Verma The Global checkbox is checked
@shyamkumar VK UI is set to ALL
@ramprasadk Below is the script logic on the field