+ Start a Discussion
MaheemSamMaheemSam 

Component value is not returning

Hi,

 In below component <aura:if isTrue="{!v.erpId == null}"> is not retuning please suggest me what might be the issue here. 
 
v.erpid is not returning value from controller in component. 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global"  controller="POTrackerExtLtn">
	<aura:attribute name="act" type="Object"/>
	<aura:attribute name="key" type="String" access="private"/>
    
     <force:recordData aura:id="forceRecord"
                      recordId="{!v.recordId}"
                      targetFields="{!v.act}"
                      fields="accountId,userId,erpId,region,quoteIds"
                      recordUpdated="{!c.handleRecordUpdated}"
                      mode="EDIT" />
    <div class="slds-box slds-theme_info">
        
<aura:if isTrue="{!v.erpId == null}">
	<p>"Oracle ERP disti ID" is not set for this account. Please contact system administrator for more information. </p>
    <aura:set attribute="else">
        <p>PO Tracker is lunched in New window!</p>
    </aura:set>
</aura:if>
        
    </div>
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
</aura:component>

Class. 
public class POTrackerExtLtn{
      
    @AuraEnabled
    public static String getAccessKey(ID recordId){
         ID accountId; 
         ID userId;
         String erpId;
         string region;
         string quoteIds;
         String userarea;
         string commaQuoteIds;    
       list<String> CommastrList = new List<String>();
       
       list<SBQQ__Quote__c> QtAprd = [select id, Quote_ID__c,SBQQ__Opportunity2__r.ownerid,
                                     SBQQ__Opportunity2__r.accountid,SBQQ__Opportunity2__r.account.Oracle_ERP_ID__c,
                                     SBQQ__Opportunity2__r.owner.Area__c,SBQQ__Opportunity2__r.owner.Region_New__c,
                                     SBQQ__Opportunity2__r.API_Session__c,SBQQ__Opportunity2__r.API_Partner_Server_100__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Account__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c
                                     from SBQQ__Quote__c 
                                     where SBQQ__Opportunity2__c = :recordId and ApprovalStatus__c = 'Approved'];   
    
       for(SBQQ__Quote__c str : QtAprd){
       
           if(str.Quote_ID__c != null){
                CommastrList.add(str.Quote_ID__c);     
            }     
            
            
            accountId = str.SBQQ__Opportunity2__r.Distributor__r.Account__c;
            userId    = str.SBQQ__Opportunity2__r.ownerid;
             
             if(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c != null){
             erpId     = String.valueof(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c);
             }
             
             region    = str.SBQQ__Opportunity2__r.owner.Region_New__c;
             quoteIds  = commaQuoteIds;
        }
    
        commaQuoteIds = String.join(CommastrList,','); //Quote Id in comma separated format. 
        
          system.debug('Debug from POTrackerExtLtn commaQuoteIds ' + commaQuoteIds);
          system.debug('Debug from POTrackerExtLtn accountId ' + accountId );
          system.debug('Debug from POTrackerExtLtn userId    ' + userId );
          system.debug('Debug from POTrackerExtLtn erpId ' + erpId);
          system.debug('Debug from POTrackerExtLtn region    ' + region    );
          system.debug('Debug from POTrackerExtLtn quoteIds  ' + commaQuoteIds );
          
             String input = 'accountId=' + accountId  +
                        '&erpId='+erpId +
                        '&userId='+userinfo.getUserId() +
                        '&region='+region +
                        '&quoteIds='+commaQuoteIds +                        
                        '&timestamp=' + System.currentTimeMillis();
                        
        String key = EncryptionSSOUtils.encryptWithAES128(input);
        system.debug('Key_noendcode_'+key);
        key = EncodingUtil.urlEncode(key,'UTF-8');
        system.debug('Key__endcode__'+key);
        return key; 
        
         

    }
    
}

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You are using erpId in aura:if, but you are not storing the value anywhere. You need to create an attribute for that.

<aura:attribute name="erpId" type="String" />

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
MaheemSamMaheemSam
Thanks Khan for you reply. 

In above thread In class POTrackerExtLtn,  String erpId is getting a value from controller POTrackerExtLtn is used inside the component 

I want to display a message when erpId is null I am new to lightning please suggest me how to add this condition. 

User-added image

I am calling the component from opportunity, How to add opportunity fields in condition please suggest 

Thanks
Sam