when the page is loaded display the short description as incident number+catgory+channel in onload

prasadservi
Giga Contributor
 
5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @prasadservi 

 

You can write a code like this

 

function onLoad() {
// Get the short description from the form
var shortDesc = g_form.getValue('short_description');

g_form.showInfoMessage("Short Description: " + shortDesc);
}

*************************************************************************************************************
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]

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

Sandeep Rajput
Tera Patron
Tera Patron

@prasadservi Here is the script.

 

function onLoad() {
    // Ensure the fields are available
    var number = g_form.getValue('number');
    var category = g_form.getValue('category');
    var channel = g_form.getValue('contact_type'); 

    // Combine fields into one string
    var shortDesc = number + ' - ' + category + ' - ' + channel;

    // Set the short_description field
    g_form.setValue('short_description', shortDesc);
}

@prasadservi Thanks for the upvote, please mark the response an accepted solution if it addressed your question.

J Siva
Tera Sage

Hi @prasadservi 

Try the below script.

Note: The short description value will be updated only on the client side. Make sure to save /update the record if you want to update the short description in the database.

function onLoad() {
    var number = g_form.getValue('number');
    var category = g_form.getDisplayValue('category');
    var contact_type = g_form.getDisplayValue('contact_type'); 

    var shortDescription = number + ' - ' + category + ' - ' + contact_type;

    g_form.setValue('short_description', shortDescription);
}​

 Regards,

Siva