Created
November 19, 2019 15:00
-
-
Save dhaniksahni/b64d3bd86c29a987e13aca99138d4b8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<lightning-card> | |
<div class="divcenter">SalesforceCodex Field's Access Explorer</div> | |
<lightning-layout multiple-rows> | |
<lightning-layout-item size="2" padding="around-small"> | |
<lightning-combobox name="objectName" | |
label="Object" | |
value="" | |
placeholder="Select Object" | |
options={objects} | |
onchange={handleObjectChange} | |
required></lightning-combobox> | |
</lightning-layout-item> | |
<lightning-layout-item size="2" padding="around-small"> | |
<lightning-combobox | |
name="Fields" | |
label="Fields" | |
value="" | |
placeholder="Select Field" | |
options={fields} | |
onchange={handleFieldChange} | |
required | |
></lightning-combobox> | |
</lightning-layout-item> | |
</lightning-layout> | |
</lightning-card> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track, wire} from 'lwc'; | |
import getObjects from '@salesforce/apex/FieldExplorerController.getObjects'; | |
import getFields from '@salesforce/apex/FieldExplorerController.getFields'; | |
export default class FieldAccessExplorer extends LightningElement { | |
@track objects = []; | |
@track fields = []; | |
@wire(getObjects) | |
wiredMethod({ error, data }) { | |
if (data) { | |
this.dataArray = data; | |
let tempArray = []; | |
this.dataArray.forEach(function (element) { | |
var option= | |
{ | |
label:element, | |
value:element | |
}; | |
tempArray.push(option); | |
}); | |
this.objects=tempArray; | |
} else if (error) { | |
this.error = error; | |
} | |
} | |
handleObjectChange(event) | |
{ | |
const selectedOption = event.detail.value; | |
getFields({ objectName: selectedOption}) | |
.then(result => { | |
this.dataArray = result; | |
let tempArray = []; | |
this.dataArray.forEach(function (element) { | |
var option= | |
{ | |
label:element.Label, | |
value:element.Name | |
}; | |
tempArray.push(option); | |
}); | |
this.fields=tempArray; | |
}) | |
.catch(error => { | |
this.error = error; | |
}); | |
} | |
handleFieldChange(){ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="fieldAccessExplorer"> | |
<apiVersion>47.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightningCommunity__Page</target> | |
<target>lightningCommunity__Default</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__AppPage</target> | |
<target>lightning__HomePage</target> | |
</targets> | |
</LightningComponentBundle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment