• Viru D.
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 9
    Replies
Best way to synchronize information between Salesforce orgs of same company. This is required for the standard objects Account, Contact, Lead, Opportunity, Case etc. 
- Duplicate information of account should be avoided.
- Any suggestion to improve the quality of the data like Company Name, address information (Phone, country,state, postal code).

I am thinking of Lightning connect but still you can comment.
 
  • September 20, 2019
  • Like
  • 0
I want to setup SFDX environment without scratch org that is pull all metadata from to local machine like ecplise and save it back with Ctrl + S.
here I was able to complete few steps but still not complete.

sfdx force:auth:web:login --setalias my-sandbox --instanceurl https://test.salesforce.com
sfdx force:mdapi:retrieve -r ./AllCode_APIZip -u my-sandbox -k src/package.xml
sfdx force:mdapi:deploy -c -f ../AllCode_APIZip/unpackaged.zip -u my-sandbox -w 10


I got the code on local machine but after clicking Ctrl + S, it is not saving to server. 
Thanks in advance.



 
aggregateResult are not calculating in after insret trigger but they work fine in after update trigger.
However after insert all the records are available and I can able to print it in the log. 
I am seeing this first time. why aggregrate results are not avilable in after insert trigger ?
Giving log here for your reference.

Thanks in advance.


public static void Update_Forecasting_by_group(map<id,Monthly_Forecast__c> MapMontlyForecast ){
        if(Execonce_method2){
           Execonce_method2 = false;
           list<Forecast_by_group> List_ForcastbyGr = new list<Forecast_by_group>();
           map<string ,Forecast_by_group> map_ForcastbyGr = new map<string ,Forecast_by_group>();
           map<string,id> FBG_Key_id_map = new map<string,id>();
           list<Forecasting_By_Group__c> Upsert_list = new list<Forecasting_By_Group__c>();   
           set<string> Set_ProdGrpMkt = new set<string>();
           
           system.debug('==MapMontlyForecast.keyset()==' + MapMontlyForecast.keyset()); 
           
           for(Monthly_Forecast__c MFobj : [select id,Account_Product_Forecast__r.Product_Group_Marketing__c,Product_Group_Marketing__c, Forecast_for_Date__c, revenue__c, delta_revenue__c, Product_Name__c, Account_Name__c from Monthly_Forecast__c where id in : MapMontlyForecast.keyset()] ){
                 system.debug('== Monthly_Forecast__c field values ==' + MFobj);
                 if(MFobj.Account_Product_Forecast__r.Product_Group_Marketing__c != null ) 
                 Set_ProdGrpMkt.add(MFobj.Account_Product_Forecast__r.Product_Group_Marketing__c);
           }
           
            
           system.debug('==Set_ProdGrpMkt==' + Set_ProdGrpMkt );
           List<aggregateResult> results = [select sum(Revenue__c) Total_Revenue , SUM(Delta_Revenue__c) Total_Delta_Revenue, Product_Group_Marketing__c, Forecast_for_Date__c from Monthly_Forecast__c where (Forecast_for_Date__c = Last_N_Years:1 or Forecast_for_Date__c = this_year) and Product_Group_Marketing__c in : Set_ProdGrpMkt group by Product_Group_Marketing__c, Forecast_for_Date__c];
          //List<aggregateResult> results = [select sum(Revenue__c) Total_Revenue , SUM(Delta_Revenue__c) Total_Delta_Revenue, Product_Group_Marketing__c, Forecast_for_Date__c from Monthly_Forecast__c where Product_Group_Marketing__c != null group by Product_Group_Marketing__c, Forecast_for_Date__c]; 
           
           system.debug('==results==' + results);
           
           for(aggregateResult ar  : results){
                 List_ForcastbyGr.add(new Forecast_by_group( (double)ar.get('Total_Revenue'),(double)ar.get('Total_Delta_Revenue') , (string)ar.get('Product_Group_Marketing__c'), (date)ar.get('Forecast_for_Date__c')  ));
           } 
           
           system.debug('==List_ForcastbyGr==' + List_ForcastbyGr);
           
           for(Forecast_by_group FBGobj : List_ForcastbyGr){
             map_ForcastbyGr.put(FBGobj.Forecast_by_group_key,FBGobj);
           }
          
          system.debug('==map_ForcastbyGr==' + map_ForcastbyGr);
          
          for(Forecasting_By_Group__c FBGobj : [select id,Forecast_by_group_key__c from Forecasting_By_Group__c where Forecast_by_group_key__c in : map_ForcastbyGr.keyset()])
              FBG_Key_id_map.put(FBGobj.Forecast_by_group_key__c, FBGobj.id);
                        
         system.debug('==FBG_Key_id_map==' + FBG_Key_id_map);     
              
          for(string Key : map_ForcastbyGr.keyset()){
                system.debug('==Key==' + Key);  
                Forecast_by_group FBGOBJ =   map_ForcastbyGr.get(Key);
                if(FBG_Key_id_map.containskey(Key))
                   Upsert_list.add(new Forecasting_By_Group__c(id = FBG_Key_id_map.get(key), Total_Revenue__c = FBGOBJ.Total_Revenue, Total_Delta__c = FBGOBJ.Total_Delta_Revenue,Product_Group_Marketing__c = FBGOBJ.product_mkt_grp, Forecast_for_Date__c = FBGOBJ.forecast_date));
                else
                   Upsert_list.add(new Forecasting_By_Group__c(Total_Revenue__c = FBGOBJ.Total_Revenue, Total_Delta__c = FBGOBJ.Total_Delta_Revenue,Product_Group_Marketing__c = FBGOBJ.product_mkt_grp, Forecast_for_Date__c = FBGOBJ.forecast_date));
            }
          
          system.debug('==Upsert_list==' + Upsert_list);
          
              if(Upsert_list.size() > 0)
                 upsert Upsert_list;
        }
    }

Log :

10:18:58.0 (285221766)|USER_DEBUG|[77]|DEBUG|==MapMontlyForecast.keyset()=={a0T4F000000jXiUUAU, a0T4F000000jXiVUAU}
10:18:58.0 (285563121)|SOQL_EXECUTE_BEGIN|[79]|Aggregations:0|SELECT id, Account_Product_Forecast__r.Product_Group_Marketing__c, Product_Group_Marketing__c, Forecast_for_Date__c, revenue__c, delta_revenue__c, Product_Name__c, Account_Name__c FROM Monthly_Forecast__c 
10:18:58.0 (295157565)|SOQL_EXECUTE_END|[79]|Rows:2
10:18:58.0 (295594304)|USER_DEBUG|[80]|DEBUG|== Monthly_Forecast__c field values ==Monthly_Forecast__c:{Id=a0T4F000000jXiUUAU, Account_Product_Forecast__c=a2q4F000000NYSHQA4, Forecast_for_Date__c=2018-07-15 00:00:00, Revenue__c=9.7284, Delta_Revenue__c=0.0000, Product_Name__c=LXML-PB01-0040, Account_Name__c=THOUSAND LIGHTS LIGHTING (CHANGZHOU) LIMITED, CurrencyIsoCode=USD}
10:18:58.0 (295751548)|USER_DEBUG|[80]|DEBUG|== Monthly_Forecast__c field values ==Monthly_Forecast__c:{Id=a0T4F000000jXiVUAU, Account_Product_Forecast__c=a2q4F000000NYSHQA4, Forecast_for_Date__c=2018-08-15 00:00:00, Revenue__c=19.4568, Delta_Revenue__c=0.0000, Product_Name__c=LXML-PB01-0040, Account_Name__c=THOUSAND LIGHTS LIGHTING (CHANGZHOU) LIMITED, CurrencyIsoCode=USD}
10:18:58.0 (295831738)|USER_DEBUG|[86]|DEBUG|==Set_ProdGrpMkt=={Colors}
10:18:58.0 (298335806)|SOQL_EXECUTE_BEGIN|[87]|Aggregations:0|SELECT SUM(Revenue__c) Total_Revenue, SUM(Delta_Revenue__c) Total_Delta_Revenue, Product_Group_Marketing__c, Forecast_for_Date__c FROM Monthly_Forecast__c WHERE ((Forecast_for_Date__c = Last_N_Years:1 OR Forecast_for_Date__c = this_year) AND Product_Group_Marketing__c = :tmpVar1) GROUP BY Product_Group_Marketing__c, Forecast_for_Date__c
10:18:58.0 (345034833)|SOQL_EXECUTE_END|[87]|Rows:0
10:18:58.0 (345188715)|USER_DEBUG|[90]|DEBUG|==results==()  ----> here is nothing is calcuating.
10:18:58.0 (345266134)|USER_DEBUG|[96]|DEBUG|==List_ForcastbyGr==()
10:18:58.0 (345397915)|USER_DEBUG|[102]|DEBUG|==map_ForcastbyGr=={}
10:18:58.0 (345676009)|SOQL_EXECUTE_BEGIN|[104]|Aggregations:0|SELECT id, Forecast_by_group_key__c FROM Forecasting_By_Group__c 
10:18:58.0 (349200864)|SOQL_EXECUTE_END|[104]|Rows:0
10:18:58.0 (349389572)|USER_DEBUG|[107]|DEBUG|==FBG_Key_id_map=={}
10:18:58.0 (349486674)|USER_DEBUG|[118]|DEBUG|==Upsert_list==()
My requirement is to show account name in the picklist and store id behind so when you change the value in the picklist, you will get id easily.
I tried something like this but not working.

I think this portion is not working : 
label: allValues[i].name,
value: allValues[i].id

Let me know what do you think.


markup :
<aura:attribute name="accounts" type="List" />
  <div class="slds-form-element slds-m-top_x-small slds-size_8-of-12 slds-m-left_large slds-box">
            <label class="slds-text-heading_small slds-form-element__label" for="input-unique-id">Select Account :</label>
            <div class="slds-form-element__control"> 
            <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedPricebook}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
                <option text="--Select--" value="--Select--" selected="--Select--"/>
                <aura:iteration items="{!v.accounts}" var="item">
                    <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
                </aura:iteration>
            </lightning:select>
            </div>
    </div>  
    
Helper :

getAccountList2 : function(component) {
        console.log('==In getAccountList2==');  
        var action = component.get("c.getAccounts");
        var opts = [];
        //Setting the Callback
            action.setCallback(this,function(response){
                //get the response state
                var state = response.getState();
                
                //check if result is successfull
                if(state == "SUCCESS"){
                   var allValues = response.getReturnValue();
                  for (var i = 0; i < allValues.length; i++) {
                    opts.push({
                        class: "optionClass", 
                        label: allValues[i].name,
                        value: allValues[i].id
                    });
                }
                component.set("v.options", opts);
                
  
                } else if(state == "ERROR"){
                    alert('Error in calling server side action');
                }
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
    }

Class :
  @AuraEnabled
      public static List <Account> getAccounts() {
        return [SELECT id, name, industry, Type, NumberOfEmployees, TickerSymbol, Phone FROM Account ORDER BY createdDate ASC limit 10];
      }
    







 
I am interested to use VS Code Extensions for development in VSCODE but what i see is everytimg you need to create Screach Org to start development. Is it possible to create project directly without creating screach org ? like we do in MavensMate or Ecplise ? 
my component is working fine independently when tested in lightning app but dosen't show anything when loaded from Quick action button. Plase suggest if any changes are required in code. Thanks in advance.

Works fine here :-
<aura:application extends="force:slds">
    <c:Sample_Req_Line_Comp />
    <!--<c:TestingComp1 />-->
</aura:application>

Not working on Quick action button :-

User-added image








Code snipet :-

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
    <aura:attribute name="isError" type="Boolean" default="false"/>

     
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      checking here ==> {!v.isError}

      <aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>
      
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product Family</label>
       <div class="slds-form-element__control"> 
    <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedFamily}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
        <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
        </aura:iteration>
    </lightning:select>
    </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product</label>
       <div class="slds-form-element__control"> 
       <lightning:select name="myproduct" label="" aura:id="mySelect2" value="{!v.selectedProduct}" onchange="{!c.onPicklistChange2}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist">
       <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options2}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
         </aura:iteration>
        </lightning:select>
      </div>
    </div>     
    
        
        
     <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Inventory Name</label>
      <div class="slds-form-element__control">
         <force:outputField value="{!v.InventoryRecord.Name}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Available</label>
      <div class="slds-form-element__control">
        <!--<force:outputField value="{!v.InventoryRecord.Quantity_Available__c}" />-->
        <lightning:formattedNumber value="{!v.InventoryRecord.Quantity_Available__c}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Sample Hub</label>
      <div class="slds-form-element__control">
        
      </div>
    </div>
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Requested</label>
      <div class="slds-form-element__control">
          <lightning:input type="number" aura:id="Req_qty" label=""
                             name="expenseamount"
                             min="1"
                             formatter="decimal"
                             step="1"
                             value="{!V.Request_Qty}"
                             messageWhenRangeUnderflow="Enter Quantity"/>
      </div>
    </div>
    
      
   <lightning:button label="Save" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.SaveData}"/>   
    
    
    <!--<force:outputField value="{!v.InventoryRecord.Sample_Hub__r.name}" />-->
    <!--<force:inputField value="{!v.InventoryRecord.Name}"/>-->
    <!--<lightning:formattedText value="I like salesforce.com and trailhead.salesforce.com." />-->
  
    </div>    

    <!--
    <lightning:recordViewForm recordId="{!v.InventoryRecord}" objectApiName="Sample_Inventory__c" >
        <div class="slds-box slds-theme_default">
            <lightning:outputField fieldName="name" />
            <lightning:outputField fieldName="Quantity_Available__c" />
            <lightning:outputField fieldName="Sample_Hub__r.name"/>
        </div>
    </lightning:recordViewForm>
    -->
