• Prashant Bhatt 2
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
HI everyone, 

I am working on salesforce Lightning movement and got stuck while converting a Intacct classic button to lightning button.

Process
We have 'Sync to Intacct' button which calls a intacct URL to sync up SF data to intacct.
we need to pass session Id and partner_server_url in the url.

Issue
Now when I am trying to create a lightning component for this button, I am getting error ' Unable to validate Salesforce.com session is active'.
I have gone thorugh couple of post and found that UserInfo.getSessionId() do not work in lightning component.

So I have tried creating a VF page to get the session id
<apex:page standardStylesheets="false" lightningStylesheets="false">
    <body>
        <span style="display: block">
            SESSION_ID_START{!$Api.Session_ID}SESSION_ID_END
        </span>
    </body>
</apex:page>
I am using this session Id in my page
@AuraEnabled
    webService static String getSessionIdFromVFPage() {
            
            //PageReference page = new PageReference('apex/SessionId');
            PageReference PageSessionId = Page.SessionId;
            String pageContent = PageSessionId.getContent().toString();
         System.debug(pageContent);
            String SESSION_ID_START = 'SESSION_ID_START';
            String SESSION_ID_END = 'SESSION_ID_END';
            
            Integer startIndex = pageContent.indexOf(SESSION_ID_START) + SESSION_ID_START.length();
            Integer endIndex = pageContent.indexOf(SESSION_ID_END);
        System.debug(endIndex);
            //System.assert( false, PageSessionId.getContent().toString() );
            //System.assert( false, pageContent.substring(startIndex) );
            //System.assert( false, startIndex + ':' + endIndex );
            String sessionId=pageContent.substring(startIndex, endIndex);
            System.debug(sessionId);
            return sessionId;
}

Now when I am calling this function in my component I am getting error index out of bound -1  -cmp.get("c.getSessionIdFromVFPage");

Also, When I am trying to use the same controller function using anonymous block I get the desired result.

I have followed below post-
https://salesforce.stackexchange.com/questions/110515/getting-session-id-in-lightning

Thanks in advance.
 
Hi Guys, 

Has anyone tried Cybersource silent order API integration with Salesforce? Looking for some help.
Thanks in advance.

Thanks,
Prashant.
Hi Guys, 

Has anyone tried Cybersource silent order API integration with Salesforce? Looking for some help.
Thanks in advance.

Thanks,
Prashant.