
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 01:23 PM
I have been asked to automatically put the caller_id in the beginning of the short_description on an Incident Form. I have reviewed with our ServiceDesk and validated their use case asking for this change and it seems legit. Newbie here....I think the right way to go is a Client Script to dynamically update the form onChange. What am I missing?
Here's what I got and how crazy am I:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading){
return;
}
//try to ensure we don't loop and keep processing short description field changes
if (oldValue != ''){
return;
}
//Alter Short Description with "caller_id" colon space short_description
//Get contents of caller_id field and put into var caller
var caller = g_form.getReference('caller_id');
//Get contents of short_description and put into var shortd
var shortd = g_form.getValue('short_description');
//Combine var caller and var shortd into one var called newshortd
var newshortd = (caller +': ' +shortd);
//Set the new value of short_description with the var newshortd
g_form.setValue('short_description', newshortd);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 05:19 PM
Please try below, if this helps.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var shortd = g_form.getValue('short_description');
var caller = g_form.getReference('caller_id', doAlert);
function doAlert(caller) {
if(!shortd.includes(caller.name)){
var newshortd = caller.name +': ' + shortd;
g_form.setValue('short_description', newshortd);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 04:23 PM
Jeff,
Hmm, this is the time to come up with some creativity . In this case i would create a hidden field similar to caller_id and capture the caller_id and add this way in the script.
First suggestion:
var caller = current.caller_id;
var cduplicate = current.caller_id_duplicate.getDisplayValue(); //Duplicate field similar to caller id;
var sd = current.short_description;
if(cduplicate ==' ' )
{
current.short_description = caller +": "+sd;
}
else{
// search for "cduplicate" in "sd"
//replace that part with current "caller_id"
}
Second Suggestion:
Get the short_description and split it by "::" and then replace first part of it with current caller and then add this to short_description
current.short_description = current.caller_id+ " :: "+current.short_description;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 11:39 PM
I would question the need for this simply because the caller id can just be added to any lists. That would serve the same purpose as having the caller id in the short description.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 06:45 AM
That was my thought to my customers. However, they have different list views. AND when they remove caller from the list to get other columns available -- they want to be able to see who the incident is for. This solution solves that issue for them. I gave in to the need of the customer. Sometimes I say no. Saying yes when possible makes the answer of no a bit more tolerable when it happens. I can then remind them of the times I did say yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 10:05 PM
Sometimes we need to say no even if it is possible. It is so easy to break this functionality unless the short description is made readonly. I bet you will end up with incidents where the caller id is repeated and the customer will complain that your solution was not good enough 😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 11:10 PM
Hi Tommy Jensen,
Good Day
One query : In case I am using the call back function and populating the short description. In that scenario I am modifying the short description (consider the field is not read only) what will be impact? - the same will be happen as what you mentioned over there right? [I mean customer will complain].
Thanks,
Priyanka R