Skip to main content

#Javascript Buttons0 discussing

Hi Everyone, I am new to salesforce and need some guidance to convert a javaScript button to lightning. I have already checked a few resources such as: 

 

https://developer.salesforce.com/blogs/2018/06/convert-javascript-buttons-to-lightning-friendly-alternatives-with-the-lightning-experience-configuration-converter.html

 

https://trailhead.salesforce.com/content/learn/modules/lex_javascript_button_migration/javascript_buttons_to_lightning_actions

 

https://help.salesforce.com/articleView?id=lcc_javascript_buttons_overview.htm&type=5

 

This button does not even show for me to convert  on this page (https://lightning-configuration.salesforce.com/javascript-buttons.xhtml

 

Don't know what else to do here, here is the code I have on this button, 

 

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

{!REQUIRESCRIPT("//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js")}

 

function addOnClicks() {

$('.sowButton').click(function() {

generateSOW($(this).attr('docType'));

});

}

 

var box;

function insertScript(){

box = new SimpleDialog("hersh"+Math.random(), true);

parent.box = box;

box.createDialog();

box.setWidth('20%');

 

if ('{!$Profile.Name}' == 'Solution Engineer' || '{!$Profile.Name}' == 'System Administrator' || '{!$Profile.Name}' == 'Professional Services') {

box.setContentInnerHTML('<div><center><p>Which type of document would you like to generate?</p><button class="sowButton" docType="pdf">Pdf</button><button class="sowButton" docType="doc">Word</button></center></div><button class="btn" onclick="window.parent.box.hide(); return false;">Close</button>');

} else {

generateSOW('pdf');

}

 

box.setupDefaultButtons();

box.show();

 

addOnClicks();

}

 

function generateSOW(docType) {

box.setContentInnerHTML('<div><center><p>Loading SOW. Please wait..</p><img src="/img/loading.gif"/></center></div>');

 

sforce.apex.execute("ZuoraDocumentGenerator","generateSOW",{quoteId:"{!zqu__Quote__c.Id}", docType:docType}, function(result) {

box.setContentInnerHTML('<div><center><p>' + result + '</p></center></div><button class="btn" onclick="window.parent.box.hide(); return false;">Close</button>');

});

}

 

insertScript();

 

Can someone able to provide me some help to convert this button to lighting action? thank you.  

0/9000

Javascript buttons working in Lightning?

 

I am working through several Javascript buttons that were identified in the Lightning conversion tool. In testing though, several of the buttons are still continuing to work as they did in Classic while using the Lightning UI. Is this normal? Are there some buttons, depending on the code, that won't need to be converted?

3 comments
0/9000

I have some javascript buttons (List Button) on object, while running Configuration converter those  JS buttons are not showing in scan list.  

Is there any sample code to convert button into lightning actions and components. Any help is much appreciated. 

 

Below is sample code in classic for javascript button

 

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit

{!REQUIRESCRIPT('/soap/ajax/33.0/apex.js')}

 

var url = parent.location.href; //string for the URL of the current page

var records = {!GETRECORDIDS($ObjectType.Account)}; //grabs the Account records that the user is requesting to update

var updateRecords = []; //array for holding records that this code will ultimately update

 

if (records[0] == null) { //if the button was clicked but there was no record selected

alert("Please select at least one record to update."); //alert the user that they didn't make a selection

}

if (records.length > 1) { //if the button was clicked but there was no record selected

alert("Please select only one record to update."); //alert the user that they didn't make a selection

}else { //otherwise, there was a record selection

for (var a=0; a<records.length; a++) { //for all records

var update_Account = new sforce.SObject("Account"); //create a new sObject for storing updated record details

update_Account.Id = records[a]; //set the Id of the selected Account record

sforce.apex.execute("ActiveAccount","ActiveAccount",

{AccountID : update_Account.Id});

}

//push the updated records back to Salesforce

parent.location.href = url; //refresh the page

}

1 comment
  1. Dec 18, 2019, 2:10 PM
    Hi @Mayur Gupta

    , You could check it on the "Files" tab in the "jsButtons-*" CSV file.

    This Conversion Type is Manual, because List view buttons aren't supported, as an alternative you could use a Custom Visualforce buttons on list views. Please have a look at this link below in the "Custom Visualforce buttons on list views" section

    https://trailhead.salesforce.com/en/content/learn/modules/lex_javascript_button_migration/javascript_button_alternatives
0/9000

Hi - I have 35 JavaScript buttons that are not working in Lightning. I went to the Lightning Experience Configuration Converter and followed all the steps to convert them. Unfortunately, none of them are working in Lightning. 

 

The Reason for all of them is "Mass action buttons aren't supported" and the User Impact is "Can't be calculated for this button type"

 

The similarity all these buttons share is that they pre-populate some fields upon clicking them (Primary Contact, Date, Deal of Interest, etc.)

 

In classic, all of these buttons work just fine. In Lightning, the buttons still appear on the page layout, but when you click on any of them, the fields do not pre-populate anything.

 

If someone has any idea on what I'm doing wrong, that would be great. Thanks!

7 comments
  1. Oct 8, 2019, 8:35 PM
    Also, at this moment I don't have information to confirm if it is planned to increase conversion support in near future releases, but there are multiple development teams working to help the transition to Lightning to be easier
0/9000

Hello! I am converting to lightning and have 2 OnClick buttons that I need some help converting.

 

I would appreciate any help that the community could provide!

 

Button 1:

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}

