3

We have a JS button in Classic which perform some checks and open the /lead/leadconvert.jsp? page with some fields prepopulated. Now we are migrating to Lightning, so for replacing the button we created quick action and redirecting the user to /lead/leadconvert.jsp?. But it is navigating to the classic page . Are there any events like force;createRecord which we can use for opening the Lead convert standard modal window.

  • Why not use standard lead convert button for the lead in lightning? – Pranay Jaiswal May 8 '18 at 14:20
  • We are checking for certain conditions. For example if field A is null, then we are throwing error message and not opening lead convert page . So we need quick actions or js buttons – Ravi Narayanan May 8 '18 at 14:22
  • You have to create a custom quickaction and embeded a lightning compoment in it. that lightning component will do all validations and then prepopulate itself. You have to write lead convert logic in Apex as far my knowledge is concerned. – Pranay Jaiswal May 8 '18 at 14:27
1

Instead of going at it the way you've done, consider blocking it with a trigger:

trigger CheckValidLeadConvert on Lead (after update) {
  for(Integer index = 0, size = Trigger.new.size(); index < size; index++) {
    if(!Trigger.old[index].IsConverted && Trigger.new[index].IsConverted) {
      // Check for whatever conditions you like
      Trigger.new[index].addError('You cannot convert this lead because blah blah blah...');
    }
  }
}

You may also be able to use validation rules as well, since they now also run on lead conversion. I realize that this is slightly less ideal than aborting early, but using a trigger will prevent a lead from being converted incorrectly in any means, including Apex Code, Visualforce, Lightning, API, and Classic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.