</aura:component>

 
Trying to set value of boolean variable isError to true when required to display error message. But not working !!
Let me know if any solution or error in code..


Code snipet :-

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
   <aura:attribute name="isError" type="boolean" default="false"/>
 
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      checking here ==> {!v.isError}

<aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>



Controller : -

SaveData_Ctrl: function(component, event, helper, ReqQty,selectedProduct,SampleReq_id) {
        var action = component.get("c.SaveData2");
        action.setParams({
            "Requested_Qty": ReqQty,
            "selectedProduct": selectedProduct,
            "SampleReq_id": SampleReq_id
        });
        action.setCallback(this, function(response) {
            if (response.getState() === "SUCCESS") {
                var showerror = false; 
                component.set("V.isError", showerror);
                component.set("v.InventoryRecord", response.getReturnValue());
                console.log('==Success isError==' + component.get("V.isError"));
            }
            else{
                var errors = action.getError();
                var showerror2 = true;
                component.set("V.isError", showerror2);
                component.set("v.recordError", errors[0].message);
                console.log('==checking isError==' + component.get("V.isError"));
                
           }
        });
        $A.enqueueAction(action);
    },
My requirement is to show account name in the picklist and store id behind so when you change the value in the picklist, you will get id easily.
I tried something like this but not working.

I think this portion is not working : 
label: allValues[i].name,
value: allValues[i].id

Let me know what do you think.


markup :
<aura:attribute name="accounts" type="List" />
  <div class="slds-form-element slds-m-top_x-small slds-size_8-of-12 slds-m-left_large slds-box">
            <label class="slds-text-heading_small slds-form-element__label" for="input-unique-id">Select Account :</label>
            <div class="slds-form-element__control"> 
            <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedPricebook}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
                <option text="--Select--" value="--Select--" selected="--Select--"/>
                <aura:iteration items="{!v.accounts}" var="item">
                    <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
                </aura:iteration>
            </lightning:select>
            </div>
    </div>  
    
Helper :

