Skip to main content
Mohammed Shafiq 님이 * Lightning Now! *에 글을 올렸습니다

Hi everyone,

 

I have the following javascript button, which I need to migrate to lightning.  I have had an attempt with actions using a lightning component and a visualforce page but no joy with my limited experience as a developer.

 

Can someone please tell me the best approach and provide step by step instructions to move the following JS code to lightning:

 

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

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

 

var myquery = "SELECT Solution_Type__c FROM Opportunity WHERE Id = '{!Opportunity.Id}' limit 1"; 

result = sforce.connection.query(myquery); 

records = result.getArray("records"); 

 

var oppQuery = records[0]; 

var solution = oppQuery.Type__c; 

if (solution == "Project") 

{

alert('Sorry this button can only be used for certain opportunities. This is a project solution type.'); 

else 

 

if (window.confirm("Have you attached relevant information to the opportunity?") == true) 

 

var reason = prompt("What would you like assistance with?", ""); 

if (reason != "" && reason != null) 

var oppToUpdate = new sforce.SObject("Opportunity"); 

oppToUpdate.Id = '{!Opportunity.Id}'; 

oppToUpdate.updateWF__c = "TRUE"; 

oppToUpdate.Prompt__c = reason; 

 

var result = sforce.connection.update([oppToUpdate]); 

 

if(result[0].getBoolean("success")) 

window.location.reload(); 

 

}

else 

alert('Error updating updateWF__c: '+result); 

else 

alert('assistance has not been requested, please enter a description'); 

else 

//Do nothing. 

 

}

 

Thanks in advance!

댓글 1개
  1. 2018년 7월 18일 오후 5:05
    You can reproduce all of this functionality in a Flow.
0/9000