- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 11:41 AM
Hello all,
We have an onChange client script setup - whenever a caller is filled in, the location will be auto-populated on the incident form. But when the impacted user (not mandatory field) is filled in, it overrides the location of the caller and replaces the value with the impacted user's location. However, for eg, if tech by mistake uses the impacted user field and has a location for 'impacted user' on the incident form and then decides just to go with the caller field, the caller's location does not auto-populate and leaves the location as 'blank'. Is there any way to re-populate the value of the caller's field after the impacted user is used and then left blank? I am also pasting the scripts for reference. Any lead would be appreciated.
(BP) Set Location to User :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
if (newValue == '' || newValue == null) {
g_form.setValue('u_location', '');
return;
}
if (!g_form.hasField('u_location'))
return;
var caller = g_form.getReference('u_impacted_user', setLocation);
function setLocation(caller) {
if (caller)
g_form.setValue('u_location', caller.location);
}
}
Impacted User Location :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('u_location', '');
return;
}
if (!g_form.getControl('u_location')) {
return;
}
var caller = g_form.getReference('u_impacted_user', setContactNumber);
}
function setContactNumber(caller) {
if (caller) {
g_form.setValue('u_location', caller.location);
}
}
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 12:45 PM
You can implement via onChange client script. Write below code in impacted user change client script
if (newValue == '') {
var caller = g_form.getReference('caller_id', setContactNumber);
return;
}
if (!g_form.getControl('u_location')) {
return;
}
var caller = g_form.getReference('u_impacted_user', setContactNumber);
function setContactNumber(caller) {
if (caller) {
g_form.setValue('u_location', caller.location);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 11:52 AM
So the scripts will run only on change of field. Work around is change the caller twice when tech wants location as per caller. like change the caller and again select the original caller.
Or you can implement like when impacted user set to empty update the location as caller field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 11:58 AM
(BP) Set Location to User and Impacted User Location :
both the script are same. In both the scripts u_impacted_user location is updated in location field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 12:03 PM
Oops. I just copied and pasted the same script. But yes I confirm we have two different scripts for the caller and impacted user. How can I implement when impacted user set to empty update the location as caller field? Is it going to be through business rule?
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 12:07 PM
You can implement via onChange client script. Write below code in impacted user change client script
if (newValue == '') {
var caller = g_form.getReference('caller_id', setContactNumber);
return;
}
if (!g_form.getControl('u_location')) {
return;
}
var caller = g_form.getReference('u_impacted_user', setContactNumber);
function setContactNumber(caller) {
if (caller) {
g_form.setValue('u_location', caller.location);
}
}
