Populate Short Description for Catalog Items with Form Variable Value.

JayGervais
Kilo Sage

Hi there, 

We have a catalog item and all records being created contain a generic title (short_description) that was originally added when the item was created. This is problematic because in our list view it has become impossible to easily navigate through the requests. The form to create a request includes form variables including a field for 'What are you requesting? (what_are_you_requestion)' that displays information on the request details page. I have been trying to create a script to populate the Short Description with this variable but have not been able to make it work.

The are some of the things I have tried...

Within the workflow, I added a script to the Activity Properties: Catalog Task:

task.short_description = current.variables.what_are_you_requesting;

I also tried adding a Run Script with the following:

var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id', current.cat_item);
gr.query();
if (gr.next()) {
	gr.short_description = current.variables.what_are_you_requesting;
	gr.update();
}

My last attempt was to create a Business Rule. I tried both async and before insert/update hoping new records could include a title. I have tried a few script variations but this is my most recent:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if (current.name == 'Generic IT Request') {
		current.short_description = current.variables.what_are_you_requesting;
	}

})(current, previous);

I have been struggling to come up with a solution for this and appreciate any advice. Cheers!

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

I'm trying to understand WHAT record...are you trying to change the short description? Because some of your attempts look like you're trying to change the task short description...then others...it's the RITM short description.

If you're trying to change the RITM short description...and this workflow runs on the RITM table...then you should be able to easily change the short description using something like this in a run script activity:

current.short_description = current.variables.what_are_you_requesting.toString();

But all of this is assuming that 1) you're running this workflow on the RITM table and 2) The name of your variables...is correct...so check that.

find_real_file.png

find_real_file.png

find_real_file.png

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


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

View solution in original post

8 REPLIES 8

Allen Andreas
Administrator
Administrator

Hi,

I'm trying to understand WHAT record...are you trying to change the short description? Because some of your attempts look like you're trying to change the task short description...then others...it's the RITM short description.

If you're trying to change the RITM short description...and this workflow runs on the RITM table...then you should be able to easily change the short description using something like this in a run script activity:

current.short_description = current.variables.what_are_you_requesting.toString();

But all of this is assuming that 1) you're running this workflow on the RITM table and 2) The name of your variables...is correct...so check that.

find_real_file.png

find_real_file.png

find_real_file.png

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


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

Thank you so much for this. I was so close to making this work and had tried an almost identical script without the toString method. Cheers!

Hi,

You're welcome. Please mark my reply as Correct, above. Currently, you have marked your own as Correct.

Thanks!


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

Thanks! 🙂


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