Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Use client script to populate text if field is empty

jasonho
Tera Contributor

Hello,

 

I am trying to create an onload client script to populate the description field with text when the field is not empty.

 

I am trying to use the following script:

 

function onLoad() {

if (g_form.getValue('description' !== ""))

{
return;
}

else

{
g_form.setValue('description','Questions: \n\n 1. System the issue is related to \n 2. What browser \n 3. On VPN/not on VPN \n 4. Reminder to include a screenshot \n 5. Best time/contact number to reach them on for more details');
}
}

 

The script works if the ticket already has text in the description field but the setValue text does not populate when I try to create a new ticket.

 

How can I get the setValue text to populate in the onload script when I create a new ticket?

 

Many thanks

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @jasonho 

Try this script.

 

function onLoad() {

 

if (g_form.getValue('description') != ""){

return;

}else{

g_form.setValue('description','Questions: \n\n 1. System the issue is related to \n 2. What browser \n 3. On VPN/not on VPN \n 4. Reminder to include a screenshot \n 5. Best time/contact number to reach them on for more details');

}

}

 

 

Thanks,
Anvesh

View solution in original post

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @jasonho 

Try this script.

 

function onLoad() {

 

if (g_form.getValue('description') != ""){

return;

}else{

g_form.setValue('description','Questions: \n\n 1. System the issue is related to \n 2. What browser \n 3. On VPN/not on VPN \n 4. Reminder to include a screenshot \n 5. Best time/contact number to reach them on for more details');

}

}

 

 

Thanks,
Anvesh

jasonho
Tera Contributor

Hi Anvesh,

 

The script works. Thank you so much.