- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 12:49 PM
Thanks Cris! I am trying to use this in the onChange script that I created to compare the short description and description. I am getting a javascript error on the portal record producer though.
Here is the onChange client script. Also, how to I add an alert popup if the description is under 251 characters?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Verify that Short Description and Description are not the same
var title = g_form.getValue('short_description');
if(title == newValue)
{
alert('Description cannot be the same as the short description. Please enter additional information.');
g_form.clearValue('description');
}
//Verify that Description is at least 250 characters
var ga = new GlideAjax('CPcheckDescriptionLength'); //The name of the Script Include
ga.addParam('sysparm_name', 'isLengthSatisified'); //The name of the method we want to use in the SI
ga.addParam('sysparm_sd', g_form.getValue('description')); //Pass your description to the param we define in the SI
ga.getXMLAnswer(function(response){ //Callback function to use the 'response' from our SI
jslog(response); //Will be true or false
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 07:12 AM
I tried this with the onLoad script and cannot get it to work. I get a javascript error when the record producer loads
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:43 AM
Have you considered using a variable set for this?
The variable set would only contain a single field - Description, and the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 07:38 AM
Hi,
you want to validate this on catalog/record producer form right?
Also I assume both description and short description are variables on that record producer.
Why not add those 2 variables as part of single variable set and create catalog client script which applies on variable set?
You can add this variable set to all your catalog items and the script will work on every form
Regards
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 01:27 PM
I ended up creating a variable set with the 2 variables and catalog client script and it works well. Thank you for the help!