9 Replies · Latest reply on Dec 7, 2017 1:51 PM by Brendan Halliday

    Automatically consuming a consumable via Request

      I would like a consumable item be consumed and assigned automatically to the user when the hardware request (RITM) has been fulfilled and closed. Also I would like to reference that RITM record to that consumed record. Is there something built in OOB that I can configure to make this happen or does this require a bit of coding and customization on the catalog item?

       

      Right now, we would have to manually consume the item once the RITM has been fulfilled and closed.

       

      Thanks in advanced!

        • Re: Automatically consuming a consumable via Request
          Ben Sweetser

          Hi Genesis,

           

          A couple quick questions for you here:

          • Did you create the Catalog Item from the Consumable Model? This is important to leverage existing stock.
          • Are you using the Procurement plugin in ServiceNow? This will allow you to identify that you want to use existing stock or order more of an item (both consumables and hardware) when you source the item.

          If you have these configured, then the item should be consumed when it is fulfilled.

           

          Ben

          --------------------
          Ben Sweetser, Principal Business Process Consultant
          ServiceNow

            • Re: Automatically consuming a consumable via Request
              Genesis Layco

              Hi Ben,

               

              I did create a Product Model record under the consumable model, then a Vendor Catalog Item, and published it to the Hardware Catalog in our Service Catalog. Then I added the consumable stock in the stockroom for that item.

               

              Procurement plugin? I don't think we are using this at the moment. Currently, our workflow for the inventory check, procurement, and delivery is a manual check via tasks. Would I need to modify my workflows in order to use the procurement plugin to automatically check for inventory and auto consume when fulfilled?

               

              -Genesis

            • Re: Automatically consuming a consumable via Request
              Teri Bobst

              Hi Genesis, I am trying to something very similar and was wondering if you found a solution?

               

              bsweetser

               

              Hi Ben, I understand that the procurement plug-in can facilitate the consumption of a consumable and I would have gone that route if we had been using procurement when our WF's were first created. Since we were not, I would like to be able to write a RunScript in the workflow that Consumes the Consumable once it has been deployed. Do you have any ideas where I could find some example code to do this? Instead of worrying about consuming it, should I just write the script to reduce the current consumable quantity?

               

              Thanks,

              Teri

                • Re: Automatically consuming a consumable via Request
                  Ben Sweetser

                  Hi Teri,

                  Tracing this through the Consume UI Action, you find it opens a UI Page called consume_a_consumable. This is what prompts for the quantity to consume and the user or asset to consume against. In the Processing script of that UI page, it does this to split out the consumed item:

                   

                  var new_sys_id = new Consumables().splitForeground(consumable, qty, '10', '', asset, '', '', user);

                  }

                   

                  Consumables here is a Script Include you can leverage in your code to do the work. The definition of splitForeground in the Script Include is:

                   

                  splitForeground : function(sys_id, qty, status, substatus, asset, stockroom, location, assigned_to)

                   

                  • sys_id - the SysID of the In stock consumable from which you are consuming some quantity
                  • qty - the quantity to consume
                  • status - 10 is consumed
                  • substatus - leave blank, consumed has no substate
                  • asset - the asset to consume against - this becomes the parent of the consumed item
                  • stockroom - leave blank - because this function is used in other places, such as splitting some quantity to a different location, it provides for other details
                  • location - leave blank - same as stockroom
                  • user - the user to which the consumed item should be associated - if it is associated to an asset, you can leave this blank

                   

                  Good luck, Teri! I hope this helps!

                  --------------------
                  Ben Sweetser, Principal Business Process Consultant
                  ServiceNow