Service Catalog Variables map to description field on Service Catalog Task

purdue
Kilo Sage

Hello,

I need to map variables to description on Catalog Task but I tried using scripted option but keeps erroring out.  What is the syntax for this.   Any assistance is appreciated.

Screenshot 2024-06-07 at 12.59.48 PM.png

Screenshot 2024-06-07 at 1.06.30 PM.png

1 ACCEPTED SOLUTION

Hi @purdue could you please also check the semicolon at the line 3. I missed it. it should be like below

var desc = [];

 

Let me know if it is working or will find another solution.

View solution in original post

22 REPLIES 22

johnfeist
Mega Sage
Mega Sage

Hi Purdue,

 

I can see a few things that might make things work:

I'm assuming that fd_data is something defined which includes a function 1__get_catalog_variables.  In that case the syntax would be

desc = fd_data.1__get_catalog_variables("requested_for);

If you have global selected for your relevant variables in the item definitions, they will show up on the task automatically.  If you use that, then you can just use current.variables.<variable name> as part of setting desc.

 

You are missing an = after var desc, so nothing will assign.

 

Even with the above corrections, if everything works, your result in desc will only show provide_details_for _your_update because you are redeclaring desc in each statement.  The assignments should look like this

var desc = "Requested for: " + fd_data.1__get_catalog_variables("requested_for);
desc = desc + "Manager" " + fd_data.1__get_catalog_variables(manager");
.
.
.
return desc;

Which will give you the string with the variables and labels. 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

purdue
Kilo Sage

Thanks John for responding.   Unfortunately this did not work.   I was able to get this to stop erroring out but still not getting the results.

var hold = fd_data._1__get_catalog_variables.requested_for;
var desc = "Requested for " + hold;
return desc;
Results
Requested for [object GlideRecord]

Hi purdue,

Please make this little change:

var hold = fd_data._1__get_catalog_variables.requested_for.getDisplayValue();

It looks like requested_for is a reference.  If that's the case, you need to get the display value.  If it's a more complex object, you will need to extract the property within it that you need.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Requested for is fine the issue is for select box variables.   Without custom action you cannot get the display value.