Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Notice removed Improve details by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Improve details by Pavan tej
Bounty Started worth 100 reputation by Pavan tej
added 790 characters in body
Source Link
Pavan tej
  • 1.4k
  • 5
  • 43
  • 92
    ({
    doInit : function(component, event, helper) {
        var action = component.get("c.fieldCheker");
        var recordId=component.get("v.recordId");
        action.setParams({
            "recId" : recordId
        });
        action.setCallback(this, function(response){
            var state = response.getState(); 
            if(state == 'SUCCESS') {                
                var returnValue= response.getReturnValue() 
                if(returnValue!=null){
                    if(returnValue.Promo__c==null || returnValue.Promo__c =='undefined'){
                        //alert("To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.")
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title: "Error!",
                            message: "To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.",
                            type: "Error"});
                        //$A.get("e.force:closeQuickAction").fire()
                        //dismissActionPanel.fire();
                        //$A.get("e.force:refreshView").fire();
                        //toastEvent.fire(); 
                        //$A.get("e.force:refreshView").fire();
                        /*var svg = component.find("svg_content");
        var value = svg.getElement().innerText;
        value = value.replace("<![CDATA[", "").replace("]]>", "");
        svg.getElement().innerHTML = value;*/
                        component.set('v.myText','To convert this lead, Please specify whether Marketing \'Promo\' is applied or not.\nYou can update this information using the Promo field under \'Marketing Information\' section.\nThank you for your co-operation');
                    }
                    else if(returnValue.Flag_Type__c == 'Related'){
                       component.set('v.myText','You don\'t have sufficient access to convert a related lead.\nPlease swap this lead to master by clicking the swap to master button\nFor more information contact SMO team.');
                    }
                        else{
                            var/*var navLink = component.find("navigation");
                            var pageRef = {
                                type: 'standard__objectPage',
                                attributes: {
                                    actionName: "convert",
                                    objectApiName: 'Lead',
                                    recordId : recordId  
                                },
                            };
                            navLink.navigate(pageRef, true);*/
                            var urlString = window.location.href;
                            var baseURL = 'https://testaz--current.lightning.force.com';
                            //use apex or JS libraries to get the base URL
                            // urlString.substring(0, urlString.indexOf("/lightning"));
                            var urlEvent = $A.get("e.force:navigateToURL");
                            urlEvent.setParams({
                            //ws is the relative url to the redirect screen once lead is converted. right now it will got to account page
                            "url": baseURL + '/lightning/cmp/runtime_sales_lead__convertDesktopConsole?leadConvert__leadId=' + recordId + 'ws=%2Flightning%2F%2FLead%2F'+recordId+'%2Fview'
                            });
                            urlEvent.fire();
                        }
                }
            }
        });
        if(recordId !=null && 'undefined' ){
            $A.enqueueAction(action);
        }
        
    }
})
    ({
    doInit : function(component, event, helper) {
        var action = component.get("c.fieldCheker");
        var recordId=component.get("v.recordId");
        action.setParams({
            "recId" : recordId
        });
        action.setCallback(this, function(response){
            var state = response.getState(); 
            if(state == 'SUCCESS') {                
                var returnValue= response.getReturnValue() 
                if(returnValue!=null){
                    if(returnValue.Promo__c==null || returnValue.Promo__c =='undefined'){
                        //alert("To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.")
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title: "Error!",
                            message: "To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.",
                            type: "Error"});
                        //$A.get("e.force:closeQuickAction").fire()
                        //dismissActionPanel.fire();
                        //$A.get("e.force:refreshView").fire();
                        //toastEvent.fire(); 
                        //$A.get("e.force:refreshView").fire();
                        /*var svg = component.find("svg_content");
        var value = svg.getElement().innerText;
        value = value.replace("<![CDATA[", "").replace("]]>", "");
        svg.getElement().innerHTML = value;*/
                        component.set('v.myText','To convert this lead, Please specify whether Marketing \'Promo\' is applied or not.\nYou can update this information using the Promo field under \'Marketing Information\' section.\nThank you for your co-operation');
                    }
                    else if(returnValue.Flag_Type__c == 'Related'){
                       component.set('v.myText','You don\'t have sufficient access to convert a related lead.\nPlease swap this lead to master by clicking the swap to master button\nFor more information contact SMO team.');
                    }
                        else{
                            var navLink = component.find("navigation");
                            var pageRef = {
                                type: 'standard__objectPage',
                                attributes: {
                                    actionName: "convert",
                                    objectApiName: 'Lead',
                                    recordId : recordId  
                                },
                            };
                            navLink.navigate(pageRef, true);
                        }
                }
            }
        });
        if(recordId !=null && 'undefined' ){
            $A.enqueueAction(action);
        }
        
    }
})
    ({
    doInit : function(component, event, helper) {
        var action = component.get("c.fieldCheker");
        var recordId=component.get("v.recordId");
        action.setParams({
            "recId" : recordId
        });
        action.setCallback(this, function(response){
            var state = response.getState(); 
            if(state == 'SUCCESS') {                
                var returnValue= response.getReturnValue() 
                if(returnValue!=null){
                    if(returnValue.Promo__c==null || returnValue.Promo__c =='undefined'){
                        //alert("To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.")
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title: "Error!",
                            message: "To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.",
                            type: "Error"});
                        //$A.get("e.force:closeQuickAction").fire()
                        //dismissActionPanel.fire();
                        //$A.get("e.force:refreshView").fire();
                        //toastEvent.fire(); 
                        //$A.get("e.force:refreshView").fire();
                        /*var svg = component.find("svg_content");
        var value = svg.getElement().innerText;
        value = value.replace("<![CDATA[", "").replace("]]>", "");
        svg.getElement().innerHTML = value;*/
                        component.set('v.myText','To convert this lead, Please specify whether Marketing \'Promo\' is applied or not.\nYou can update this information using the Promo field under \'Marketing Information\' section.\nThank you for your co-operation');
                    }
                    else if(returnValue.Flag_Type__c == 'Related'){
                       component.set('v.myText','You don\'t have sufficient access to convert a related lead.\nPlease swap this lead to master by clicking the swap to master button\nFor more information contact SMO team.');
                    }
                        else{
                            /*var navLink = component.find("navigation");
                            var pageRef = {
                                type: 'standard__objectPage',
                                attributes: {
                                    actionName: "convert",
                                    objectApiName: 'Lead',
                                    recordId : recordId  
                                },
                            };
                            navLink.navigate(pageRef, true);*/
                            var urlString = window.location.href;
                            var baseURL = 'https://testaz--current.lightning.force.com';
                            //use apex or JS libraries to get the base URL
                            // urlString.substring(0, urlString.indexOf("/lightning"));
                            var urlEvent = $A.get("e.force:navigateToURL");
                            urlEvent.setParams({
                            //ws is the relative url to the redirect screen once lead is converted. right now it will got to account page
                            "url": baseURL + '/lightning/cmp/runtime_sales_lead__convertDesktopConsole?leadConvert__leadId=' + recordId + 'ws=%2Flightning%2F%2FLead%2F'+recordId+'%2Fview'
                            });
                            urlEvent.fire();
                        }
                }
            }
        });
        if(recordId !=null && 'undefined' ){
            $A.enqueueAction(action);
        }
        
    }
})
added 2626 characters in body; edited tags
Source Link
Pavan tej
  • 1.4k
  • 5
  • 43
  • 92

