- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2020 08:04 AM
Hi everyone
We have a Request Item designed for requesting that the Servicedesk makes announcements regarding service Windows. It's available on the service portal for anyone in IT.
Now management wants this request item to be a part of the change process. Basically they wish it to be possible to order this RITM by filling out fields on the change form.
What I've done so far:
On the Change form, I've made a new tab meant for the ordering of service Windows announcements ("Bestilling af udmelding"). This contains fields with the same names as the ones on the Request Item. Change Form:
What I do not know how to do is how to create a RITM with these field values included. I assume the best way would be via the change workflow. I could then make an "IF" branching that would be triggered by the first field above not being empty. Or maybe just add a yes/no checkbox which could trigger a specific branch of the flow.
In the workflow I've mad a "create task" box and set the task type to Requested Item:
Now here's the issue. How do I tell it to make a specific task with the values from my fields in the Change? If I chose to get the task values from "Fields" I get no way of designating which fields or which Request Item to create/populate with the values.
If I choose "Values" then I can choose among what looks like every field except the new ones I created.
Thanks for any suggestions.
Solved! Go to Solution.
- Labels:
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2020 05:37 AM
Thanks for all the suggestions everyone. We ended up with the following:
A button at the top op the change form ("Opret udmelding"):
Which triggers a UI action:
The effect of which is, that when you press the button a new tab in the browser windows is opened directly on the Catalog Item. As others mentioned this should be much more future proof and not break when Servicenow is upgraded to future versions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2020 08:16 AM
We personally prefer to follow our catalog item the same way everytime, and as such we essentially create a new request via the Cart API.
gs.include('Cart');
var hddcart = new Cart();
//add your requested item to the cart by sys_id of the catalog item
var item = hddcart.addItem('fb16c1dfacbe2400f9dbe56e438907ad', 1);
//fill in the variables on the request item form
hddcart.setVariable(item,"assignment_group", "2415434abdd30100d74acbcfbb8cd20d");
hddcart.setVariable(item,"requested_for", "6ad5f047ac7e2400f9dbe56e438907ff");
hddcart.setVariable(item,"short_description", "Verify Fax Server Operation");
hddcart.setVariable(item,"description", "Confirm that the Fax over IP server xmediusfax is sending and receiving faxes and sends out email notifications.");
hddcart.setVariable(item,"bus_serv_parent","952b446f6f4835c03da9fd8abb3ee400");
hddcart.setVariable(item,"bus_serv_child","b8549776ccbe24009b1e13c6501b560d");
hddcart.placeOrder();
Essentially you are able to create the exact same request you would if someone were to order out of the catalog. This includes setting variables, triggering workflow, etc. The challenge you're running into is that you're creating a RITM itself - but a RITM should have a Request and Catalog Task with it as well.
So for us we say "Why not just treat it like a normal catalog request?" and develop it the same way, then call with the code above.
Edit: All those variables relate to the name of the variable in the variable set of the catalog item. You are simply setting them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2020 06:43 AM
This sounds much simpler and better than what I was doing.
Where do you use this code? Is it inserted as a script in the workflow which is then triggered by a choice in the change?
Also... what is the actual effect - will a new windows open with you being on the catalogue item on the service portal or...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2020 08:01 AM
It depends when you want it to be created.
It almost sounds like you want someone to be able to fill out some fields on the change request form and then "trigger" it. So to me, that would likely be a UI Action. You could also do a Business Rule but that requires a trigger (like a checkbox stating "Create Announcement RITM").
Putting it in the workflow often means you would have to close off a change task to kick off the script portion - I am not sure if that's what you want.
The code I provided can be used in any server side call, like a Business Rule or a UI Action that does not have the Client field checked off (https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/list-administration/task/t_EditingAUIAction.html).
This code will visually do nothing from an end user point of view. Everything is executed server side and there is no indication in the browser of anything. I mean, you could code in an info message or something but it would not redirect them anywhere. The advantage here is that it just works - no interaction involved beyond clicking a button that says "Generate RITM".
If you want a client-side redirection we can talk about that too. I just assumed from your post that they have provided everything in that form section so no need for further input on the client part.
Hope that makes sense? Any help let me know!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2020 08:20 AM
The easiest way I've found to automate the creation of a RITM based outside the catalog is using the Service Catalog Script API: https://docs.servicenow.com/bundle/newyork-application-development/page/script/server-scripting/refe...
You could add a RunScript activity to your change workflow to do the actual creation.
You'd use something like this example:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('<sys_id_of_catalog_item>');
cart.setVariable(item,'<variable_name>', current.<field>);
//As many of the above lines as you need.
var rc = cart.placeOrder();
//rc.number would have the Req that was created, from which you could then query the RITM.
Hope this helps!
If this was helpful or correct, please be kind and click appropriately!
Michael Jones - Proud member of the CloudPires Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!