Scripting with catalog variables on tasks (sc_item_option_mtom) table

nmartinez
Kilo Contributor

I am familiar with accessing [sc_item_option] and [sc_item_option_mtom] to query, modify and even create new catalog variables for request items via scripting; however I am trying to figure out how to associate catalog variables with newly created catalog tasks via scripting in the same fashion that it is done via the visual workflow.

I assume that there must be a related table that connects the catalog variables to the catalog task and then not unlike [sc_item_option_mtom] that would reference the catalog task's sys_id and the [sc_item_option] record. If there is such a table it does not have the "mtom" in the table's name. My second guess was that it would be either a script include or a business rule that is dynamically associating the variables to the catalog tasks. However I've yet to find any scripts that perform this function.

If anyone knows how to accomplish this, I would appreciate some help.

23 REPLIES 23

TJW2
Mega Guru

The variables are associated with the RITM not the sc_task. On the sc_item_option_mtom table the Parent reference is to the Request Item.


nmartinez
Kilo Contributor

Thank you Terri. I understand that relationship on the mtom table.

What I am trying to do however is create a Catalog Task via a client script and have the catalog variables for the parent Request Item display on said child Catalog Task.

In the visual workflow editor, there is an Activity for Catalog Task. On that activity there is a slush bucket were you can select which catalog variables from the parent Request Item should carry over to the child task. I would like to replicate this function via scripting.


TJW2
Mega Guru

Ah, interesting. If the variables are to show on ALL tasks, you can mark the variables as 'Global', instead of using the slushbucket.


nmartinez
Kilo Contributor

That's my problem; the trick is I only want to show specific catalog variables based on what options the user selected on the Request Item.

I'll explain what I am doing via scripting.

I have a Catalog Item with a slush bucket that contains a list of application they can request access for. Based on what options they select, additional catalog variables are displayed and/or become required.

On my workflow for the Request Item, I have a Run Script activity that takes the slush bucket, dumps the contents into an array then creates a task for every application they selected. This could generate one task, it could generate fifty. It's all based on what the user selected. Work Notes, Short Description, CMBDI are all dynamic based on selected applications.

Now presently I scan the mtom tables, and output the required catalog variables into the work_notes field. But I don't like that, it doesn't look clean.

So that's why I am trying to get the variables to show on the task as they would if I added them via the activity.