Vf pageMy Component:

<apex    <aura:pagecomponent sidebar="false"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" showHeader="false"access="global" extensions="ConvertLeads" standardController="Lead"controller="JavaScript_migration_controller">
    <aura:handler name="init" value="{!this}" action="{!updateconvertc.doInit}">"/>
<apex    <aura:pagemessagesattribute name="myText" type="string" default=""/>
     <aura:attribute name="url" type="String" />
    <aura:attribute name="pageReference" type="Object" />
 <lightning:navigation aura:id="navigation"/>
    <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert" aura:id="alerta">
  <span class="slds-assistive-text">error</span>
  <span class="slds-icon_container slds-icon-utility-error slds-m-right_x-small" title="Description of icon when needed">
  </span>
    
    <ui:outputText value="{!v.myText}"/>
</div>
</aura:component>
public with sharing class ConvertLeads({
    doInit : function(component, event, helper) {
    public ConvertLeads   var action = component.get(ApexPages"c.StandardControllerfieldCheker");
 stdCtrl       var recordId=component.get("v.recordId");
        action.setParams({
    }        "recId" : recordId
    public Pagereference updateconvert(  });
        action.setCallback(this, function(response){
        String conId   var state = ApexPagesresponse.currentPagegetState().getParameters; 
            if(state == 'SUCCESS') {                
                var returnValue= response.getgetReturnValue('id'); 
        Lead Related=[Select id,UniqueKey__c,Promo__c,Qualification_Score__c,Flag_Type__c from lead where id=:conId LIMIT 1];if(returnValue!=null){
                    if(RelatedreturnValue.Promo__cPromo__c==null ==|| nullreturnValue.Promo__c =='undefined'){
        {
            ApexPages.addMessage    //alert(new"To ApexPagesconvert this lead, Please specify whether Marketing Promo is applied or not.Message\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.")
                        var toastEvent = $A.get(ApexPages"e.Severityforce:showToast");
                        toastEvent.WarningsetParams({
                            title: "Error!", 
 'To                           message: "To convert this lead, Please specify whether Marketing \'Promo\'Promo is applied or not'+'\n'+'\n'+'Younot.\n\nYou can update this information using the Promo'Promo' field under \'Marketing'Marketing Information\'Information' section.'+'\n'+'\n'+'Thank\n\nThank you for your co-operation.'",
                            type: "Error"});
                        //$A.get("e.force:closeQuickAction").fire()
                        //dismissActionPanel.fire();
            return null;           //$A.get("e.force:refreshView").fire();
        }                //toastEvent.fire(); 
                        //$A.get("e.force:refreshView").fire();
        else if               /*var svg = component.find(integer"svg_content");
        var value = svg.valueofgetElement(Related).Qualification_Score__cinnerText;
        value = value.replace('%'"<![CDATA[",'') "")<70.replace("]]>", "");
        {svg.getElement().innerHTML = value;*/
            ApexPages.addMessage(new ApexPages           component.Messageset(ApexPages.Severity'v.WarningmyText','To 'Leadconvert this lead, Please specify whether Marketing \'Promo\' is applied or not.\nYou qualifiedcan enoughupdate tothis convert')information using the Promo field under \'Marketing Information\' section.\nThank you for your co-operation');
           return null;
        }
                    else if(RelatedreturnValue.Flag_Type__c == 'Related'){
        {
            ApexPages.addMessage(new ApexPages  component.Messageset(ApexPages.Severity'v.WarningmyText', 'You don\'t have sufficient access to convert a related lead.'+'\n'+'\n'+'Please\nPlease swap this lead to master by clicking the swap to master button'+'\n'+'\n'+'Forbutton\nFor more information contact SMO team.');
                    }
                        else{
                            var navLink = component.find("navigation");
            return null;               var pageRef = {
                                type: 'standard__objectPage',
                                attributes: {
                                    actionName: "convert",
                                    objectApiName: 'Lead',
                                    recordId : recordId  
                                },
        return null;                   };
                            navLink.navigate(pageRef, true);
                        }
                }
</apex:page>            }
        });
        if(recordId !=null && 'undefined' ){
            $A.enqueueAction(action);
        }
        
    }
})

Vf page:

<apex:page sidebar="false" showHeader="false" extensions="ConvertLeads" standardController="Lead"  action="{!updateconvert}">
<apex:pagemessages />
public with sharing class ConvertLeads {
    public ConvertLeads(ApexPages.StandardController stdCtrl) {
    }
    public Pagereference updateconvert()
    {
        String conId = ApexPages.currentPage().getParameters().get('id');
        Lead Related=[Select id,UniqueKey__c,Promo__c,Qualification_Score__c,Flag_Type__c from lead where id=:conId LIMIT 1];
        if(Related.Promo__c == null)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'To convert this lead, Please specify whether Marketing \'Promo\' is applied or not'+'\n'+'\n'+'You can update this information using the Promo field under \'Marketing Information\' section.'+'\n'+'\n'+'Thank you for your co-operation.'));
            return null;
        }
        
        else if(integer.valueof(Related.Qualification_Score__c.replace('%',''))<70 )
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'Lead not qualified enough to convert'));
           return null;
        }
        else if(Related.Flag_Type__c == 'Related')
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'You don\'t have sufficient access to convert a related lead.'+'\n'+'\n'+'Please swap this lead to master by clicking the swap to master button'+'\n'+'\n'+'For more information contact SMO team.'));
            return null;
        }
        return null;
    }
}
</apex:page>

