In my component I have this formattedURL :
<lightning:formattedUrl
value="{!notification.objectUrl}"
label="{!notification.objectName}"
target="_self" />
I make my notification in my Helper where I use a JSON that I get from a POST call. When I receive the JSON I have a phone number and from it I find the object that possess this number.
So basically I have something like that :
const newNotification = {
time: $A.localizationService.formatDateTime(
message.data.payload.CreatedDate,
"HH:mm"
),
message: messageText,
user: userId,
objectType: objectType,
objectName: objectName,
ObjectId: objectId,
objectUrl: "MyURL",
phone: phone
};
const notifications = component.get("v.notifications");
notifications.push(newNotification);
component.set("v.notifications", notifications);
When the Phone number is unknow from salesforce I modify it this way :
const newNotification = {
time: $A.localizationService.formatDateTime(
message.data.payload.CreatedDate,
"HH:mm"
),
message: "New Call !",
user: "",
objectType: "",
objectName: "Unknow",
ObjectId: "",
objectUrl: "",
phone: res.Phone
};
// Save notification in history
const notifications = component.get("v.notifications");
notifications.push(newNotification);
component.set("v.notifications", notifications);
So in my formattedURL
I use objectName
(here Unknow) and the objectURL
to get a link to the object through a call history. Now when the phone number is unknow I want put a link to an another component that will allow the user to search in salesforce. I already used $A.get("e.force:navigateToComponent");
that I use to open my component automatically. But I want to give a way to open it later through history. How can I get the url value of an another component ?