Can I create a Work Order from a RITM/SCTASK Record?

MRPack
Tera Contributor

Hi Team,

 

Is there a way I can create a Work Order by clicking on the title Bar of a RITM or SCTASK and then clicking on it as an option? It would be similar to how it is with a Problem record like in the screenshot.
MRPack_0-1711719886144.png
Also I would like to take some of the information in the RITM/SCTASK and use it auto-populate some of the fields of the Work Order (like for example the description, short-description, and configuration item). What would be the best way to do this?

Thanks in advance

 

 

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

Hi @MRPack ,

 

OOB is not available but you can make it very easily.

Follow below steps.

  1. Create New ui action called  "Create Work Order" on RITM and SC_TASK table. 
  2. In Script put below code.

 

 

current.update(); 
wmu = new WorkManagementInitiation(); 
wmu.createWorkOrderFromRitm(current);

 

 

  • Open script include "WorkManagementInitiation".
  • Add new function like below.

 

 

createWorkOrderFromRitm: function(ritm) {
        var workOrder = this._retrieveWorkOrder(true, ritm, true);
       
        // work order already exists and redirection is already handled
        if (workOrder == null)
            return;
       
        // complete the work order definition and creation
        workOrder.location = ritm.short_description;
        workOrder.description = ritm.description;
        workOrder.insert();
     
        // redirect to new work order
        this._redirectToNewWorkOrder(workOrder, ritm);
        return workOrder;
    },

 

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

View solution in original post

3 REPLIES 3

Anonymous_guy
Tera Expert

HI @MRPack ,

Have you managed to find a solution to this using OOB configurations?

Runjay Patel
Giga Sage

Hi @MRPack ,

 

OOB is not available but you can make it very easily.

Follow below steps.

  1. Create New ui action called  "Create Work Order" on RITM and SC_TASK table. 
  2. In Script put below code.

 

 

current.update(); 
wmu = new WorkManagementInitiation(); 
wmu.createWorkOrderFromRitm(current);

 

 

  • Open script include "WorkManagementInitiation".
  • Add new function like below.

 

 

createWorkOrderFromRitm: function(ritm) {
        var workOrder = this._retrieveWorkOrder(true, ritm, true);
       
        // work order already exists and redirection is already handled
        if (workOrder == null)
            return;
       
        // complete the work order definition and creation
        workOrder.location = ritm.short_description;
        workOrder.description = ritm.description;
        workOrder.insert();
     
        // redirect to new work order
        this._redirectToNewWorkOrder(workOrder, ritm);
        return workOrder;
    },

 

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

MRPack
Tera Contributor

Thanks @Runjay Patel ,

 

This solution works for me as I am able to create the UI Action and Scripts needed for it.