The CreatorCon Call for Content is officially open! Get started here.

Get all catalog item variables in client script on service portal

Eli Guttman
Tera Guru

Hi,

Is there a client script function that get all catalog item variables?

Something that can be used in a client script (in service portal also) to get all variables and run a certain command like - set all mandatory / read only.

 

thank you!

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

A common way to do this is to go through all fields like so and set them to Mandatory false:

var fields = g_form.getEditableFields();

for (var x = 0; x < fields.length; x++) {
  g_form.setMandatory(fields[x], false);
}

So you could create this as an onSubmit client script on the catalog item, just for the catalog item (so don't check the other boxes for request item and tasks, etc.). Give that a try?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @Eli Guttman 

This is from several years ago, haha, but I came across it.

If my reply helped guide you Correctly, please mark it as "Accept Solution".

Thanks and I hope all has been well!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!