Create a request from script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2013 03:31 AM
Hi,
we have the Service Catalog, where users can go to create a request for something.
A request is then created with a workflow linked to this request depending on the type of item they order.
We have a tool for booking a room, and we want that this tool creates a request in snow.
I can of course create a request record, but the workflow is not associated with this request.
Is there a way to create a request, with variables and a workflow, from script, like if it was created by a user from the service catalog?
Thanks a lot
rgds
Xavier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 11:18 AM
I know this thread is old (like really old) but you can do what is being asked here using the Service Catalog script API
Use the Cart class.
Use cart.addItem() and pass the sys id for the catalog item you want to generate.
Then add values to your variables using cart.setVariable() just like you would set the values using the UI. Keep in mind any UI policies or client scripts that might manipulate fields based on supplied values.
Then cart.placeOrder() will generate the request and return the id.
This will kick off any workflow associated with the catalog item and the ticket should be well formed, displaying the variables as it would if you completed the catalog item using the UI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 01:18 PM
This is why it's nice to comment on old threads... I was searching for the very same problem today and found the answer thanks to your reply. So thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 09:29 AM
The Cart script include is set to private and can be used in the global scope only. I have to create a Service Request from a scoped app and can't use it.
Setting the Cart script include to be public isn't an option, as we'd be loosing support.
Is there another, similar way to create a Service Request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 02:18 PM
You would use the CartJS API which is scope friendly.
I haven't had an occasion to use it yet so I can't speak to how well it works. Looks a fair bit more complicated than the old Cart API.