• kishore goud 3
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 8
    Replies
Requirement: There is a button "Export Today "  which is used to export account records in the form of csv in lightning component(Account_Detail_Component).In the helper ,we have "convertArrayOfObjectsToCSV" function which is used to convert object records into csv. I am able to display account fields values i.e 'Name','AccountNumber','Id'  in csv.But I am not able to display parent account field values.
For example below query return account field values and parent field value 
Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null.Could any one please post javascript code which needs to be used in helper fucntion for displaying parent  account records.


User-added image


Component:
<aura:component  controller="CsvDownloadCtrller" implements="force:appHostable">
    <aura:attribute name="AcctLst" type="Account[]"></aura:attribute>
    <aura:handler name="init" value="{!this}" action="{!c.loadAcctRcrds}"/>
    <div class="slds-box slds-box">
  <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Account List View</span>
          </a>
        </h2>
      </div>
        
      <div class="slds-no-flex">
        <button class="slds-button slds-button_brand" onclick="{!c.exprtTodysRecrds}">Export Today</button>
        <button class="slds-button slds-button_brand">Export Weekly</button>  
      </div>
    </header>
  </div>
</article>
        
 <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Search Accounts</span>
          </a>
        </h2>
      </div>
      
    </header>
  </div>
</article>
<div class="slds-form slds-form_compound">
    <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Account Type" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
        <option value="4">four</option>
        <option value="5">five</option>
    </lightning:select>
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Parent Account Number" name="ParentAccountNumber"  />
</div>
</div>
</div>
</fieldset>
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Account Number" name="AccountNumber"  />   
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
    <lightning:textarea name="input1" label="Description" />    
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Country" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
         <option value="4">four</option>
    </lightning:select>  
</div>    
</div>
</div>
</fieldset> 
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>          
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="From Date" /> 
</div>    
</div>
</div>
</fieldset>   
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="To Date" /> 
</div>    
</div>
</div>
</fieldset>  
</div>
       
<div class="slds-no-flex slds-align_absolute-center slds-m-top_xx-large">
        <button class="slds-button slds-button_brand" style="width:100px">Search</button>
        <button class="slds-button slds-button_brand" style="width:100px">Clear</button>  
      </div> 
</div> 
</aura:component>

controller:
({
    loadAcctRcrds:function(component,event,helper){
        
       var action = component.get("c.getAccounts");
        action.setCallback(this,function(response){
        var state = response.getState();
            
            
            
            if(state == "SUCCESS"){
                
                component.set("v.AcctLst",response.getReturnValue());
                
            }
            else{
                alert('failed');
                
            }
        });
        $A.enqueueAction(action);      
        
    },
    
    exprtTodysRecrds : function(component, event, helper) {
         var stockData = component.get("v.AcctLst")    
         var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
          if (csv == null){return;} 
        
        // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####     
         var hiddenElement = document.createElement('a');
          hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
          hiddenElement.target = '_self'; // 
          hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
          document.body.appendChild(hiddenElement); // Required for FireFox browser
          hiddenElement.click(); // using click() js function to download csv file
        
        
    }
})


Helper:

({
        
    convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
        var csvStringResult, counter, keys, columnDivider, lineDivider,parentKey;
       
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         }
        // store ,[comma] in columnDivider variabel for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider varaible  
        columnDivider = ',';
        lineDivider =  '\n';
 
        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header  
        keys = ['Name','AccountNumber','Id','Parent' ];
        //parentKey=['AccountNumber'];
        
        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);
        csvStringResult += lineDivider;
 
        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;
           
             for(var sTempkey in keys) {
                var skey = keys[sTempkey] ; 
                 
                /* if(skey=='Parent'){
                     for(var pTempkey in parentKey){
                         csvStringResult += '"'+ objectRecords[i][skey][pTempkey]+'"';                       
                         
                     }    
                     
                     
                 }*/
                
 
              // add , [comma] after every String value,. [except first]
                  if(counter > 0){ 
                      csvStringResult += columnDivider; 
                   }   
               
               csvStringResult += '"'+ objectRecords[i][skey]+'"'; 
               
                /* if(csvStringResult.includes("Parent")){
                     for(var sTemp in parentKey){
                         var orgnKey = parentKey[sTemp];        
                        csvStringResult += '"'+ objectRecords[i][skey][orgnKey]+'"'; 
                         
                     }
                     
                 } */ 
                 
                 
               
               counter++;
             
             } // inner for loop close     
             csvStringResult += lineDivider;
          }// outer main for loop close 
       
       // return the CSV formate String 
        return csvStringResult;        
    },

})

Apex Controller:

public class CsvDownloadCtrller {
    
    @AuraEnabled
    public static List<Account> getAccounts(){
       return [Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null];
              
        
    } 

}







 
When we create new case ,suggested articles side bar should be visible to user .We created permission set with below permissons
System Permissions
View Data Categories
View Roles and Role Hierarchy
View Setup and Configuration

App Permisisons
​Allow View Knowledge
Knowledge One
Manage Articles
Manage Knowledge Article Import/Export
Manage Salesforce Knowledge
Share internal Knowledge articles externally

