0

Following up on the provided example from documentation - Create Components for Lightning for Outlook (Beta), I am able to display the selecetd email's data in html form, but when I try to read the same variables in INIT JS controller method, I get undefined/null values.

sampleOutlookComponent.cmp

<aura:component implements="clients:availableForMailAppAppPage,clients:hasItemContext">

    <aura:attribute name="source" type="String" access="global" />
    <aura:attribute name="people" type="Object" access="global" />
    <aura:attribute name="subject" type="String" access="global" />

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

    <div id="content">
        <h1><b>Email subject</b></h1>
        <span id="subject">{!v.subject}</span>

        <h1>To:</h1>
        <aura:iteration items="{!v.people.to}" var="to">
            {!to.name} - {!to.email} <br/>
        </aura:iteration>

        <h1>From:</h1>
        {!v.people.from.name} - {!v.people.from.email}

        <h1>CC:</h1>
        <aura:iteration items="{!v.people.cc}" var="cc">
            {!cc.name} - {!cc.email} <br/>
        </aura:iteration>

        <span class="greeting">{!v.greeting}</span>, {!v.subject}!
    </div>
</aura:component>

sampleOutlookComponentController.js

({
    doInit : function(component, event, helper) {
        var sc = component.get('v.source');
        var sb = component.get('v.subject');
        var pp = component.get('v.people');
        console.log('== people [S] == ');
        console.log('Source: '+sc);
        console.log('Subject: '+sb);
        console.log(pp);
        console.log('== people [E] == ');
    }
})

The console output from above code snippet is this:

== people [S] == 
Source: undefined
Subject: undefined
null
== people [E] ==

I am unable to figure out what I'm doing incorrectly to read the selected email's attributes? Though when I launch this component in sidebar I do get the displayed html render the values correctly like this:

Email subject
Another Email
To:
Varun C - testing@testing123.onmicrosoft.com
From:
Varun C - testemailfrom@yahoo.com
CC:

, Another Email!

what could be wrong in my doInit method code that I'm getting null values but when I put same attribute values in component html, and it renders the values correctly, could it be a bug or I'm missing something here?

  • Where do you load this component from? it should run from outlook... – Itai Shmida Oct 24 '16 at 19:39
  • Yes that is clear to me as well :-), I've been trying to sue it from Office365 outlook account, and it shows up fine just the doinit method does not provide me the values. – VarunC Oct 24 '16 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.