My Component:

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global"  controller="JavaScript_migration_controller">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="myText" type="string" default=""/>
     <aura:attribute name="url" type="String" />
    <aura:attribute name="pageReference" type="Object" />
 <lightning:navigation aura:id="navigation"/>
    <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert" aura:id="alerta">
  <span class="slds-assistive-text">error</span>
  <span class="slds-icon_container slds-icon-utility-error slds-m-right_x-small" title="Description of icon when needed">
  </span>
    
    <ui:outputText value="{!v.myText}"/>
</div>
</aura:component>
    ({
    doInit : function(component, event, helper) {
        var action = component.get("c.fieldCheker");
        var recordId=component.get("v.recordId");
        action.setParams({
            "recId" : recordId
        });
        action.setCallback(this, function(response){
            var state = response.getState(); 
            if(state == 'SUCCESS') {                
                var returnValue= response.getReturnValue() 
                if(returnValue!=null){
                    if(returnValue.Promo__c==null || returnValue.Promo__c =='undefined'){
                        //alert("To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.")
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title: "Error!", 
                            message: "To convert this lead, Please specify whether Marketing Promo is applied or not.\n\nYou can update this information using the 'Promo' field under 'Marketing Information' section.\n\nThank you for your co-operation.",
                            type: "Error"});
                        //$A.get("e.force:closeQuickAction").fire()
                        //dismissActionPanel.fire();
                        //$A.get("e.force:refreshView").fire();
                        //toastEvent.fire(); 
                        //$A.get("e.force:refreshView").fire();
                        /*var svg = component.find("svg_content");
        var value = svg.getElement().innerText;
        value = value.replace("<![CDATA[", "").replace("]]>", "");
        svg.getElement().innerHTML = value;*/
                        component.set('v.myText','To convert this lead, Please specify whether Marketing \'Promo\' is applied or not.\nYou can update this information using the Promo field under \'Marketing Information\' section.\nThank you for your co-operation');
                    }
                    else if(returnValue.Flag_Type__c == 'Related'){
                       component.set('v.myText','You don\'t have sufficient access to convert a related lead.\nPlease swap this lead to master by clicking the swap to master button\nFor more information contact SMO team.');
                    }
                        else{
                            var navLink = component.find("navigation");
                            var pageRef = {
                                type: 'standard__objectPage',
                                attributes: {
                                    actionName: "convert",
                                    objectApiName: 'Lead',
                                    recordId : recordId  
                                },
                            };
                            navLink.navigate(pageRef, true);
                        }
                }
            }
        });
        if(recordId !=null && 'undefined' ){
            $A.enqueueAction(action);
        }
        
    }
})
Notice removed Canonical answer required by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Canonical answer required by Pavan tej
Bounty Started worth 50 reputation by Pavan tej
edited title
Link
Pavan tej
  • 1.4k
  • 5
  • 43
  • 92

How to redirect to standard lead convert page in lightning

deleted 1 character in body
Source Link
Pavan tej
  • 1.4k
  • 5
  • 43
  • 92
Loading
Source Link
Pavan tej
  • 1.4k
  • 5
  • 43
  • 92
Loading