• Akash Kaintura
  • NEWBIE
  • 30 Points
  • Member since 2020
  • Developer
  • RubicoIT


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
Hi, 

I wrote a custom lightning opponent, which is finally working. I managed to add it to the Accounts page where the user should be able to see a list of commissions and the contacts who achieved them. I would like the user to see only the commissions that are related to that account. I added force:hasRecordId to the app and it seemed to be working until I realised that the app is only returning the contacts who have no accounts at all. I am a bit baffled by this so I appreciate any help. 
Below is my code: 
<aura:application extends="force:slds" implements="force:hasRecordId" >
  
    <c:commissionsByAccount/>
    
</aura:application>
The component:
<aura:component controller="commissionController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="contacts" type="Commission__c[]" />
    <aura:attribute name="commissions" type="Commission__c[]"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
   
    <lightning:layout class="slds-page-header slds-page-header--object-home">
    	<lightning:layoutItem padding="around-small" size="4">
            <lightning:icon iconName="standard:scan_card" alternativeText="Commissions"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
            	<h1 class="slds-text-heading--label">Commissions for this account</h1>
                <h1 class="slds-text-heading--medium">Commissions</h1>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    
    <lightning:layout>
    	<lightning:layoutItem padding="around-small" size="12">
	<table class="slds-table slds-table_cell-buffer slds-table_bordered">
  <thead>
    <tr class="slds-line-height_reset">
      <th aria-label="Date" aria-sort="descending" class="sdls-is-sortable" scope="col">
        <div class="slds-truncate" title="Date">Date</div>
      </th>
      <th class="" scope="col">
        <div class="slds-truncate" title="Name">Name</div>
      </th>
      <th class="" scope="col">
        <div class="slds-truncate" title="Amount">Amount</div>
      </th>
    </tr>
  </thead>
  <tbody>
      <aura:iteration items="{!v.contacts}" var="com">
    <tr class="slds-hint-parent">
      <th data-label="Date" scope="row">
        <div class="slds-truncate" title="Date">
          <a href="javascript:void(0);" tabindex="-1">{!com.Date__c}</a>
        </div>
      </th>
      <td data-label="Name">
        <div class="slds-truncate" title="Name">{!com.Contact_Name__r.Name}</div>
      </td>
      <td data-label="Amount">
        <div class="slds-truncate" title="Amount">{!com.Commission_Amount__c}</div>
      </td>
      </tr>
      </aura:iteration>
  </tbody>
</table>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

The Controller:

 
public class commissionController {
@AuraEnabled
	public static List<Commission__c> getCommissions(String AccountID) {
       return [SELECT Commission_Amount__c, Date__c, Commission__c.Contact_Name__r.Name FROM Commission__c WHERE Commission__c.Contact_Name__r.Account.Id =: AccountID ];
    	
    }
}

And the other controller: 
({
	doInit: function(component, event, helper) {
        var action = component.get("c.getCommissions");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var res=response.getReturnValue();
                component.set("v.contacts", response.getReturnValue());
             
                console.log("Success");
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        // Send action off to be executed
        $A.enqueueAction(action);
    },
})

Thank you very much​​​​​​​
I am trying to use the community cloud in salesforce but not able to find how the SEO works in a community cloud. From providing object permission to the guest user.
I have written a code to calculate SI but each time I try to add calculate any value I am getting below error

User-added image
trigger TriggerFullNameExample on Opportunity (before insert) 
{   
    List<Account> acc=new List<Account>();
    for(Opportunity opp:trigger.new) 
{    
    if(acc.First_Name__c + '' + acc.Last_Name__c==opp.FullName__c)
    {
        Account acco= new Account();
        acco.First_Name__c+ '' + acco.Last_Name__c== opp.FullName__c;
        acc.add(acco);
    }
}
    insert acc;
}
  • January 20, 2020
  • Like
  • 0
Hi Guys,
Good Morning,  I am new to salesforce. from my company i would like to create a workflow process /build a process. 
Scenario is :
when lead status changed to Reconginsed > On-hold Automatically send an Emails to Lead Email and also send an email to the in-house marketing team. 
User-added image
Hi, 

I wrote a custom lightning opponent, which is finally working. I managed to add it to the Accounts page where the user should be able to see a list of commissions and the contacts who achieved them. I would like the user to see only the commissions that are related to that account. I added force:hasRecordId to the app and it seemed to be working until I realised that the app is only returning the contacts who have no accounts at all. I am a bit baffled by this so I appreciate any help. 
Below is my code: 
<aura:application extends="force:slds" implements="force:hasRecordId" >
  
    <c:commissionsByAccount/>
    
</aura:application>
The component:
<aura:component controller="commissionController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="contacts" type="Commission__c[]" />
    <aura:attribute name="commissions" type="Commission__c[]"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
   
    <lightning:layout class="slds-page-header slds-page-header--object-home">
    	<lightning:layoutItem padding="around-small" size="4">
            <lightning:icon iconName="standard:scan_card" alternativeText="Commissions"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
            	<h1 class="slds-text-heading--label">Commissions for this account</h1>
                <h1 class="slds-text-heading--medium">Commissions</h1>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    
    <lightning:layout>
    	<lightning:layoutItem padding="around-small" size="12">
	<table class="slds-table slds-table_cell-buffer slds-table_bordered">
  <thead>
    <tr class="slds-line-height_reset">
      <th aria-label="Date" aria-sort="descending" class="sdls-is-sortable" scope="col">
        <div class="slds-truncate" title="Date">Date</div>
      </th>
      <th class="" scope="col">
        <div class="slds-truncate" title="Name">Name</div>
      </th>
      <th class="" scope="col">
        <div class="slds-truncate" title="Amount">Amount</div>
      </th>
    </tr>
  </thead>
  <tbody>
      <aura:iteration items="{!v.contacts}" var="com">
    <tr class="slds-hint-parent">
      <th data-label="Date" scope="row">
        <div class="slds-truncate" title="Date">
          <a href="javascript:void(0);" tabindex="-1">{!com.Date__c}</a>
        </div>
      </th>
      <td data-label="Name">
        <div class="slds-truncate" title="Name">{!com.Contact_Name__r.Name}</div>
      </td>
      <td data-label="Amount">
        <div class="slds-truncate" title="Amount">{!com.Commission_Amount__c}</div>
      </td>
      </tr>
      </aura:iteration>
  </tbody>
</table>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

The Controller:

 
public class commissionController {
@AuraEnabled
	public static List<Commission__c> getCommissions(String AccountID) {
       return [SELECT Commission_Amount__c, Date__c, Commission__c.Contact_Name__r.Name FROM Commission__c WHERE Commission__c.Contact_Name__r.Account.Id =: AccountID ];
    	
    }
}

And the other controller: 
({
	doInit: function(component, event, helper) {
        var action = component.get("c.getCommissions");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var res=response.getReturnValue();
                component.set("v.contacts", response.getReturnValue());
             
                console.log("Success");
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        // Send action off to be executed
        $A.enqueueAction(action);
    },
})

Thank you very much​​​​​​​
Hi, I am not able to Install the DreamHouse app, even though i follow the steps after that i am stuck on the DATA IMPORT step when i click on that tab it is continuously loading the page there is no option is coming to click on  Initialize Sample Data. What do i do and it showsThis message is showing on Trailhead..!!This image is continuously loading the error on the trailhead page like...
 
Hi All,
i have a field on Account called “Only_Default_Contact”, checkbox, default off
 
When a new Account is created, create a new Contact that has the following data points:
First Name = “Info”
Last Name = “Default”
Email = “info@websitedomain.tld”
and set Account Field Only_Default_Contact = TRUE

When the Account has more than 1 Contact, update Account field  Only_Default_Contact to FALSE.
public class TriggerAccountHelper {
    public static List<Account> newAccount = new List<Account>();
    public static List<Account> oldAccount = new List<Account>();
    public static Map<Id, Account> newMapAccount = new Map<Id, Account>();
    public static Map<Id, Account> oldMapAccount = new Map<Id, Account>();
  

    public static void CreatContact(){
         List<Contact> contactToInsert = new List<Contact>();
        for(Account acc : newAccount){
            Contact con = new Contact(LastName = 'test30',
                                      AccountId=acc.id
                                     );
            contactToInsert.add(con);
            if(contactToInsert.size() == 0){
                acc.OnlyDefaultContact__c = True;
            }
            else{
                acc.OnlyDefaultContact__c = False;
            }
        }
        
        if(!contactToInsert.isEmpty()){ 
            insert contactToInsert; 
         }
    
     }
}
i am executing the trigger on After insert.
its showing me this error:-Trigger_Account: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.TriggerAccountHelper.CreatContact: line 19, column 1 Trigger.Trigger_Account: line 12, column 1