Custom Events Using Custom Webservice
To create custom events, you must first write your own web service classes to create cases, work orders , service requests or records of any other object in your ServiceMax implementation. Then you must associate them with Event Names in the IoT Setup page. These custom events can help you extend the capabilities such that they align with your business processes better.
1. Create a custom Apex web service.
a. The custom web service classes must extend IOTImplInterface class and override its execute method.
b. To apply Installed Product Lookup configuration, IPLookup_IoT() method must be called. This returns the Id of the matching Installed Product record, and it can be used to get and set the appropriate fields in the record being created.
global class <classname> extends SVMXC.IOTImplInterface {
override public Object execute(IoTRequest.ServiceRequestAlert request) {
//add logic here ...
}
}
Given below is an example web service to create a work order of type 'Field Service' with the asset information received. For the asset sending the event request, the corresponding Installed Product record’s Id is also retrieved and set in the Work Order's Component field.
//This is a sample web service that extends the IoTImplInterface class for creating
//a custom IoT implementation. It creates a Field service type work order with the received information
//and sets the asset as the work order's Component
global class CreateFSWO extends SVMXC.IOTImplInterface {
//Execute method should be overridden for custom implementation
override public Object execute(SVMXC.IoTRequest.ServiceRequestAlert request) {
if(request != null && request.Event != null && request.Asset != null){
SVMXC__Service_Order__c newWO = new SVMXC__Service_Order__c();
newWO.SVMXC__Special_Instructions__c = request.Event.Subject;
newWO.SVMXC__Problem_Description__c = request.Event.Description;
newWO.SVMXC__Order_Type__c = 'Field Service';
newWO.SVMXC__Component__c = IPLookup_IoT();
try{
insert newWO;
return newWO.id;
}
catch(Exception err){
return new ErrorMessage('ERR02','Exception', err.getMessage());
}
}
else{
return new ErrorMessage('ERR01','Invalid / empty request', 'Invalid / empty request');
}
}
}
2. Create an event name for the above webservice and associate them using the IoT Setup page. For more inofmration, see IoT Setup.
3. Create the Installed Product Lookup configuration as required using the IoT Setup page. For more inofmration, see IoT Setup.
4. The REST endpoint URI for custom events will be http://<your salesforce org url>/services/apexrest/SVMXC/svmx/rest/IOTServiceIntf/<CustomEventName>/2.0/. The CustomEventName should be same as the Event Name specified in the IoT Setup page.
Was this helpful?