This permission set contains users belongs to different different profiles .Only few users of some profiles are able to view the suggested articles side bar when we create new case.I am not able to figure out why other users are not able to view this side bar.Do I need to give any additional permission to the profile users who are not  able view this side bar.Could you please help me out. User-added image
 
Hi every one,
As per my requirement,I need to check whether phone field of account object is null before inserting contact.If it is null,I should not allow user to create contact.I created trigger for this scenario,but unable to achieve functionality .I am posting my trigger code,any one please help me out.

trigger CheckAcctPhoneBlank on Contact (Before insert) {
     
    for(Contact con:[Select id,account.phone,account.name from Contact where id in:trigger.new]){ 
        system.debug('Contact size**'+con);   
        system.debug('??test2??');
        system.debug('Phone details**'+con.account.phone);
        if(con.account.phone == null){
         con.addError('Contact cannot be inserted');
        
        }
        
    
    }

}
 
I have two division Europe and Japan Region.OWD is private for account object and I have specific profile to each region . Europian Region profile users should be able to delete each other records but Japan users should not be able to delete Europian profile user records.We can define sharing rules to given users edit access to each other records but we cannot delete the records.
Could any one please explain territory hierarchy with real time example
Hi ,
Currently,I am working on below scenario.When check box in quote line Item object is checked ,corresponding check box in opportunity should be checked. Can anyone please post the  trigger code for this scenario
Hi
On Account Object, there is quick action which is used to create new case.As per the requirement after case is created,case owner should be should defaulted to queue(Sample Queue).I need to create predefined value.I tried to assginCase.owner = queue id ,but I am getting error.So,I wanted to create formula field in user which would be retrieve queue .I unable to fugure out how to write the formula.Later ,I would be assigning Case.Owner= User.formula field.Can any one please guide me .
Scenario: On the Account Object ,mobile user has to create new case which is related list on account.I created quick action on account object and target object is case and this quick action contains account(look up),contact(look up),subject,description.I need to prepopulate the contact look up with current logged in profile user.Could you any one please guide me the formula which need to be created in the predefined value .
Currently, I am working on a quick action on related object.Scenario:On the Account Object ,mobile user should be able to create new case which is related list on the account object.In the quick action , we have Account(lookup),Contact(lookup),subject,description.I need to prepopulate the contact look up with current logged  in profile user.We need to create predfined values for this.Please guide me the formula to be to used to prepopulate the contact look up
 
Suppose there is parent object(A) and child object (B).When I select picklist value in parent ,picklist in child should be updated and later check box in parent should be updated.For example picklist values of A(D1,D2) and picklist values of B(Division 1,Division 2).If we select picklist values as D1 and then all the picklist value of all child objects should be Divsion 1 and later check box in parent should be checked.Could any one please post a trigger for this scenario.
Hi Every One,
I an new to Field Service Lighning  and currently we have an project requirement.
Requirement: Dispatcher need to track the time taken by technician to travel from one location to another location. For example Technician is in Location A and he has an service appointment in Location B. Dispatcher need to know the time taken by technician to travel from Location A to Location B. Could any one please provide me any solution for this requirement .
Requirement: There is a button "Export Today "  which is used to export account records in the form of csv in lightning component(Account_Detail_Component).In the helper ,we have "convertArrayOfObjectsToCSV" function which is used to convert object records into csv. I am able to display account fields values i.e 'Name','AccountNumber','Id'  in csv.But I am not able to display parent account field values.
For example below query return account field values and parent field value 
Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null.Could any one please post javascript code which needs to be used in helper fucntion for displaying parent  account records.


User-added image


Component:
<aura:component  controller="CsvDownloadCtrller" implements="force:appHostable">
    <aura:attribute name="AcctLst" type="Account[]"></aura:attribute>
    <aura:handler name="init" value="{!this}" action="{!c.loadAcctRcrds}"/>
    <div class="slds-box slds-box">
  <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Account List View</span>
          </a>
        </h2>
      </div>
        
      <div class="slds-no-flex">
        <button class="slds-button slds-button_brand" onclick="{!c.exprtTodysRecrds}">Export Today</button>
        <button class="slds-button slds-button_brand">Export Weekly</button>  
      </div>
    </header>
  </div>
</article>
        
 <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Search Accounts</span>
          </a>
        </h2>
      </div>
      
    </header>
  </div>
</article>
<div class="slds-form slds-form_compound">
    <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Account Type" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
        <option value="4">four</option>
        <option value="5">five</option>
    </lightning:select>
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Parent Account Number" name="ParentAccountNumber"  />
</div>
</div>
</div>
</fieldset>
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Account Number" name="AccountNumber"  />   
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
    <lightning:textarea name="input1" label="Description" />    
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Country" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
         <option value="4">four</option>
    </lightning:select>  
</div>    
</div>
</div>
</fieldset> 
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>          
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="From Date" /> 
</div>    
</div>
</div>
</fieldset>   
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="To Date" /> 
</div>    
</div>
</div>
</fieldset>  
</div>
       
