Saturday 17 November 2018

                                             Design Attribute In Salesforce:


Community1:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
 
    <aura:attribute name = "Name" type = "String"/>
    <aura:attribute name = "Phone" type = "String" />
    <aura:attribute name = "Position" type ="String"/>
    <p>
        Name: {!v.Name}
    </p>
    <p>
        Number: {!v.Phone}
    </p>
    <p>
        Position: {!v.Position}
    </p>
</aura:component>

Design Attributes:

<design:component  >
   <design:attribute name ="Name" label="Name"></design:attribute>
    <design:attribute name ="Phone" label="Phone Number"></design:attribute>
    <design:attribute name ="Position" label="Position" datasource = "CEO, President, Manager"></design:attribute>
</design:component>


 Design Attribute value  Specification:


If we add label for design attributes,component will change to design attribute name

<design:component label="design Practise" >
   <design:attribute name ="Name" label="Name"></design:attribute>
    <design:attribute name ="Phone" label="Phone Number"></design:attribute>
    <design:attribute name ="Position" label="Position" datasource = "CEO, President, Manager"></design:attribute>
</design:component>




Saturday 10 November 2018


How to find the field data type of particular Object:

In this example,I had taken account as a example

String objType='Account';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(objType);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
system.debug('field map keyset'+fieldMap.keyset());
system.debug('values###'+fieldMap.values());
for (String fieldName: fieldMap.keySet()) {
//for finding name of the field 
String fieldLabel = fieldMap.get(fieldName).getDescribe().getLabel();
 system.debug('fieldLabel>>>>>'+fieldLabel);
//get data types for each fields like string,datetime etc..
Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
    //system.debug('fieldtype>>>'+fielddataType);
    if(fielddataType == Schema.DisplayType.DateTime) {
system.debug('field type*********'+fielddataType);
}
}

Friday 9 November 2018


$Browser in Lightning Component:


The $Browser global value provider returns information about the hardware and operating system of the browser accessing the application.

<aura:component>
    {!$Browser.isTablet}
    {!$Browser.isPhone}
    {!$Browser.isAndroid}
    {!$Browser.formFactor}
</aura:component>

Browser.App
<aura:application extends="force:slds">
    <c:BrowserComponent/>
</aura:application>

I am accessing application through desktop.

Output:
falsefalsefalseDESKTOP


LINK:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_browser_value_provider.htm

Thursday 1 November 2018

How Get record in in lightning component in communities


force:hasRecordId is meant only for the Lightning experience and App builder and not the community builder .

<design:component>
   <design:attribute name="recordId" label="recordId" description="Salesforce Id of the record" />
 </design:component>

Create an attribute mapping to the design variable
<aura:component implements="forceCommunity:availableForAllPageTypes,force:appHostable,flexipage:availableForAllPageTypes">

 <!--ATTRIBUTES DECLARATION -->

 <aura:attribute name="recordId" type="String" default="{!recordId}"/>
   <aura:handler name="init" value="{!this}" action="{!c.getrecord}" />
 </aura:component>
Lets get the Id now in our JS controller
({
   getresults: function(component, event, helper) {
    console.log(component.get("v.recordId"));//print the Id 

  }
})