- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 07:41 AM
Below is the code I am using to populate short description. This is for a catalog item so a user can put in an incident based on category and subcategory, but will give the person who receives the incident a clear understanding of what is the problem. Does anyone have any advice for my code.
function onSubmit() {
var category = g_form.getValue(category);
var subcategory = g_form.getValue(subcategory);
var message = 'I am having an issue with ' + category + '. ' + 'It seems to be ' + subcategory + '.';
g_form.setValue('short_description', message);
}
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 07:55 AM
Hi Alec,
A couple things here:
You mentioned this client script is for a catalog item? & then you say it's for incident?
If its for Create an issue (Record producer)
1. I do not recommend this solution, you can have the record producer auto populate the categories.
if you still want to do this
2. Your field names need to be in quotes.
3. Try using a onChange client script instead.
4. If you do onSubmit, you might want to check if the short description is empty before you submit to make sure you dont overwrite your text. You can do something like :
if (g_form.getValue('short_description') == '' {
// Run Code
)
Again, i do not recommend this solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 07:59 AM
what does your message actually say?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 08:15 AM
Just for reference, you can try below script to get display value of select box:
var category = g_form.getValue('variables.category');
category = g_form.getOption('category', category).text;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 07:55 AM
Hi Alec,
A couple things here:
You mentioned this client script is for a catalog item? & then you say it's for incident?
If its for Create an issue (Record producer)
1. I do not recommend this solution, you can have the record producer auto populate the categories.
if you still want to do this
2. Your field names need to be in quotes.
3. Try using a onChange client script instead.
4. If you do onSubmit, you might want to check if the short description is empty before you submit to make sure you dont overwrite your text. You can do something like :
if (g_form.getValue('short_description') == '' {
// Run Code
)
Again, i do not recommend this solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 08:13 AM
Hi Steven,
We are making a catalog item based on the incident table so we can have users submit incidents from our new service portal that we are rolling out soon. This works great for now and it is just a temporary solution.
Thanks, Alec