
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 02:13 AM
Hello Everyone,
I'm currently working on implementing a character limit for a multiline variable within a variable set that's associated with a specific catalog item. Despite attempting to utilize the max_length attribute, I haven't achieved the desired result. As an alternative, I've explored the option of employing a catalog client script. However, it seems like its not firing becuase I have tried to insert a dummy alert as well never showed. Please see my script below and advise where you can:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('Testing...');
//Type appropriate comment here, and begin script below
var charLimit = 250;
var reasonForNomination = g_form.getValue('reason_for_nomination');
if (reasonForNomination.length > charLimit){
g_form.setValue('reason_for_nomination', reasonForNomination.substring(0, charLimit));
g_form.addFieldMessage('reason_for_nomination', 'Maximum character limit exceeded. Please limit your input to ' + charLimit + ' characters.');
return false;
}else{
g_form.clearMessages();
return true;
}
}
Below is the configurations:
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 02:32 AM
Hi @Kamva ,
are you checking this on portal?
if yes please make UI type as all & then try it should work.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 02:32 AM
Hi @Kamva ,
are you checking this on portal?
if yes please make UI type as all & then try it should work.
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 02:52 AM
Hi @Kamva
Can you check if your variable selected in the client script variable is correct?
also, try putting in alerts here, your script looks fine except for using function "showFieldMsg"
Go through below doc to understand the function better.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 03:49 AM
Hi @Kamva
I simulated your requirement on my PDI. Below are my findings :
1. Ensure that you have selected UI Type as All in your On-Change Client Script as shown below :
2. Change your Client Script as below :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var charLimit = 250;
var reasonForNomination = g_form.getValue('reason_for_nomination');
if (reasonForNomination.length > charLimit){
g_form.setValue('reason_for_nomination', reasonForNomination.substring(0, charLimit));
g_form.showFieldMsg('reason_for_nomination', 'Maximum character limit exceeded. Please limit your input to ' + charLimit + ' characters.');
return false;
}else{
g_form.hideAllFieldMsgs();
return true;
}
}
Output :
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.