Sample Apex Class to Create Case Records for Service Process Requests

When a service process request is submitted, an Apex class invokes the service process connect API to create a case. The apex class extracts the details provided for the service request and assigns these details to the data attributes defined for the service process in Service Process Studio. The Apex class then passes the attributes and their values to the connect API to create a case.

This sample Apex class helps in processing a request related to a transaction dispute. It extracts details, such as the financial account associated with the dispute, dispute type and subtype, transaction description, status, dispute received date, disputed amount, actual amount, approved amount, supporting documents, and the list of disputed transactions. It maps these details to the data attributes that are defined for the service process in Service Process Studio. The Apex class then constructs an API payload using the retrieved data attributes and their extracted values and passes the payload to the connect API to create a case. When a case is created, service catalog request, dispute, and dispute items records are created.

The Apex class retrieves these data attributes. This set contains a mix of complex attributes, which includes attributes of type lookup, text, currency, date, and ListOfMaps. While defining the data attributes, you can choose relevant objects where to store the values for these attributes. For more information, see Considerations for Selecting Base Objects

DATA ATTRIBUTE NAMEDATA ATTRIBUTE API NAMEPARENT DATA ATTRIBUTEDATA TYPE
Account Idaccount_id–Lookup
Assessment Idassessment_id–Lookup
Financial Accountfinancial_account_id–Lookup
Dispute Typedispute_type–Text
Dispute Subtypedispute_subtype–Text
Descriptiondescription–Text
Disputed Transactions Infodisputed_transactions_info–ListOfMaps
Transaction Descriptiontransaction_descriptiondisputed_transactions_infoText
Transaction Identifiertransaction_identifierdisputed_transactions_infoText
Transaction Datetransaction_datedisputed_transactions_infoDate
Transaction Amounttransaction_amountdisputed_transactions_infoCurrency
Statusstatus–Text
Received Datereceived_date–Date
Actual Amountactual_amount–Currency
Disputed Amountdisputed_amount–Currency
Approved Amountapproved_amount–Currency

This is a sample API payload constructed by the Apex class for the Connect API. The payload is based on the values extracted for the data attributes that were defined to capture the data for the service process request.

You can use this sample Apex class as a reference to create an Apex class that suits your transaction dispute service process requirements.