getAccountList2 : function(component) {
        console.log('==In getAccountList2==');  
        var action = component.get("c.getAccounts");
        var opts = [];
        //Setting the Callback
            action.setCallback(this,function(response){
                //get the response state
                var state = response.getState();
                
                //check if result is successfull
                if(state == "SUCCESS"){
                   var allValues = response.getReturnValue();
                  for (var i = 0; i < allValues.length; i++) {
                    opts.push({
                        class: "optionClass", 
                        label: allValues[i].name,
                        value: allValues[i].id
                    });
                }
                component.set("v.options", opts);
                
  
                } else if(state == "ERROR"){
                    alert('Error in calling server side action');
                }
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
    }

Class :
  @AuraEnabled
      public static List <Account> getAccounts() {
        return [SELECT id, name, industry, Type, NumberOfEmployees, TickerSymbol, Phone FROM Account ORDER BY createdDate ASC limit 10];
      }
    







 
I am interested to use VS Code Extensions for development in VSCODE but what i see is everytimg you need to create Screach Org to start development. Is it possible to create project directly without creating screach org ? like we do in MavensMate or Ecplise ? 
my component is working fine independently when tested in lightning app but dosen't show anything when loaded from Quick action button. Plase suggest if any changes are required in code. Thanks in advance.

Works fine here :-
<aura:application extends="force:slds">
    <c:Sample_Req_Line_Comp />
    <!--<c:TestingComp1 />-->
</aura:application>

Not working on Quick action button :-

User-added image








Code snipet :-

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
    <aura:attribute name="isError" type="Boolean" default="false"/>

     
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      checking here ==> {!v.isError}

      <aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>
      
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product Family</label>
       <div class="slds-form-element__control"> 
    <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedFamily}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
        <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
        </aura:iteration>
    </lightning:select>
    </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product</label>
       <div class="slds-form-element__control"> 
       <lightning:select name="myproduct" label="" aura:id="mySelect2" value="{!v.selectedProduct}" onchange="{!c.onPicklistChange2}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist">
       <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options2}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
         </aura:iteration>
        </lightning:select>
      </div>
    </div>     
    
        
        
     <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Inventory Name</label>
      <div class="slds-form-element__control">
         <force:outputField value="{!v.InventoryRecord.Name}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Available</label>
      <div class="slds-form-element__control">
        <!--<force:outputField value="{!v.InventoryRecord.Quantity_Available__c}" />-->
        <lightning:formattedNumber value="{!v.InventoryRecord.Quantity_Available__c}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Sample Hub</label>
      <div class="slds-form-element__control">
        
      </div>
    </div>
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Requested</label>
      <div class="slds-form-element__control">
          <lightning:input type="number" aura:id="Req_qty" label=""
                             name="expenseamount"
                             min="1"
                             formatter="decimal"
                             step="1"
                             value="{!V.Request_Qty}"
                             messageWhenRangeUnderflow="Enter Quantity"/>
      </div>
    </div>
    
      
   <lightning:button label="Save" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.SaveData}"/>   
    
    
    <!--<force:outputField value="{!v.InventoryRecord.Sample_Hub__r.name}" />-->
    <!--<force:inputField value="{!v.InventoryRecord.Name}"/>-->
    <!--<lightning:formattedText value="I like salesforce.com and trailhead.salesforce.com." />-->
  
    </div>    

    <!--
    <lightning:recordViewForm recordId="{!v.InventoryRecord}" objectApiName="Sample_Inventory__c" >
        <div class="slds-box slds-theme_default">
            <lightning:outputField fieldName="name" />
            <lightning:outputField fieldName="Quantity_Available__c" />
            <lightning:outputField fieldName="Sample_Hub__r.name"/>
        </div>
    </lightning:recordViewForm>
    -->
</aura:component>

 
Trying to set value of boolean variable isError to true when required to display error message. But not working !!
Let me know if any solution or error in code..


Code snipet :-

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
   <aura:attribute name="isError" type="boolean" default="false"/>
 
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      checking here ==> {!v.isError}

<aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>



Controller : -

SaveData_Ctrl: function(component, event, helper, ReqQty,selectedProduct,SampleReq_id) {
        var action = component.get("c.SaveData2");
        action.setParams({
            "Requested_Qty": ReqQty,
            "selectedProduct": selectedProduct,
            "SampleReq_id": SampleReq_id
        });
        action.setCallback(this, function(response) {
            if (response.getState() === "SUCCESS") {
                var showerror = false; 
                component.set("V.isError", showerror);
                component.set("v.InventoryRecord", response.getReturnValue());
                console.log('==Success isError==' + component.get("V.isError"));
            }
            else{
                var errors = action.getError();
                var showerror2 = true;
                component.set("V.isError", showerror2);
                component.set("v.recordError", errors[0].message);
                console.log('==checking isError==' + component.get("V.isError"));
                
           }
        });
        $A.enqueueAction(action);
    },