We have to populate short description based upon the Check box variables.

Sofiya Perumal
Tera Expert

Hi Experts,

We have to populate short description based upon the Check box variables. For eg. we have a catalog item for choosing assets which has options as check box latop, macbook, pc. if the select pc in the task short description it should appear as Asset- laptop if the user selects macbook the task short description should have Asset-macbook. How to acheive this ?

 

Regards,

Sofi

2 REPLIES 2

Ahmmed Ali
Mega Sage

Hello @Sofiya Perumal 

 

You can write below script in create catalog task activity:

 

var short_desc = "Asset";

if(current.variables.laptop == "true"){

short_desc += " - Laptop";

}

else if(current.variables.macbook== "true"){

short_desc += " - Macbook";

}

else if(current.variables.pc== "true"){

short_desc += " - PC";

}

task.short_description = short_desc;

 

 

Note: replace variables names as per your configuration in bolded place.

 

Thanks,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Amit Gujarathi
Giga Sage
Giga Sage

HI @Sofiya Perumal ,
I trust you are doing great.

you can follow these steps:

  1. Create a new catalog item or open the existing one for choosing assets.
  2. Add checkbox variables for laptop, macbook, and pc options to the catalog item form.
  3. Edit the associated catalog task form to include the short description field.
  4. Write a script to update the short description based on the selected checkbox variables.

Here's an example script that you can use in the "Client Script" section of the catalog task form:

function onChangeCheckbox() {
  var shortDesc = 'Asset-';

  // Get the values of the checkbox variables
  var laptopChecked = g_form.getValue('laptop');
  var macbookChecked = g_form.getValue('macbook');
  var pcChecked = g_form.getValue('pc');

  // Check which checkboxes are selected and append their names to the short description
  if (laptopChecked)
    shortDesc += 'laptop';
  else if (macbookChecked)
    shortDesc += 'macbook';
  else if (pcChecked)
    shortDesc += 'pc';

  // Update the short description field on the catalog task form
  g_form.setValue('short_description', shortDesc);
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi