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
({ | |
doInit : function(component, event, helper) { | |
var sobject = component.get('v.objName'); | |
var fieldName = component.get('v.fieldName'); | |
var formatText = component.find("fielddata"); | |
if(!fieldName.includes('.')) { | |
formatText.set("v.value",sobject[fieldName]); | |
} | |
else { | |
console.log(sobject[fieldName.split(".")[0]]); |
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
<aura:component > | |
<aura:attribute name="objName" type="String" /> | |
<aura:attribute name="fieldName" type="String" /> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<lightning:formattedText aura:id="fielddata" /> | |
</aura:component> |
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
<aura:application controller="sObjectDetailController" extends="force:slds"> | |
<aura:attribute name="objName" type="String" default='Account'/> | |
<aura:attribute name="sObjects" type="sObject[]"/> | |
<aura:attribute name="fieldNames" type="String[]" default='["Id","Name","Owner.Name"]'/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<div class="slds-m-around_small"> | |
<div class="slds-page-header"> | |
<div class="slds-media"> | |
<div class="slds-media__body"> |
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
<aura:application controller="MapIterationController" extends="force:slds"> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<aura:attribute name="oppAccountList" type="List" /> | |
<div class="slds-m-around_small"> | |
<div class="slds-page-header"> | |
<div class="slds-media"> | |
<div class="slds-media__body"> | |
<div class="slds-box slds-theme_shade"> | |
<p> <h1>Map Iteration in Lightning Component</h1></p> |
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
public class MapIterationController { | |
@AuraEnabled | |
public static Map < String, String > fetchMapData() { | |
Map < String, String > mapOppAccount = new Map < String, String >(); | |
for(Opportunity opp : [SELECT ID, Account.Name, Name FROm Opportunity LIMIT 5]) | |
mapOppAccount.put(opp.Name, opp.Account.Name); | |
return mapOppAccount; | |
} | |
} |
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
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/language/datasets/upload'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
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
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/predict'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
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
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/train'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
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
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/datasets/upload'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); //replace token with your access token | |
req.setHeader('Cache-Control', 'no-cache'); | |
string form64 = ''; | |
form64 += HttpFormBuilder.WriteBoundary(); |
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
HttpRequest req = new HttpRequest(); | |
req.setMethod('GET'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/train/<MODEL ID>'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setTimeout(60*1000); | |
Http h = new Http(); | |
String resp; | |
HttpResponse res = h.send(req); | |
resp = res.getBody(); |