You need to sign in to do that
Don't have an account?
Jaanu
hyperlink the case number in lightning
I have build a lightning component to list all the open cases and inserted in a page layout. But I want to hyperlink the case number, if someone clicks on that, it should take the user to the corresponding case for view/edit etc. can you pls let me know how to do this. thanks.
Don't write alerts in the code. instead use console.log();
All Answers
Please check below post for same
1) https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_supported_html_tags_a.htm
Example Using Navigation Event
This example uses an <a> tag that’s wired to a controller action, which fires the force:navigateToSObject event to navigate to a record. The one.app container handles the event. This event is supported in Lightning Experience, Salesforce app, and Lightning communities.
Here is the controller that fires the event.
Example 2) One small Sample for code Controller Helper
Let us know if this will help you
<aura:attribute name="cases" type="Case[]" />
<aura:attribute name="caseId" type="Id" />
<aura:iteration items="{!v.cases}" var="cse" >
<tr>
caseId = {!cse.Id} --> Case id is displayed correctly.
alert('Case Id # ' caseId )
<aura:set attribute="caseId" value="{!cse.Id}" /> ---> Trying to assign to caseId variable.
<p><a onclick="{!c.handleClick}">{!cse.CaseNumber}</a></p>
<td> {!cse.Id} </td>
<td> {!cse.CaseNumber} </td>
<td> {!cse.Owner.Name} </td>
<td> {!cse.Case_State__c} </td>
<td> {!cse.Priority} </td>
<td> {!cse.Status} </td>
<td> {!cse.Case_Sub_Status__c} </td>
</tr>
</aura:iteration>
Controller
handleClick : function(component, event, helper) {
alert('Case ID Before # ' + component.get("!v.caseId"));
//alert('Record Id # ' + component.get("v.cases.Id"));
//component.set("v.recordId", component.get("v.caseId"));
//var recordId = {v.cse.Id};
//alert('Record ID After # ' + recordId);
var sObectEvent = $A.get("e.force:navigateToSObject");
sObectEvent.setParams({
"recordId": "{!v.caseId}",
"slideDevName": "detail"
});
sObectEvent.fire();
Here I am unable to get the caseId. pls help with this.
Don't write alerts in the code. instead use console.log();
Uncaught Assertion Failed!: Unable to get value for key '!v.caseId'. No value provider was found for '!v'. : false
Hi,
I am trying to achieve the same thing. I need to open the detail page of the record on click of hyperlink in my component.But it is not working.
Can you pls check what am I missing here.
Here is my Code-
APEX Method -
@AuraEnabled
public static List<Announcements__c> getTrainingDetails() {
String year = String.valueOf(Date.today().year());
Integer monthNum = Date.today().month();
System.debug(monthNum);
List<Announcements__c> A = [SELECT Id, Training_Name__c, Training_Date__c,RecordTypeId
FROM Announcements__c where RecordType.name ='Trainings'];
List<Announcements__c> todayList= new List<Announcements__c>();
for(Announcements__c TrainingRecord :A)
{
if(TrainingRecord.Training_Date__c >= date.today()){
todayList.add(TrainingRecord);
}
}
return todayList;
}
Aura Component-
<aura:component controller="ctrl" implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" >
<aura:attribute name="recId" type="String"/>
<aura:attribute name="Training" type="Announcements__c[]"/>
<aura:handler name="init" value="{!this }" action="{! c.init }"/>
<lightning:card class="slds-text-heading_Medium" iconName="utility:announcement" title="Upcoming Training Announcement">
<aura:iteration items="{!v.Training}" var="Training">
<div class="slds-p-top_xx-large">
<p class="slds-p-horizontal_Small">
<a data-Trainingid="{!Training.Id}" onclick="{!c.handleClick}">
{!Training.Training_Name__c}
</a>
</p>
<p class="slds-align_absolute-right ">
{!Training.Training_Date__c}
</p>
</div>
</aura:iteration>
</lightning:card>
</aura:component>
Aura Js controller-
({
handleClick : function(component, event, helper) {
var recordId = event.target.dataset.Trainingid;
var sObectEvent = $A.get("e.force:navigateToSObject");
sObectEvent.setParams({
"recordId": recordId,
"slideDevName": "detail"
});
sObectEvent.fire();
}
})