{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}

 

var opptyId = '{!Opportunity.Id}';

 

var revisionId = sforce.apex.execute("CreateRevisionController","createRevision",{revisionType: 'Revision', masterOpptyId: opptyId});

 

console.log(revisionId);

 

//redirect to revision page

window.location.href = '/' + revisionId;

 

Button 2:

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}

{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}

 

var opptyId = '{!Opportunity.Id}';

 

var revisionId = sforce.apex.execute("CreateRevisionController","createRevision",{revisionType: 'Revision', masterOpptyId: opptyId});

 

console.log(revisionId);

 

//redirect to revision page

window.location.href = '/' + revisionId;

5 comments
0/9000

I'm trying to work out what exactly in the config of these buttons make them JavaScript buttons? I have others with similar config which are not appearing on the JavaScript page, so very confused.

 

Button 1

/a03/e? 

Name=NEW 

&CF00ND0000006EYUB={!Financial_Summary__c.Name} 

&00ND0000006EYVl={!Financial_Summary__c.Start_On_Site__c} 

&00ND0000006EYVD={!Financial_Summary__c.Construction_Completion__c} 

&retURL={!Financial_Summary__c.Id}

 

Button 2

/a0V/e?

Name={!Project_Feedback__c.Name}/Action

&CF00ND00000068z6D={!Project_Feedback__c.Name}

&CF00ND00000068z6g={!Project_Feedback__c.Project_Name__c}

&CF00ND00000068z6e={!Project_Feedback__c.Organisation_Name_1__c}

&CF00ND00000068z6f={!Opportunity.Delivery_Project_Leader__c}

&retURL=%2F{!Project_Feedback__c.Id}

&saveURL=%2F{!Project_Feedback__c.Id}%23{!Project_Feedback__c.Id}_00ND00000068z6D_target

1 comment
  1. Sep 4, 2019, 1:42 AM
    @Claire Jones

    ,

    It seems to me that those JavaScript buttons set data onto the URL for the specific object the button resides in. Have you tried to replace the variables manually and create a URL to see the behavior?

0/9000

I am struggling trying to finish the badge "Lightning Alternatives to JavaScript Buttons" https://trailhead.salesforce.com/modules/lex_javascript_button_migration.

The 3rd unit "Discover Lightning Actions"  https://trailhead.salesforce.com/modules/lex_javascript_button_migration/units/javascript_buttons_to_lightning_actions, has a challenge that ask you to change the component "quickcontact" (installed as per instructions) before you can add the Lightning action on the  Account object.

I got to the point of editing the component using Developer Console, but really don't know what to do next while editing, before I can create the Action button.

Any help would be greatly appreciated. 

4 comments
0/9000

I have a banner showing up at the top of my production org that is showing 48 Days Until Lightning Experience. A couple of questions. I thought I had until October 12th. I recently took over this org and am working on updating Javascript buttons before we make Lightning available. Which leads to the second question, anyway to remove this?

3 comments
  1. May 22, 2019, 3:15 PM
    Thanks. That did the trick. I've run the Lightning Readiness program and it showed issues that need to be taken care of, so I'm not sure why Salesforce thought we would be good candidates for early transition.
0/9000

Hello I am just beginning the conversion for my org. I ahve a number of javascript buttons that need conversion. I tried the Lightning Experience Configuration Converter Scan for JavaScript Buttons and it came up with quite a few no surprise but it reports No data for Usage.  Is that because I ran this against a sandbox that is not used and if so is it safe to do the scan on my production environment? Thanks for any comments or responses.

4 comments
  1. Mar 17, 2019, 4:09 PM
    Also, you can always create a case with Salesforce Support if you are not able to get the converter to run.
0/9000

I have several JavaScript buttons that I need to recreate in Lightning, how do I determine if I should create a New Action or a New Button or Link?   I've tried creating a New Action where if a Active Contact box is unchecked that four other check boxes are checked.  This did not work. 

 

I also tried creating another New Action where I could pre-populate a new record with values for the fields, however, because I am using fields with multi-select picklist values, those fields won't populate according to documentation I found.  I'm not a developer, and just starting the Lightning transition.  I appreciate any advice you could give to handle these two senarios.  Thanks in advance.

6 comments
  1. Mar 15, 2019, 9:24 PM
    if the button was converted previously and then the Lightning alternative deleted then no . I would suggest to duplicate the button and move the new one using the tool. I should create a new alternative.
0/9000