- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:26 AM
Hello,
We have created a database view and was wondering if it's possible to concatenate two columns using a script (see below).
If so can this script can also be applied to a report or automated indicator?
- var now_GR = new GlideRecord('u_chg_cab_definition_view');
Solved! Go to Solution.
- Labels:
-
Dashboard
-
Performance Analytics
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 05:36 AM
Hi,
you can make that field as calculated and store the concatenated value
Use advanced view
Something like this; you can use current object and dot walk to whichever field you wish
(function calculatedFieldValue(current) {
// Add your code here
return current.u_cab_meeting + ' ' + current.cab_definition;
})(current);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:34 AM
Hi,
As per my understanding that's not possible
if you wish to do so you will have to create custom field on the table which holds both the fields and concatenate and show that column in database view.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:50 AM
Hi Don,
NO!! you cannot concatenate 2 columns. However there is a possibility to do this :
Example:- You have 3 Fields and Need to add all 3 Strings in a single field while any one of out of 3 fields changes.
I Have a field called "Name" and three fields value needs to be added "Name" field
A). First Name
B). Middle Name
C). Last Name
Name = "First Name" + "Middle Name" + "Last Name"
So IN this condition I have 3 OnChange Client script on each field changes (First Name, Middle Name, Last Name). So any one of the fields will be changed, NAME field will be auto concatenated.
********************************************************************
OnChange Client Scrip_1
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var firstname = g_form.getDisplayValue('u_first_name');
var middlename = g_form.getDisplayValue('u_middle_name');
var lastname = g_form.getDisplayValue('u_last_name');
g_form.setValue('u_name', firstname + ' ' + middlename + ' ' + lastname);
}
Note:- Similar you have to write 2 more Client scripts for other field changes.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:56 AM
This is required for database view and not for form.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 04:07 AM
ok..got it