<div class="slds-no-flex slds-align_absolute-center slds-m-top_xx-large">
        <button class="slds-button slds-button_brand" style="width:100px">Search</button>
        <button class="slds-button slds-button_brand" style="width:100px">Clear</button>  
      </div> 
</div> 
</aura:component>

controller:
({
    loadAcctRcrds:function(component,event,helper){
        
       var action = component.get("c.getAccounts");
        action.setCallback(this,function(response){
        var state = response.getState();
            
            
            
            if(state == "SUCCESS"){
                
                component.set("v.AcctLst",response.getReturnValue());
                
            }
            else{
                alert('failed');
                
            }
        });
        $A.enqueueAction(action);      
        
    },
    
    exprtTodysRecrds : function(component, event, helper) {
         var stockData = component.get("v.AcctLst")    
         var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
          if (csv == null){return;} 
        
        // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####     
         var hiddenElement = document.createElement('a');
          hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
          hiddenElement.target = '_self'; // 
          hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
          document.body.appendChild(hiddenElement); // Required for FireFox browser
          hiddenElement.click(); // using click() js function to download csv file
        
        
    }
})


Helper:

({
        
    convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
        var csvStringResult, counter, keys, columnDivider, lineDivider,parentKey;
       
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         }
        // store ,[comma] in columnDivider variabel for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider varaible  
        columnDivider = ',';
        lineDivider =  '\n';
 
        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header  
        keys = ['Name','AccountNumber','Id','Parent' ];
        //parentKey=['AccountNumber'];
        
        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);
        csvStringResult += lineDivider;
 
        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;
           
             for(var sTempkey in keys) {
                var skey = keys[sTempkey] ; 
                 
                /* if(skey=='Parent'){
                     for(var pTempkey in parentKey){
                         csvStringResult += '"'+ objectRecords[i][skey][pTempkey]+'"';                       
                         
                     }    
                     
                     
                 }*/
                
 
              // add , [comma] after every String value,. [except first]
                  if(counter > 0){ 
                      csvStringResult += columnDivider; 
                   }   
               
               csvStringResult += '"'+ objectRecords[i][skey]+'"'; 
               
                /* if(csvStringResult.includes("Parent")){
                     for(var sTemp in parentKey){
                         var orgnKey = parentKey[sTemp];        
                        csvStringResult += '"'+ objectRecords[i][skey][orgnKey]+'"'; 
                         
                     }
                     
                 } */ 
                 
                 
               
               counter++;
             
             } // inner for loop close     
             csvStringResult += lineDivider;
          }// outer main for loop close 
       
       // return the CSV formate String 
        return csvStringResult;        
    },

})

Apex Controller:

public class CsvDownloadCtrller {
    
    @AuraEnabled
    public static List<Account> getAccounts(){
       return [Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null];
              
        
    } 

}







 
When we create new case ,suggested articles side bar should be visible to user .We created permission set with below permissons
System Permissions
View Data Categories
View Roles and Role Hierarchy
View Setup and Configuration

App Permisisons
​Allow View Knowledge
Knowledge One
Manage Articles
Manage Knowledge Article Import/Export
Manage Salesforce Knowledge
Share internal Knowledge articles externally

This permission set contains users belongs to different different profiles .Only few users of some profiles are able to view the suggested articles side bar when we create new case.I am not able to figure out why other users are not able to view this side bar.Do I need to give any additional permission to the profile users who are not  able view this side bar.Could you please help me out. User-added image
 
Hi every one,
As per my requirement,I need to check whether phone field of account object is null before inserting contact.If it is null,I should not allow user to create contact.I created trigger for this scenario,but unable to achieve functionality .I am posting my trigger code,any one please help me out.

trigger CheckAcctPhoneBlank on Contact (Before insert) {
     
    for(Contact con:[Select id,account.phone,account.name from Contact where id in:trigger.new]){ 
        system.debug('Contact size**'+con);   
        system.debug('??test2??');
        system.debug('Phone details**'+con.account.phone);
        if(con.account.phone == null){
         con.addError('Contact cannot be inserted');
        
        }
        
    
    }

}
 
Hi ,
Currently,I am working on below scenario.When check box in quote line Item object is checked ,corresponding check box in opportunity should be checked. Can anyone please post the  trigger code for this scenario
Scenario: On the Account Object ,mobile user has to create new case which is related list on account.I created quick action on account object and target object is case and this quick action contains account(look up),contact(look up),subject,description.I need to prepopulate the contact look up with current logged in profile user.Could you any one please guide me the formula which need to be created in the predefined value .
Currently, I am working on a quick action on related object.Scenario:On the Account Object ,mobile user should be able to create new case which is related list on the account object.In the quick action , we have Account(lookup),Contact(lookup),subject,description.I need to prepopulate the contact look up with current logged  in profile user.We need to create predfined values for this.Please guide me the formula to be to used to prepopulate the contact look up
 
Suppose there is parent object(A) and child object (B).When I select picklist value in parent ,picklist in child should be updated and later check box in parent should be updated.For example picklist values of A(D1,D2) and picklist values of B(Division 1,Division 2).If we select picklist values as D1 and then all the picklist value of all child objects should be Divsion 1 and later check box in parent should be checked.Could any one please post a trigger for this scenario.