Solution:- public class AttachQuoteCntrl {
public static List<string> OpportunityRecordsList;
@AuraEnabled
public static List<string> oppRecords(String recordId){
OpportunityRecordsList = new List<string>();
List<Opportunity> oppList=[SELECT id,AccountId,SyncedQuoteId,Quote_ID__c, RecordType.Id,(SELECT id FROM Quotes limit 1) FROM Opportunity WHERE id =:recordId];
for(Opportunity oppRecord : oppList){
List<Quote> quoteList=oppRecord.Quotes;
OpportunityRecordsList.add(oppRecord.RecordType.Id);
If(quoteList[0].id==null)
OpportunityRecordsList.add('noQuote');
else
OpportunityRecordsList.add(quoteList[0].id);
if(oppRecord.SyncedQuoteId==null)
OpportunityRecordsList.add('noSyncedQuote');
else
OpportunityRecordsList.add(oppRecord.SyncedQuoteId);
OpportunityRecordsList.add(oppRecord.AccountId);
OpportunityRecordsList.add(Integration_Settings__c.getInstance().Quoting_Tool_URL__c);
OpportunityRecordsList.add(Opportunity_Record_Types__c.getInstance().New_Record_Type_Id__c);
OpportunityRecordsList.add(Opportunity_Record_Types__c.getInstance().Pilot_Record_Type_Id__c);
OpportunityRecordsList.add(Opportunity_Record_Types__c.getInstance().Renew_Upsell_Record_Type_Id__c);
}
System.debug('*******OpportunityRecordsList='+OpportunityRecordsList);
return OpportunityRecordsList;
}
}
<aura:component controller ="AttachQuoteCntrl" implements="force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="String" />
<aura:attribute name="lstOfRecordType" type="String[]" />
<aura:attribute name="OpportunityRecordsList" type="List" />
</aura:component>
controller
({
doInit: function(component, event, helper) {
helper.opportunityRecordList(component);
}
})
Helper
({
opportunityRecordList: function(component) {
var action = component.get("c.oppRecords");
action.setParams({"recordId" : component.get("v.recordId")});
action.setCallback(this, function(response) {
var state = response.getState();
if(state=="SUCCESS"){
var oppId=component.get("v.recordId");
var oppRecordList = response.getReturnValue();
console.log("oppRecordList="+JSON.stringify(oppRecordList));
component.set("v.OpportunityRecordsList", oppRecordList);
console.log("Record Type Name="+oppRecordList[0]);
console.log("QuoteId="+oppRecordList[1]);
console.log("syncedQuoteId="+oppRecordList[2]);
console.log("AccountId="+oppRecordList[3]);
console.log("Quote URL="+oppRecordList[4]);
console.log("newRecord Type="+oppRecordList[5]);
console.log("Pilot record type="+oppRecordList[6]);
console.log("RenewUpsell record type="+oppRecordList[7]);
if(oppRecordList[0]==oppRecordList[5] || oppRecordList[0]==oppRecordList[6] || oppRecordList[0]==oppRecordList[7] && oppRecordList[1]!='noQuote' && oppRecordList[2]=='noSyncedQuote') {
console.log("in if condition");
window.alert("xxxxxxxxxxxxx");
//window.close();
$A.get("e.force:closeQuickAction").fire();
}
else{
console.log("in else condition");
window.open ("http:"+oppRecordList[4]+"/reps/xxxxxx.aspx?SFAccountId="+oppRecordList[3]+"&SFOppId="+oppId);
// window.close();
$A.get("e.force:closeQuickAction").fire();
}
}
else{
console.log("cannot call back apex method");
}
});
$A.enqueueAction(action)
}
})
3 answers