Configuring PM Plan Web Service
The Preventive Maintenance (PM) Plan module includes a web service for generating PM Plan Details such as PM Schedule Definitions, PM Schedules, and Preventive Maintenance Coverages on a PM Plan during creation. The same web service supports the creation of related records for both time-based and condition-based PM Plans. The mode is controlled by a request parameter; when the flag, request.planType = 'CONDITION' is not provided, the service preserves the existing time-based behavior.
This allows you to automate bulk creation of related records for time-based and condition-based PM Plans.
* 
To create time-based and condition-based PM Plans through this web service, you must first configure time-based and Condition-based PM Plan Templates.
PM Plan Automation Components
The following table lists the methods and parameters required for invoking the PM Plan Details Web service outside of an SFM Transaction. The same methods applies for both time-based and condition-based PM Plans
Entry Points
Entry Point
Class
When to Use
SOAP Webservice
PREV_PMAutomation
External SOAP integrations, middleware, third-party systemscalling Salesforce via SOAP API
Global Apex API
PREV_PMAutomation_API
Internal Apex callers: Triggers, Batch Apex, Queueable,Flows, LWC Apex controllers
Both the entry points expose the following methods, one per scoping mode:
Method Name
Input Parameters
Output Parameters
CreatePMPlanFromAccount
PREV_PMAutomationRequest
PREV_PMAutomationResponse
CreatePMPlanFromLOC
PREV_PMAutomationRequest
PREV_PMAutomationResponse
CreatePMPlanFromSC
PREV_PMAutomationRequest
PREV_PMAutomationResponse
CreatePMPlanFromIB
PREV_PMAutomationRequest
PREV_PMAutomationResponse
Request and Response Structure
The following code provides the sample request/response structure and parameters:
Web service
The following code provides the sample request/response structure and parameters for the Web Service:
 global class PREV_PMAutomationKeyValue{
webservice String key {get;set;}
webservice String value {get;set;
}
global sharing class PREV_PMAutomationRequest
{
webservice list<Strings> pmPlanIdList{get;set;}
webservice String planType{get;set;}
webservice List<SVMXC.PREV_PMAutomation.PREV_PMAutomationKeyValue> additionalParams {get; set;}

}
global class PREV_PMAutomationResponse
{
webservice Boolean success{get;set;}
webservice String message{get;set;}
webservice String messageType{get;set;}
webservice list<PREV_PMAutomationResult> results{get;set;}
}
Global Class PREV_PMAutomationResult
{
webservice String pmPlanId {get;set;}
webservice String errorMessage {get;set;}
webservice Boolean success{get;set;}
}
Global Apex API
The following code provides the sample request/response structure and parameters for the Global Apex API:
global class PREV_PMAutomationKeyValue{
global String key {get;set;}
global String value {get;set;
}
global class PREV_PMAutomationRequest
{
global list<Strings> pmPlanIdList{get;set;}
global String planType{get;set;}
global List<SVMXC.PREV_PMAutomation.PREV_PMAutomationKeyValue> additionalParams {get; set;}

}
global class PREV_PMAutomationResponse
{
global Boolean success{get;set;}
global String message{get;set;}
global String messageType{get;set;}
global list<PREV_PMAutomationResult> results{get;set;}
}
Global Class PREV_PMAutomationResult
{
global String pmPlanId {get;set;}
global String errorMessage {get;set;}
global Boolean success{get;set;}
}
Code Snippet
Web Service
For invoking the PM Plan web service for a time-based PM Plan, use the following sample code snippet:
* 
It is optional to specify request.planType = 'TIME' parameter for the time-based PM Plan.
SVMXC.PREV_PMAutomation.PREV_PMAutomationRequest request = new SVMXC.PREV_PMAutomation.PREV_PMAutomationRequest();
request.pmPlanIdList = new List<String>{'PM Plan SF Id'};
request.planType = 'TIME';
SVMXC.PREV_PMAutomation.createPMPlanFromAccount(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromLOC(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromSC(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromIB(request);
To invoke the same web service for a condition-based PM Plan, set the request.planType flag to Condition. Ensure that the referenced PM Plan IDs use Condition-based PM Plan Templates.
* 
when the flag, request.planType = 'CONDITION' is not provided, the service preserves the existing time-based behavior.
SVMXC.PREV_PMAutomation.PREV_PMAutomationRequest request = new SVMXC.PREV_PMAutomation.PREV_PMAutomationRequest();
request.pmPlanIdList = new List<String>{'PM Plan SF Id'};
request.planType = 'CONDITION';
SVMXC.PREV_PMAutomation.createPMPlanFromAccount(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromLOC(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromSC(request);
//SVMXC.PREV_PMAutomation.createPMPlanFromIB(request);
Global APEX API
For invoking the Global Apex API for a time-based PM Plan, use the following sample code snippet:
* 
It is optional to specify request.planType = 'TIME' parameter for the time-based PM Plan.
SVMXC.PREV_PMAutomation_API.PREV_PMAutomation_APIRequest request = new SVMXC.PREV_PMAutomation_API.PREV_PMAutomation_APIRequest();
request.pmPlanIdList = new List<String>{'PM Plan SF Id'};
request.planType = 'TIME';
SVMXC.PREV_PMAutomation_API.createPMPlanFromAccount(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromLOC(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromSC(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromIB(request);
To invoke the same Global APEX API for a condition-based PM Plan, set the request.planType flag to Condition. Ensure that the referenced PM Plan IDs use Condition-based PM Plan Templates.
* 
when the flag, request.planType = 'CONDITION' is not provided, the service preserves the existing time-based behavior.
SVMXC.PREV_PMAutomation_API.PREV_PMAutomation_APIRequest request = new SVMXC.PREV_PMAutomation_API.PREV_PMAutomation_APIRequest();
request.pmPlanIdList = new List<String>{'PM Plan SF Id'};
request.planType = 'CONDITION';
SVMXC.PREV_PMAutomation_API.createPMPlanFromAccount(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromLOC(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromSC(request);
//SVMXC.PREV_PMAutomation_API.createPMPlanFromIB(request);
* 
If your organization is offering PM Plans for Installed Based, then ensure that the IP records are created before generating PM Plans with them as coverages.
Best Practices
The following table outlines recommended best practices for using the PM automation request effectively.
Best Practice
Description
Using the correct planType value
Always set planType to 'CONDITION' (case-sensitive) when processing condition-based plans.
When the flag, request.planType = 'CONDITION' is not provided, the service preserves the existing time-based behavior.
Validating IB mode prerequisites
Ensure that coverages already exist on the PM Plan before calling createPMPlanFromIB(). If no coverages exist, the plan is skipped.
Handling large volumes efficiently
Use Queueable or Batch Apex to split large plan ID sets across multiple transactions for better scalability.
Retrying safe processing
Rely on built-in behaviour where plans with existing schedules are skipped. Safely retry requests without risk of duplicate processing.
Checking activation settings
Verify the PREV001 > SET002 configuration before processing. If disabled, plans are processed but their status remains unchanged.
Using additionalParams appropriately
Consider additionalParams as a placeholder for future enhancements. Leave it null or omit it, as it has no effect in current functionality.
Avoiding mixed plan types
Do not include both time-based and condition-based plan IDs in a single request. Ensure all plan IDs match the specified planType to prevent individual rejections.
Was this helpful?