Initialize Repository
This commit is contained in:
commit
2622f14385
20 files changed
+455
No files matched your search
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"plugins": ["@salesforce/eslint-plugin-aura"],
|
||||
"extends": ["plugin:@salesforce/eslint-plugin-aura/recommended", "prettier"],
|
||||
"rules": {
|
||||
"func-names": "off",
|
||||
"vars-on-top": "off",
|
||||
"no-unused-expressions": "off"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @description This service exposes methods that contain logic to make cloning an opportunity
|
||||
* much easier and more functional.
|
||||
* @author Cloud Performer Inc. <cgary@cloudperformer.com>
|
||||
* @version 1.0
|
||||
* @group Opportunity Cloning
|
||||
* @history 2021-04-02 - CJG - Created
|
||||
*/
|
||||
public with sharing class OpportunityCloneService {
|
||||
/**
|
||||
* @description exception class that is thrown when something happens in the opportunity
|
||||
* clonde process.
|
||||
*/
|
||||
public class CloneException extends System.Exception {}
|
||||
public static Map<String,Schema.DescribeSObjectResult> opportunityChildrenMap;
|
||||
static {
|
||||
List<Schema.ChildRelationship> childRelationshipList =
|
||||
Schema.Opportunity.getSObjectType().getDescribe().getChildRelationships();
|
||||
opportunityChildrenMap = new Map<String, Schema.DescribeSObjectResult>();
|
||||
for(Schema.ChildRelationship childRel:childRelationshipList) {
|
||||
Schema.DescribeSObjectResult childObjRes = childRel.getChildSObject().getDescribe();
|
||||
opportunityChildrenMap.put(childObjRes.getName(),childObjRes);
|
||||
}
|
||||
}
|
||||
|
||||
@AuraEnabled(cacheable=true)
|
||||
public static List<String> ObtainOpporunityChildRelationships(){
|
||||
return new List<String>(opportunityChildrenMap.keySet());
|
||||
}
|
||||
|
||||
public static String ObtainQueryStringForOppAndChildren(Id oppRecordId, List<String> relationships) {
|
||||
String queryString = 'SELECT ';
|
||||
queryString += String.join(ObtainFieldsForObject('Opportunity'),',');
|
||||
List<String> subqueryList = new List<String>();
|
||||
for(String relationship:relationships){
|
||||
Schema.DescribeSObjectResult childObject = opportunityChildrenMap.get(relationship);
|
||||
String childQueryString = '(SELECT ' + String.join(ObtainFieldsForObject(childObject.getName()),',') + ' FROM ';
|
||||
childQueryString += relationship + ')';
|
||||
subqueryList.add(childQueryString);
|
||||
}
|
||||
queryString += ', ' + String.join(subqueryList,',') + 'FROM Opportunity WHERE Id =\'' + oppRecordId + '\'';
|
||||
|
||||
return queryString;
|
||||
}
|
||||
/**
|
||||
* @description this method is responsible for getting the list of fields for a particular object
|
||||
*/
|
||||
private static List<String> ObtainFieldsForObject(String objectName) {
|
||||
List<String> fieldNameList;
|
||||
List<String> objectListToDescribe = new List<String>{objectName};
|
||||
List<Schema.DescribeSObjectResult> describeItem = System.Schema.describeSObjects(objectListToDescribe);
|
||||
if(describeItem.isEmpty()) {
|
||||
throw new OpportunityCloneService.CloneException('Could not find info for ' + objectName + '.');
|
||||
}
|
||||
Map<String, Schema.SObjectField> fieldSObjectMapping = describeItem[0].fields.getMap();
|
||||
fieldNameList = new List<String>();
|
||||
for(Schema.SObjectField fieldToken:fieldSObjectMapping.values()) {
|
||||
Schema.DescribeFieldResult fieldTokenDescribe = fieldToken.getDescribe();
|
||||
if(fieldTokenDescribe.isCreateable() && fieldTokenDescribe.isUpdateable()) {
|
||||
fieldNameList.add(fieldTokenDescribe.getName());
|
||||
}
|
||||
}
|
||||
return fieldNameList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>51.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexClass>
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": ["@salesforce/eslint-config-lwc/recommended", "prettier"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.test.js"],
|
||||
"rules": {
|
||||
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
@@ -0,0 +1,3 @@
|
||||
import { LightningElement } from 'lwc';
|
||||
|
||||
export default class OpportunityCustomClone extends LightningElement {}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>51.0</apiVersion>
|
||||
<isExposed>false</isExposed>
|
||||
</LightningComponentBundle>
|
||||
Reference in new issue
Block a user