How to Create New Custom UI action (work order) for Request FSM work order

Research
Tera Guru

Hi 

 

Can any one guide me how to create UI action (work order) for Service Request

 

We have OOTB UI action (Work Order) for Incident 
Similar I want to create a custom UI action for Request.

Please guide me with steps and logics.

 

Research_0-1699192955094.png

like this I want to enable for Request table 
I created using same logic but its not working

By changing table name

Research_1-1699193065365.png

 

Under script I changed to Request

Its not working and not loading the page

Is there anything missing I need to change any script or logic

 

Research_3-1699193149667.png

 

Please guide me   

Thanks.

 

 

1 ACCEPTED SOLUTION

Clara Lemos
Mega Sage
Mega Sage

Hi @Research ,

 

You need to create a new function on your script include. 

For that, open the 'WorkManagementInitiation' script include ,

After the 'createWorkOrderFromIncident' function,  create a new function as below:

 

 

	createWorkOrderFromRequest: function(request) {
		var workOrder = this._retrieveWorkOrder(true, request, true);
		
		// work order already exists and redirection is already handled
		if (workOrder == null)
			return;
		
		// complete the work order definition and creation 
		workOrder.location = request.location;// here you can add the fields that you'd like to map from the Request to the Work order
		workOrder.caller = request.requested_for;
		workOrder.description = request.description;
		workOrder.insert();
		
		// redirect to new work order
		this._redirectToNewWorkOrder(workOrder, request);
		return workOrder;
	},

 

 

 

After adding the 'createWorkOrderFromRequest' function into the script include, navigate to the UI action table and create a new UI action  in the Request table, calling the function.   

 
Screenshot 2023-11-05 at 17.32.25.png

Add the Condition as per your requirement 🙂 

If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers
 
 
 
 

View solution in original post

3 REPLIES 3

Clara Lemos
Mega Sage
Mega Sage

Hi @Research ,

 

You need to create a new function on your script include. 

For that, open the 'WorkManagementInitiation' script include ,

After the 'createWorkOrderFromIncident' function,  create a new function as below:

 

 

	createWorkOrderFromRequest: function(request) {
		var workOrder = this._retrieveWorkOrder(true, request, true);
		
		// work order already exists and redirection is already handled
		if (workOrder == null)
			return;
		
		// complete the work order definition and creation 
		workOrder.location = request.location;// here you can add the fields that you'd like to map from the Request to the Work order
		workOrder.caller = request.requested_for;
		workOrder.description = request.description;
		workOrder.insert();
		
		// redirect to new work order
		this._redirectToNewWorkOrder(workOrder, request);
		return workOrder;
	},

 

 

 

After adding the 'createWorkOrderFromRequest' function into the script include, navigate to the UI action table and create a new UI action  in the Request table, calling the function.   

 
Screenshot 2023-11-05 at 17.32.25.png

Add the Condition as per your requirement 🙂 

If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers
 
 
 
 

Research
Tera Guru

Hi @Clara Lemos Appreciate for you solution this working as per expected.

For OOTB script include adding function its working 
Can you guide the new script include for so I need to create custom script include instead of using OOTB script and adding function

Because my organization is asking to create new script Include.


we are near to solution can you please guide the new script include to add function only for request work order.

Thanks.

Clara Lemos
Mega Sage
Mega Sage

@Research ,
You can just create a new script include and copy the functions from the OOTB one, in the UI action you should call your new script include instead of the OOTB one