We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Order guides for ServiceNow HRSD

gejoom
Tera Contributor

Hello,

I created an order guide for HRSD, but I'm stumbling on an issue after requesting. It doesn't redirect to the record which I just created. I understand this is due to the widget SC Order Guide OOB only being coded for RITMS (I think). I guess I need to adapt client controller and the server script to get the result I want.

Did anyone ever do this type of adaptation?

Btw: we are already using a copy of the sc order guide widget to remove the price column etc.

1 REPLY 1

matrat5114
Tera Contributor

You would basically be creating a new widget from scratch if you wanted the same functionality as the sc_order_status widget, we just went through this same thing as we are now using order guides on HR Cases, here is what we did, which I think is simpler, a fair bit quicker & keeps it more OOTB:

 

  1.  Add a new boolean field to the sn_hr_core_case table. matrat5114_0-1771478320976.png

     

  2.  In your order guide add a new variable boolean that is always set to true, have cascade variables on. matrat5114_1-1771478398169.pngmatrat5114_2-1771478516813.png

     

     

  3. On each of your record producers that are part of the order guide create a boolean variable of the same name, hide it and map it to the custom field you just created on the sn_hr_core_case table. matrat5114_3-1771478674809.pngmatrat5114_4-1771478782029.png

     

     

  4. This new variable will now only be populated when these producers are ordered as part of an order guide.
  5. Create a new record producer, this is going to be your parent (sc_request) that will hold all of the child cases that are part of the order guide, make sure to tick on "no search" and to add your order guide variable and requested for so these cascade down from the order guide. matrat5114_5-1771479050119.pngmatrat5114_6-1771479115577.png

     

  6. Configure a new HR Service for this record producer (not going to go through these steps as it's straight forward) but configure to your needs along with your template and link it with your record producer.
  7. Create a flow with the following steps:  
    - Trigger off of your HR Service you just created.
    - Wait 10 seconds for the record producers to create the records.
    - Lookup the created records using your is order guide field, hr service and any other conditions you want to add.
    - Error handling if no records are found.
    - For each record update the "Parent" field, we are using the task table as this relates to all our HR tables custom or not, use one that suits you. 

     

    matrat5114_8-1771480256783.pngmatrat5114_9-1771480278704.pngmatrat5114_10-1771480326584.pngmatrat5114_11-1771480381856.png
  8. For record keeping you should change your HR Service fulfillment type to "Flow" and add the flow there (this field doesn't trigger anything, it just helps the next developer that comes along find your work, so be kind :))

  9.  

    This takes care of everything on the backend and your cases will now be linked to the parent case via the OOTB "Parent" field, we had the "Child Cases" related list already down the bottom of our cases and I'm pretty sure this is OOTB, if not setup the related list. 

    matrat5114_12-1771480663106.png

     

  10. Now to the front end, setup a new page on your portal (not going to go through all the steps and plenty of video guides out there) but the main bit you have to do here is add the OOTB simple list widget, you can also add anything else you feel is good for the page, this will be the page the end user will see when they submit your order guide so we also opted for a bit of HTML to show that up the top. 

    matrat5114_13-1771481175701.png

     

  11. Open up your custom page and ctrl right click on the simple list widget and click on "Instance Options", here is where the magic happens, add sn_hr_core_case as the table, your filter we opted for this 

active=true^opened_atONLast minute@javascript:gs.beginningOfLastMinute()@javascript:gs.endOfLastMinute()^ORopened_atONCurrent minute@javascript:gs.beginningOfCurrentMinute()@javascript:gs.endOfCurrentMinute()^opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^u_is_order_guide=true

 what you want it to display in from the fields, linking behavior and anything else you want, which will look something like below when done. 

matrat5114_14-1771481565053.pngmatrat5114_15-1771481599000.pngmatrat5114_16-1771481621180.png

12. We now need to redirect to this page after the user submits, the widget that does this is SC Order Guide you need to clone the widget, go into the client controller and search for 

'id=requests&is_new_order=true' (was line 902 on our version) , this is what is routing to the incorrect page when you submit an order guide on another table, comment out the line and add your new custom page e.g. id=your_page_name&is_new_order=true, your cloned widget should now look like this below matrat5114_17-1771482294624.png

13. Almost there! Go to the default order guide page sc_cat_item_guide  and edit it in page designer, remove the default widget  SC Order Guide and add your custom one in it's place 

 

matrat5114_18-1771482811279.png

14. Job done from that side of things! The My Requests widget won't show child tasks as a default behavior so only the parent case will show, as a nice to have we added a "Linked Requests" tab to the ticket view so that users can see exactly what's going on, again plenty of video's out there on how to achieve this but it looks like below 

matrat5114_19-1771483171837.png

 

Hope this is helpful and happy to answer questions if I've missed anything out as there are quite a few steps, I believe this to be a better way of doing instead of recreating the whole widget from scratch.