Remove legacy Appraiser_Deficiency__c object and AppraiserCaseDocGenService
Replaced by Appraiser_Case_Deficiency__c (master-detail, with Reference__c field) and the XML-merge-based CLMDocGenCallout/CLMAdminService stack. Also removes placeholder named credentials CLMNamedCred and CLMuatDownloadNamedCreds superseded by the account-specific credential set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e058dedb82
commit
703fb0c0ba
|
|
@ -1,103 +0,0 @@
|
|||
public with sharing class AppraiserCaseDocGenService {
|
||||
public class DeficiencyDTO {
|
||||
@AuraEnabled public String deficiencyNumber;
|
||||
@AuraEnabled public String description;
|
||||
@AuraEnabled public String resolution;
|
||||
@AuraEnabled public Decimal sortOrder;
|
||||
}
|
||||
|
||||
public class AppraiserCasePayload {
|
||||
@AuraEnabled public Id caseId;
|
||||
@AuraEnabled public String appraiserCaseNumber;
|
||||
@AuraEnabled public Date appraiserFieldReviewDate;
|
||||
@AuraEnabled public String propertyStreet;
|
||||
@AuraEnabled public String propertyCity;
|
||||
@AuraEnabled public String propertyStateProvince;
|
||||
@AuraEnabled public String propertyPostalCode;
|
||||
@AuraEnabled public String propertyCountry;
|
||||
@AuraEnabled public String propertyAddressSingleLine;
|
||||
@AuraEnabled public List<DeficiencyDTO> deficiencies;
|
||||
}
|
||||
|
||||
@AuraEnabled(cacheable=false)
|
||||
public static String buildPayloadJson(Id appraiserCaseId) {
|
||||
return JSON.serialize(buildPayload(appraiserCaseId));
|
||||
}
|
||||
|
||||
public static AppraiserCasePayload buildPayload(Id appraiserCaseId) {
|
||||
Appraiser_Case__c appraiserCase = [
|
||||
SELECT Id,
|
||||
Name,
|
||||
Appraiser_Field_Review_Date__c,
|
||||
Property_Street__c,
|
||||
Property_City__c,
|
||||
Property_State_Province__c,
|
||||
Property_Postal_Code__c,
|
||||
Property_Country__c,
|
||||
(SELECT Id,
|
||||
Name,
|
||||
Deficiency_Number__c,
|
||||
Description__c,
|
||||
Resolution__c,
|
||||
Sort_Order__c
|
||||
FROM Appraiser_Deficiencies__r
|
||||
ORDER BY Sort_Order__c ASC, CreatedDate ASC)
|
||||
FROM Appraiser_Case__c
|
||||
WHERE Id = :appraiserCaseId
|
||||
LIMIT 1
|
||||
];
|
||||
|
||||
AppraiserCasePayload payload = new AppraiserCasePayload();
|
||||
payload.caseId = appraiserCase.Id;
|
||||
payload.appraiserCaseNumber = appraiserCase.Name;
|
||||
payload.appraiserFieldReviewDate = appraiserCase.Appraiser_Field_Review_Date__c;
|
||||
payload.propertyStreet = appraiserCase.Property_Street__c;
|
||||
payload.propertyCity = appraiserCase.Property_City__c;
|
||||
payload.propertyStateProvince = appraiserCase.Property_State_Province__c;
|
||||
payload.propertyPostalCode = appraiserCase.Property_Postal_Code__c;
|
||||
payload.propertyCountry = appraiserCase.Property_Country__c;
|
||||
payload.propertyAddressSingleLine = buildAddress(appraiserCase);
|
||||
payload.deficiencies = new List<DeficiencyDTO>();
|
||||
|
||||
for (Appraiser_Deficiency__c deficiency : appraiserCase.Appraiser_Deficiencies__r) {
|
||||
DeficiencyDTO dto = new DeficiencyDTO();
|
||||
dto.deficiencyNumber = deficiency.Deficiency_Number__c;
|
||||
dto.description = deficiency.Description__c;
|
||||
dto.resolution = deficiency.Resolution__c;
|
||||
dto.sortOrder = deficiency.Sort_Order__c;
|
||||
payload.deficiencies.add(dto);
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
private static String buildAddress(Appraiser_Case__c appraiserCase) {
|
||||
List<String> parts = new List<String>();
|
||||
if (String.isNotBlank(appraiserCase.Property_Street__c)) parts.add(appraiserCase.Property_Street__c);
|
||||
|
||||
List<String> cityLine = new List<String>();
|
||||
if (String.isNotBlank(appraiserCase.Property_City__c)) cityLine.add(appraiserCase.Property_City__c);
|
||||
if (String.isNotBlank(appraiserCase.Property_State_Province__c)) cityLine.add(appraiserCase.Property_State_Province__c);
|
||||
if (String.isNotBlank(appraiserCase.Property_Postal_Code__c)) cityLine.add(appraiserCase.Property_Postal_Code__c);
|
||||
if (!cityLine.isEmpty()) parts.add(String.join(cityLine, ', '));
|
||||
|
||||
if (String.isNotBlank(appraiserCase.Property_Country__c)) parts.add(appraiserCase.Property_Country__c);
|
||||
return String.join(parts, ' | ');
|
||||
}
|
||||
|
||||
@AuraEnabled(cacheable=false)
|
||||
public static Map<String, Object> buildDocGenRequest(Id appraiserCaseId, String templateKey) {
|
||||
AppraiserCasePayload payload = buildPayload(appraiserCaseId);
|
||||
Map<String, Object> requestBody = new Map<String, Object>();
|
||||
requestBody.put('templateKey', templateKey);
|
||||
requestBody.put('recordId', appraiserCaseId);
|
||||
requestBody.put('sourceObject', 'Appraiser_Case__c');
|
||||
requestBody.put('mergeData', payload);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@AuraEnabled(cacheable=false)
|
||||
public static String buildDocGenRequestJson(Id appraiserCaseId, String templateKey) {
|
||||
return JSON.serialize(buildDocGenRequest(appraiserCaseId, templateKey));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>63.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexClass>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
@IsTest
|
||||
private class AppraiserCaseDocGenServiceTest {
|
||||
@IsTest
|
||||
static void buildsPayloadAndRequestJson() {
|
||||
Appraiser_Case__c appraiserCase = new Appraiser_Case__c(
|
||||
Appraiser_Field_Review_Date__c = Date.newInstance(2026, 4, 1),
|
||||
Property_Street__c = '123 Main St',
|
||||
Property_City__c = 'Ottawa',
|
||||
Property_State_Province__c = 'ON',
|
||||
Property_Postal_Code__c = 'K1A 0A1',
|
||||
Property_Country__c = 'Canada'
|
||||
);
|
||||
insert appraiserCase;
|
||||
|
||||
insert new Appraiser_Deficiency__c(
|
||||
Name = 'Deficiency 1',
|
||||
Appraiser_Case__c = appraiserCase.Id,
|
||||
Deficiency_Number__c = '1',
|
||||
Description__c = 'Missing comparable sale analysis',
|
||||
Resolution__c = 'Provide updated comparable sales section',
|
||||
Sort_Order__c = 1
|
||||
);
|
||||
|
||||
Test.startTest();
|
||||
AppraiserCaseDocGenService.AppraiserCasePayload payload = AppraiserCaseDocGenService.buildPayload(appraiserCase.Id);
|
||||
String json = AppraiserCaseDocGenService.buildDocGenRequestJson(appraiserCase.Id, 'APPRAISER_REVIEW_LETTER');
|
||||
Test.stopTest();
|
||||
|
||||
System.assertEquals(appraiserCase.Id, payload.caseId);
|
||||
System.assertEquals('Ottawa', payload.propertyCity);
|
||||
System.assertEquals(1, payload.deficiencies.size());
|
||||
System.assertEquals('1', payload.deficiencies[0].deficiencyNumber);
|
||||
System.assert(json.contains('APPRAISER_REVIEW_LETTER'));
|
||||
System.assert(json.contains('Missing comparable sale analysis'));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>63.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexClass>
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Layout xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<layoutSections>
|
||||
<customLabel>false</customLabel>
|
||||
<detailHeading>true</detailHeading>
|
||||
<editHeading>true</editHeading>
|
||||
<label>Information</label>
|
||||
<layoutColumns>
|
||||
<layoutItems>
|
||||
<behavior>Required</behavior>
|
||||
<field>Name</field>
|
||||
</layoutItems>
|
||||
<layoutItems>
|
||||
<behavior>Required</behavior>
|
||||
<field>Appraiser_Case__c</field>
|
||||
</layoutItems>
|
||||
<layoutItems>
|
||||
<behavior>Edit</behavior>
|
||||
<field>Deficiency_Number__c</field>
|
||||
</layoutItems>
|
||||
</layoutColumns>
|
||||
<layoutColumns>
|
||||
<layoutItems>
|
||||
<behavior>Edit</behavior>
|
||||
<field>Sort_Order__c</field>
|
||||
</layoutItems>
|
||||
</layoutColumns>
|
||||
<style>TwoColumnsTopToBottom</style>
|
||||
</layoutSections>
|
||||
<layoutSections>
|
||||
<customLabel>false</customLabel>
|
||||
<detailHeading>true</detailHeading>
|
||||
<editHeading>true</editHeading>
|
||||
<label>Details</label>
|
||||
<layoutColumns>
|
||||
<layoutItems>
|
||||
<behavior>Edit</behavior>
|
||||
<field>Description__c</field>
|
||||
</layoutItems>
|
||||
</layoutColumns>
|
||||
<layoutColumns>
|
||||
<layoutItems>
|
||||
<behavior>Edit</behavior>
|
||||
<field>Resolution__c</field>
|
||||
</layoutItems>
|
||||
</layoutColumns>
|
||||
<style>TwoColumnsTopToBottom</style>
|
||||
</layoutSections>
|
||||
<showEmailCheckbox>false</showEmailCheckbox>
|
||||
<showHighlightsPanel>true</showHighlightsPanel>
|
||||
<showInteractionLogPanel>false</showInteractionLogPanel>
|
||||
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
|
||||
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
|
||||
</Layout>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<allowMergeFieldsInBody>false</allowMergeFieldsInBody>
|
||||
<allowMergeFieldsInHeader>false</allowMergeFieldsInHeader>
|
||||
<calloutStatus>Enabled</calloutStatus>
|
||||
<generateAuthorizationHeader>true</generateAuthorizationHeader>
|
||||
<label>CLMNamedCred</label>
|
||||
<namedCredentialParameters>
|
||||
<parameterName>Url</parameterName>
|
||||
<parameterType>Url</parameterType>
|
||||
<parameterValue>https://api.s1.us.clm.demo.docusign.net</parameterValue>
|
||||
</namedCredentialParameters>
|
||||
<namedCredentialParameters>
|
||||
<externalCredential>DocusignJWT</externalCredential>
|
||||
<parameterName>ExternalCredential</parameterName>
|
||||
<parameterType>Authentication</parameterType>
|
||||
</namedCredentialParameters>
|
||||
<namedCredentialParameters>
|
||||
<certificate>DocusignJWT</certificate>
|
||||
<parameterName>ClientCertificate</parameterName>
|
||||
<parameterType>ClientCertificate</parameterType>
|
||||
</namedCredentialParameters>
|
||||
<namedCredentialType>SecuredEndpoint</namedCredentialType>
|
||||
</NamedCredential>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<allowMergeFieldsInBody>false</allowMergeFieldsInBody>
|
||||
<allowMergeFieldsInHeader>false</allowMergeFieldsInHeader>
|
||||
<calloutStatus>Enabled</calloutStatus>
|
||||
<generateAuthorizationHeader>true</generateAuthorizationHeader>
|
||||
<label>CLMuatDownloadNamedCreds</label>
|
||||
<namedCredentialParameters>
|
||||
<parameterName>Url</parameterName>
|
||||
<parameterType>Url</parameterType>
|
||||
<parameterValue>https://apidownloaduatna11.springcm.com</parameterValue>
|
||||
</namedCredentialParameters>
|
||||
<namedCredentialParameters>
|
||||
<externalCredential>DocusignJWT</externalCredential>
|
||||
<parameterName>ExternalCredential</parameterName>
|
||||
<parameterType>Authentication</parameterType>
|
||||
</namedCredentialParameters>
|
||||
<namedCredentialType>SecuredEndpoint</namedCredentialType>
|
||||
</NamedCredential>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<actionOverrides>
|
||||
<actionName>New</actionName>
|
||||
<type>Default</type>
|
||||
</actionOverrides>
|
||||
<actionOverrides>
|
||||
<actionName>Edit</actionName>
|
||||
<type>Default</type>
|
||||
</actionOverrides>
|
||||
<actionOverrides>
|
||||
<actionName>View</actionName>
|
||||
<type>Default</type>
|
||||
</actionOverrides>
|
||||
<allowInChatterGroups>false</allowInChatterGroups>
|
||||
<compactLayoutAssignment>SYSTEM</compactLayoutAssignment>
|
||||
<deploymentStatus>Deployed</deploymentStatus>
|
||||
<enableActivities>false</enableActivities>
|
||||
<enableBulkApi>true</enableBulkApi>
|
||||
<enableFeeds>false</enableFeeds>
|
||||
<enableHistory>true</enableHistory>
|
||||
<enableLicensing>false</enableLicensing>
|
||||
<enableReports>true</enableReports>
|
||||
<enableSearch>true</enableSearch>
|
||||
<enableSharing>true</enableSharing>
|
||||
<enableStreamingApi>true</enableStreamingApi>
|
||||
<externalSharingModel>ControlledByParent</externalSharingModel>
|
||||
<label>Appraiser Deficiency</label>
|
||||
<nameField>
|
||||
<label>Appraiser Deficiency Name</label>
|
||||
<type>Text</type>
|
||||
</nameField>
|
||||
<pluralLabel>Appraiser Deficiencies</pluralLabel>
|
||||
<searchLayouts></searchLayouts>
|
||||
<sharingModel>ControlledByParent</sharingModel>
|
||||
<visibility>Public</visibility>
|
||||
</CustomObject>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<fullName>Appraiser_Case__c</fullName>
|
||||
<label>Appraiser Case</label>
|
||||
<referenceTo>Appraiser_Case__c</referenceTo>
|
||||
<relationshipLabel>Appraiser Deficiencies</relationshipLabel>
|
||||
<relationshipName>Appraiser_Deficiencies</relationshipName>
|
||||
<reparentableMasterDetail>false</reparentableMasterDetail>
|
||||
<required>true</required>
|
||||
<trackHistory>false</trackHistory>
|
||||
<type>MasterDetail</type>
|
||||
<writeRequiresMasterRead>false</writeRequiresMasterRead>
|
||||
</CustomField>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<fullName>Deficiency_Number__c</fullName>
|
||||
<label>Deficiency Number</label>
|
||||
<length>50</length>
|
||||
<required>false</required>
|
||||
<trackHistory>true</trackHistory>
|
||||
<type>Text</type>
|
||||
</CustomField>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<fullName>Description__c</fullName>
|
||||
<label>Description</label>
|
||||
<length>32768</length>
|
||||
<required>false</required>
|
||||
<trackHistory>true</trackHistory>
|
||||
<type>LongTextArea</type>
|
||||
<visibleLines>5</visibleLines>
|
||||
</CustomField>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<fullName>Resolution__c</fullName>
|
||||
<label>Resolution</label>
|
||||
<length>32768</length>
|
||||
<required>false</required>
|
||||
<trackHistory>true</trackHistory>
|
||||
<type>LongTextArea</type>
|
||||
<visibleLines>5</visibleLines>
|
||||
</CustomField>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<fullName>Sort_Order__c</fullName>
|
||||
<label>Sort Order</label>
|
||||
<precision>6</precision>
|
||||
<required>false</required>
|
||||
<scale>0</scale>
|
||||
<trackHistory>true</trackHistory>
|
||||
<type>Number</type>
|
||||
</CustomField>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<customObject>true</customObject>
|
||||
<motif>Custom18: Form</motif>
|
||||
</CustomTab>
|
||||
Loading…
Reference in New Issue