function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Paul MargineanPaul Marginean 

Custom JS button converted to Lightning not behaving correctly

Hi everyone,

I converted a JavaScript button to Lightning and although the button does its job, it is behaving differently. It is a 'Sync with Pardot' button that takes the information from Pardot and brings it to Salesforce and vice-versa, to make sure that the most up-to-date info is present in both.

The Classic button looks like this:
window.location = 'https://pi.pardot.com/prospect/sync/email/{!Contact.Email}?contact_id={!Contact.Id}&sessionid={!$Api.Session_ID}&serverurl={!$Api.Partner_Server_URL_90}&redirect_location='+window.location

The user that clicks on this button only sees that the page refreshes and they can carry on with their job.

The one converted to Lightning with the tool that SF provides is this:
https://pi.pardot.com/prospect/sync/email/{!Contact.Email}?contact_id={!Contact.Id}&sessionid={!$Api.Session_ID}&serverurl={!$Api.Partner_Server_URL_90}&redirect_location='+window.location

The problem with the Lightning one is that it opens a new tab with a Pardot page with this URL being displayed: https://pi.pardot.com/%27+window.location. Of course, the user would just have to close the tab (the sync with Pardot is performed without issues), but it would be a major disruption in the process, since some users could be confused by the new tab that opens and does not close.

Can you let me know what edits should be brought to the Lightning button to make it work like the classic one? Or at least to not open an unusable tab anymore.

Thank you lots!!

Paul