- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2020 11:33 PM
Here's the portion of the record producer script I'm having trouble with:
var gsi = producer.gaming_system_issue;
if (gsi == 'Yes') {
current.category = 'gaming';
current.short_description = 'Gaming Issue: ' + producer.business_service.name;
} else if (producer.description.length > 45) {
current.short_description = producer.description.substring(0, 45);
} else {
current.short_description = producer.description;
}
The first if statement works perfectly for the category and short description. However, the next else if statement doesn't work. It never truncates the description per the substring criteria. I still end up with most of the description becoming the short description. I've tried using current.comments = producer.description.toString(); earlier in the script but that didn't work either.
Not sure what I'm doing wrong.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2020 01:11 AM
try this:
var gsi = producer.gaming_system_issue;
var description1 = producer.description.toString();
if (gsi == 'Yes') {
current.category = 'gaming';
current.short_description = 'Gaming Issue: ' + producer.business_service.name;
} else if (description1.length > 45) {
current.short_description = description1.substring(0, 45);
} else {
current.short_description = description1;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2020 11:57 PM
Hi Danny,
In the producer script can you try by changing the script to add toString(). For example:
producer.description.toString().substring(0, 45);
It will work as i tried.
Thanks,
C B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2020 12:07 AM
Hi CB,
Thanks for the reply, but that didn't work either. Any other ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2020 12:25 AM
Hi Danny,
I believe the Its not going inside that else if part as mention below:
else if (producer.description.length > 45)
So can you try putting toString() before the length so that it will find the length of the string
as (producer.description.toString().length > 45) and try to put log inside the else if part so to check whether its going inside or not.
If its going inside the else if then definitely it will populate the substring text.
Please let me know if it works.
Thanks,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2020 12:42 AM
I tried that as well to no avail. 😞
I also added Nikhil's suggestion of gs.info log and it returned "description length undefined"