- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 12:32 PM - edited 07-13-2023 12:45 PM
Hi Community.
Is there any possibility to add two different fields on one field's default value. I have a custom table with Detail [u_detail] field. i want to add [short_description] and [description] on [u_detail] field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 05:56 PM
Hi,
Yes, it is possible to concatenate the values of two different fields and set the result as the default value for another field. In your case, you want to concatenate the values of the [short_description] and [description] fields and set it as the default value for the [u_detail] field in a custom table.
you can use a Business Rule or a UI Policy in ServiceNow.
Please try -
(function executeRule(current, previous) {
// Concatenate the values of short_description and description
var detailValue = current.short_description + ' ' + current.description;
// Set the concatenated value as the default value for u_detail field
current.u_detail = detailValue;
})(current, previous);
create a UI Policy by adding an "Action" to the UI Policy with the following configuration:
- Type: "Set Field Value"
- Field: Select the target field, in this case, [u_detail]
- Value: Use the following script
current.short_description + ' ' + current.description
Mark as correct and helpful if it solved your query.
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 05:56 PM
Hi,
Yes, it is possible to concatenate the values of two different fields and set the result as the default value for another field. In your case, you want to concatenate the values of the [short_description] and [description] fields and set it as the default value for the [u_detail] field in a custom table.
you can use a Business Rule or a UI Policy in ServiceNow.
Please try -
(function executeRule(current, previous) {
// Concatenate the values of short_description and description
var detailValue = current.short_description + ' ' + current.description;
// Set the concatenated value as the default value for u_detail field
current.u_detail = detailValue;
})(current, previous);
create a UI Policy by adding an "Action" to the UI Policy with the following configuration:
- Type: "Set Field Value"
- Field: Select the target field, in this case, [u_detail]
- Value: Use the following script
current.short_description + ' ' + current.description
Mark as correct and helpful if it solved your query.
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 08:58 PM
default value works when form loads and it's a new record
why not set it as calculated field or use before insert BR on that table?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader