You need to sign in to do that
Don't have an account?
Michael M
Get user's current URL with Flow or apex
Hello, is it possible to use a lightning flow to get the user's current url (equivalent of javascript's window.location.href), using a lightnign flow? If not, is it possible with apex (not visualforce)?
Your code is answered above.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
Your code is answered above.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
public with sharing class BotUrlClass {
public class TranscriptInput {
@InvocableVariable(required=true)
public ID routableID;
}
public class VisitorUrlOutput {
@InvocableVariable(required=true)
public String urlOfMostRecentPage;
}
@InvocableMethod(label='Get User URL')
public static List<VisitorUrlOutput> getUrlName(List<TranscriptInput> transcripts) {
List<VisitorUrlOutput> urls = new List<VisitorUrlOutput>();
for (TranscriptInput transcript : transcripts) {
// Query for the transcript record based on the ID
LiveChatTranscript transcriptRecord = [SELECT Name, URL__c
FROM LiveChatTranscript
WHERE Id = :transcript.routableID
LIMIT 1];
string headerdata2= ApexPages.currentPage().getHeaders().get('Host');
string urlvalue2=Apexpages.currentPage().getUrl();
string url2='https://' + headerdata2+ urlvalue2;
// Store the url in an output variable
VisitorUrlOutput urlData = new VisitorUrlOutput();
urlData.urlOfMostRecentPage = url2;
// Add the url to the list of outputs
urls.add(urlData);
}
return urls;
}
}
Please create a new question me or my team will look into and answer your query.
How does this integrate with Screen Flow? I am unable to get value forApexpages.currentPage() which always gives null and throws attempts to dereference a null object.