Apply Two different fields on Default Value

Balbir_Singh
Tera Expert

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.

1 ACCEPTED SOLUTION

Tushar
Kilo Sage
Kilo Sage

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

View solution in original post

2 REPLIES 2

Tushar
Kilo Sage
Kilo Sage

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Balbir_Singh 

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?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader