How to Auto-populate description field value by using script

mania
Tera Contributor

Hi,

 

I have changed Description field is String to HTML type, But i need to know how to Auto-populate description field value by using script from catalog item (request form).

 

Can you please help me. It will helpful.

mania_0-1700128301661.png

Thanks in Advance!

6 REPLIES 6

Kavita Bhojane2
Tera Expert

Hi @mania ,

 

You can set the description in the workflow/flow:

For workflow you can use run script as below:

 

current.description = "Whatever description you want to set "+current.number;

 

In flow designer: You can use 'Update Record' action as below:

Screenshot 2023-11-16 at 4.06.13 PM.png

 

Please mark my answer correct and helpful, if you find it useful.

 

Thanks,

Kavita Bhojane

Dr Atul G- LNG
Tera Patron
Tera Patron

https://www.servicenow.com/community/itsm-forum/i-want-the-short-description-field-to-get-autopopula...

https://www.servicenow.com/community/itsm-forum/populate-the-task-description-field/m-p/439026

https://www.servicenow.com/community/developer-articles/how-to-populate-the-short-description-of-a-t...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Anand Kumar P
Giga Patron
Giga Patron

Hi @mania ,

I create before insert update business rule and used below script 

AnandKumarP_1-1700132781563.png

(function executeRule(current, previous /*null when async*/) {

	var body = '';

body += '<p>Short Description: ' + current.getDisplayValue('short_description') + '</p>';//your case you can use =var html_text = current.variables.<Variable Name>;
gs.addInfoMessage(body);

current.u_html_field = body;
current.update();

})(current, previous);



AnandKumarP_0-1700132756507.png

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

 

@Anand Kumar P 

 

I tried your code but not getting popup from record producer form to incident form.

Can you please suggest me.

 

Thanks!

Mania