Activity Forums Salesforce® Discussions How to access cross object fields in lightning:datatable?

  • Parul

    Member
    August 30, 2018 at 4:31 pm

    Hello Prachi,

    Salesforce approval process is an automated process and your organization can use to approve records in Salesforce, An approval process is combination of steps for a record to be approved and person has to approve it each step.A step can apply to all the records to that object or just record that meets the certain criteria. An approval process also specifies the actions to take when a record is approved, rejected, recalled, or first submitted for approval.

     

    Thanks.

  • shariq

    Member
    September 15, 2018 at 1:40 am

    Hi,

    I am sharing you the code for data table, it may give you a little help -

    Component - 

    <aura:component>
    <!-- Imports -->
    <aura:import library="lightningcomponentdemo:mockdataFaker" property="mockdataLibrary"/>

    <!-- attributes -->
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>

    <!-- handlers-->
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>

    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
    <lightning:datatable
    keyField="id"
    data="{! v.data }"
    columns="{! v.columns }"
    hideCheckboxColumn="true"/>
    </div>
    </aura:component>

    Controller - 

    ({
    init: function (cmp, event, helper) {
    cmp.set('v.columns', [
    {label: 'Opportunity name', fieldName: 'opportunityName', type: 'text'},
    {label: 'Account name', fieldName: 'accountName', type: 'text'},
    {label: 'Close date', fieldName: 'closeDate', type: 'date'},
    {label: 'Confidence', fieldName: 'confidence', type: 'percentage'},
    {label: 'Amount', fieldName: 'amount', type: 'currency', typeAttributes: { currencyCode: 'EUR', maximumSignificantDigits: 5}},
    {label: 'Contact Email', fieldName: 'contact', type: 'email'},
    {label: 'Contact Phone', fieldName: 'phone', type: 'phone'},
    {label: 'Website', fieldName: 'website', type: 'url', typeAttributes: { target: '_self'}},
    {label: 'Address', fieldName: 'address', type: 'location'}
    ]);

    var fetchData = {
    opportunityName: "company.companyName",
    accountName : "name.findName",
    closeDate : "date.future",
    amount : "finance.amount",
    contact: "internet.email",
    phone : "phone.phoneNumber",
    website : "internet.url",
    status : {type : "helpers.randomize", values : [ 'Pending', 'Approved', 'Complete', 'Closed' ] },
    actionLabel : {type : "helpers.randomize", values : [ 'Approve', 'Complete', 'Close', 'Closed' ]},
    confidenceDeltaIcon : {type : "helpers.randomize", values : [ 'utility:up', 'utility:down' ]}
    };

    helper.fetchData(cmp,fetchData, 10);
    }
    })

    Helper - 

    ({
    fetchData: function (cmp, fetchData, numberOfRecords) {
    var dataPromise,
    latitude,
    longitude,
    fakerLib = this.mockdataLibrary.getFakerLib();

    fetchData.address = {type : function () {
    return {
    latitude : fakerLib.address.latitude(),
    longitude : fakerLib.address.longitude()
    }
    }};

    fetchData.confidence = { type : function () {
    return fakerLib.random.number(100) + "%"
    }};

    dataPromise = this.mockdataLibrary.lightningMockDataFaker(fetchData,numberOfRecords);
    dataPromise.then(function(results) {
    cmp.set('v.data', results);
    });
    }
    })

    Hope this helps.

  • Dave

    Member
    March 20, 2020 at 9:00 am

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos