- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 09:23 PM
Hi Team
I want to create a custom Script include and call the logic in Ui action
Which is similar to Ui action available OOB for Incident table CREATE WORK ORDER
Same I want to create for Request table Create work order Ui action
for this Want to build new Custom script include and Ui action.
we can achieve with OOB script include but our Client required Custom Script include
Please can any one guide me with script Please
Please refer attached
Similar I want in Request table with custom solution
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 11:19 PM - edited 02-19-2024 12:21 AM
Hi @Research
Let's try to create your own script include, which extends the OOTB one WorkManagementInitiation. Then you can define your custom functions there.
Sample.
var RequestWorkManagement = Class.create();
RequestWorkManagement.prototype = Object.extendsObject(WorkManagementInitiation, {
initialize: function() {},
/**
* @request {object}: the Request [sc_request] record
*/
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; //request location
workOrder.caller = request.requested_for; //requestor
workOrder.description = request.description;
workOrder.insert();
// redirect to new work order
this._redirectToNewWorkOrder(workOrder, request);
return workOrder;
},
type: 'RequestWorkManagement'
});
And now you can clone the UI Action Create Work Order to the Request table. You may also need to have a look to the function _retrieveWorkOrder to ensure the fields are set properly.
Sample UI Action Script
current.update();
wmu = new RequestWorkManagement();
wmu.createWorkOrderFromRequest(current);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 11:19 PM - edited 02-19-2024 12:21 AM
Hi @Research
Let's try to create your own script include, which extends the OOTB one WorkManagementInitiation. Then you can define your custom functions there.
Sample.
var RequestWorkManagement = Class.create();
RequestWorkManagement.prototype = Object.extendsObject(WorkManagementInitiation, {
initialize: function() {},
/**
* @request {object}: the Request [sc_request] record
*/
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; //request location
workOrder.caller = request.requested_for; //requestor
workOrder.description = request.description;
workOrder.insert();
// redirect to new work order
this._redirectToNewWorkOrder(workOrder, request);
return workOrder;
},
type: 'RequestWorkManagement'
});
And now you can clone the UI Action Create Work Order to the Request table. You may also need to have a look to the function _retrieveWorkOrder to ensure the fields are set properly.
Sample UI Action Script
current.update();
wmu = new RequestWorkManagement();
wmu.createWorkOrderFromRequest(current);
Cheers,
Tai Vu