Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Append to the short description via client script

Jason Stephens
Kilo Guru

I would like to append text to the current "short description" of a task from a client script. Below is what I have:

function onSubmit() {
var action = g_form.getActionName();
var task_state = g_form.getValue('state');
var task_sd = g_form.getValue('short_description');

if ((action == 'close_task') && (task_sd=='PC or Laptop Replacement')) {

var return_answer = confirm('Click OK If This User Received MS Office 2010. Otherwise Click "Cancel".');
if (return_answer==true){
//what do we do here?
//gsftSubmit(gel('close_task'));
g_form.setValue('short_description', "'task_sd - Office Installed'");

When I use this I get the literal value of the last line and not the value of the sd_task variable. I've tried a few different combinations of parentheses and "+"'s, but I can't get it to use the current short description plus my new text of " - Office Installed". What am I doing wrong?

Jason

3 REPLIES 3

DubeyN
Mega Expert

Did you try :

g_form.setValue('short_description', task_sd +' - Office Installed');

ND


mamann
Mega Guru

This should work better

function onSubmit() {
var action = g_form.getActionName(),
task_state = g_form.getValue('state'),
task_sd = g_form.getValue('short_description'),
new_shortdesc;

if ((action == 'close_task') && (task_sd=='PC or Laptop Replacement')) {

var return_answer = confirm('Click OK If This User Received MS Office 2010. Otherwise Click "Cancel".');
if (return_answer){
//what do we do here?
//gsftSubmit(gel('close_task'));
new_shortdesc = task_sd + " - Office Installed";
g_form.setValue('short_description', new_shortdesc);


Jason Stephens
Kilo Guru

Thank you both! That got it.

Jason