Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using more performant Schema.describeSObjects method to dynamically get the SObjectType #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions evolve-forms/main/default/classes/DynamicFormsController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public with sharing class DynamicFormsController {
String apiNamesCsv = '';

try {
Schema.FieldSet fieldSet = Schema.getGlobalDescribe()
.get(objectApiName)
Schema.FieldSet fieldSet = getSObjectTypeByApiName
.getDescribe()
.fieldsets.getMap()
.get(fieldSetApiName);
Expand Down Expand Up @@ -286,7 +285,7 @@ public with sharing class DynamicFormsController {
DynamicFormsController.Field[] fieldList = new List<DynamicFormsController.Field>();
Map<String, DynamicFormsController.Field> fieldsToQuery = new Map<String, DynamicFormsController.Field>();

SObjectType schemaType = Schema.getGlobalDescribe().get(sObjectType);
SObjectType schemaType = getSObjectTypeByApiName(sObjectType);
Map<String, SObjectField> fieldMap = schemaType.getDescribe()
.fields.getMap();

Expand Down Expand Up @@ -763,4 +762,8 @@ public with sharing class DynamicFormsController {
];
}
}

private Schema.SObjectType getSObjectTypeByApiName(String sobjectApiName) {
return Schema.describeSObjects(new String[] {sobjectApiName}).get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
-->

<template>
<template if:true={hasFields}>
<template lwc:if={hasFields}>
<div class={boundaryTheme}>
<template if:true={showSpinner}>
<template lwc:if={showSpinner}>
<lightning-spinner size="small"></lightning-spinner>
</template>
<c-dynamic-forms-collapsible-section
Expand All @@ -35,7 +35,7 @@
<div class="slds-form-element__label slds-p-top_xx-small">
{field.label}
</div>
<template if:true={field.helpText}>
<template lwc:if={field.helpText}>
<lightning-helptext
content={field.helpText}
></lightning-helptext>
Expand All @@ -44,7 +44,7 @@
<div
class="slds-form-slds-form-element__static slds-p-bottom_xx-small slds-hyphenate"
>
<template if:true={field.address}>
<template lwc:if={field.address}>
<lightning-formatted-address
city={field.address.city}
country={field.address.country}
Expand All @@ -59,7 +59,7 @@
>
</lightning-formatted-address>
</template>
<template if:true={field.dateTimeValue}
<template lwc:elseif={field.dateTimeValue}
><lightning-formatted-date-time
day={field.dateTimeValue.day}
era={field.dateTimeValue.era}
Expand All @@ -76,7 +76,7 @@
>
</lightning-formatted-date-time>
</template>
<template if:true={field.email}>
<template lwc:elseif={field.email}>
<lightning-formatted-email
hide-icon={field.email.hideIcon}
label={field.email.label}
Expand All @@ -85,14 +85,14 @@
>
</lightning-formatted-email>
</template>
<template if:true={field.location}>
<template lwc:elseif={field.location}>
<lightning-formatted-location
latitude={field.location.latitude}
longitude={field.location.longitude}
>
</lightning-formatted-location>
</template>
<template if:true={field.name}>
<template lwc:elseif={field.name}>
<lightning-formatted-name
first-name={field.name.firstName}
format={field.name.format}
Expand All @@ -104,7 +104,7 @@
>
</lightning-formatted-name>
</template>
<template if:true={field.numberValue}>
<template lwc:elseif={field.numberValue}>
<lightning-formatted-number
currency-code={field.numberValue.currencyCode}
currency-display-as={field.numberValue.currencyDisplayAs}
Expand All @@ -118,34 +118,34 @@
>
</lightning-formatted-number>
</template>
<template if:true={field.phoneNumber}>
<template lwc:elseif={field.phoneNumber}>
<lightning-formatted-phone
disabled={field.phoneNumber.disabled}
tab-index={field.phoneNumber.tabIndex}
value={field.phoneNumber.value}
>
</lightning-formatted-phone>
</template>
<template if:true={field.text}>
<template if:true={field.text.isRich}>
<template lwc:elseif={field.text}>
<template lwc:if={field.text.isRich}>
<lightning-formatted-rich-text
linkify={field.text.linkify}
value={field.text.value}
></lightning-formatted-rich-text>
</template>
<template if:false={field.text.isRich}>
<template lwc:else>
<lightning-formatted-text
linkify={field.text.linkify}
value={field.text.value}
>
</lightning-formatted-text>
</template>
</template>
<template if:true={field.timeValue}>
<template lwc:elseif={field.timeValue}>
<lightning-formatted-time value={field.timeValue.value}>
</lightning-formatted-time>
</template>
<template if:true={field.url}>
<template lwc:elseif={field.url}>
<lightning-formatted-url
label={field.url.label}
tab-index={field.url.tabIndex}
Expand All @@ -155,7 +155,7 @@
>
</lightning-formatted-url>
</template>
<template if:true={field.isBoolean}>
<template lwc:elseif={field.isBoolean}>
<div class="slds-checkbox">
<input type="checkbox" checked={field.booleanValue} />
<span class="slds-checkbox_faux"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
limitations under the License.
-->

<template>
<template if:false={hideLabel}>
<template>
<template lwc:if={hideLabel}>
<slot></slot>
</template>
<template lwc:else>
<div class={sectionClass}>
<div class="slds-section__title">
<button
Expand Down Expand Up @@ -43,7 +46,4 @@
</div>
</div>
</template>
<template if:true={hideLabel}>
<slot></slot>
</template>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@

<template>
<div>
<div style="position: relative; display: block">
<div class="slds-is-relative slds-show">
<section
class="slds-popover slds-popover_panel slds-nubbin_top-left"
style="position: absolute"
class="slds-popover slds-popover_panel slds-nubbin_top-left slds-is-absolute"
role="dialog"
>
<div class="slds-popover__header">
<header class="slds-media slds-media_center slds-m-bottom_small">
<div class="slds-media__body" style="display: contents">
<template if:false={isLookupRecordType}>
<img
src={iconUrl}
style={iconBackgroundColor}
class="iconSizing"
/>
</template>
<template if:true={isLookupRecordType}>
<template lwc:if={isLookupRecordType}>
<lightning-icon
icon-name="standard:record"
alternative-text="Record Type"
title="Record Type"
class="iconSizing"
></lightning-icon>
</template>
<template lwc:else>
<img
src={iconUrl}
style={iconBackgroundColor}
class="iconSizing"
/>
</template>
<h2 class="slds-text-heading_medium slds-hyphenate">
{lookupFieldValue}
</h2>
</div>
</header>
</div>
<template if:false={isLookupUserOrGroupOrRecordType}>
<template lwc:if={isLookupUserOrGroupOrRecordType}></template>
<template lwc:else>
<div class="slds-popover__body lookupHoverBody">
<lightning-record-form
record-id={lookupRecordId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

<template>
<!-- Implementation for bottom of page-pinned button -->
<template if:true={pinToBottom}>
<template lwc:if={pinToBottom}>
<div class="bump"></div>
<div
class="slds-box slds-docked-form-footer slds-theme_default slds-align_absolute-center pinnedFooter"
>
<template if:true={includeCancelButton}>
<template lwc:if={includeCancelButton}>
<lightning-button
variant="neutral"
label="Cancel"
Expand All @@ -43,8 +43,8 @@
</template>

<!-- Implementation for standalone button -->
<template if:false={pinToBottom}>
<template if:true={includeCancelButton}>
<template lwc:else>
<template lwc:if={includeCancelButton}>
<lightning-button
variant="neutral"
label="Cancel"
Expand All @@ -65,7 +65,7 @@
</lightning-button>
</template>

<template if:true={showModal}>
<template lwc:if={showModal}>
<section role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<header class="slds-modal__header">
Expand All @@ -81,7 +81,7 @@
class="slds-modal__content slds-p-around_medium"
id="modal-content-id-1"
>
<template if:true={currentWarnings}>
<template lwc:if={currentWarnings}>
<div class="slds-align_absolute-center">
<ul class="slds-list_dotted" tabindex="0">
<template for:each={currentWarnings} for:item="warning">
Expand Down
Loading