Last active
June 23, 2018 07:56
-
-
Save jenishshingala/a9f68dfa8ebf6f0d7c1696e6b2f327af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreateQuote{ | |
@AuraEnabled | |
public static Opportunity getOpportunity(Id taskid) { | |
system.debug('ID-->'+taskid); | |
//Get all fields which needs to be prepopulated on Quote . | |
Task objTask = [SELECT Id, whatid FROM task WHERE Id = :taskid]; | |
Opportunity objOpportunity = [select id,account.name,account.billingcity,account.billingcountry,account.billingstate, | |
account.billingpostalcode,accountid,name,account.BillingStreet from opportunity where id=:objTask.whatid]; | |
return objOpportunity; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component controller="CreateQuote" implements="force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global" ><aura:component controller="CreateQuote" implements="force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global" > | |
<aura:attribute name="opportunity" type="Opportunity"/> | |
<!--On Load action which redirects to Standard Create Quote New page--> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<div class="exampleHolder"> | |
<lightning:spinner variant="brand" size="medium" alternativeText="Loading"/> | |
</div> | |
</aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.THIS.exampleHolder{ | |
position: relative; | |
display: inline-block; | |
margin-top: 100px; | |
margin-left: 282px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit: function(component, event, helper) { | |
//Of lighting Action popup afte 1 second. | |
window.setTimeout( | |
$A.getCallback(function() { | |
$A.get("e.force:closeQuickAction").fire(); | |
}), 1000 | |
); | |
console.log('Onload function call V5'); | |
//Server side action call to retrieve opportunity (what id from task). | |
var action = component.get("c.getOpportunity"); | |
action.setParams({"taskid": component.get("v.recordId")}); | |
// Configure response handler | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if(component.isValid() && state === "SUCCESS") { | |
//Set return opportunity value to attribute. | |
component.set("v.opportunity", response.getReturnValue()); | |
//Event to call createrecord. | |
var createRecordEvent = $A.get("e.force:createRecord"); | |
//Set parameters like which object record you want to create,record type id etc. | |
createRecordEvent.setParams({ | |
"entityApiName": "Quote", | |
//"recordTypeId": "0120L000000VlevQAC", | |
//Assign all default values. | |
"defaultFieldValues": { | |
'Name':component.get("v.opportunity.Name"), | |
'OpportunityId':component.get("v.opportunity.Id"), | |
'AccountId':component.get("v.opportunity.AccountId"), | |
'BillingCity':component.get("v.opportunity.Account.BillingCity"), | |
'BillingCountry':component.get("v.opportunity.Account.BillingCountry"), | |
'BillingName':component.get("v.opportunity.Account.Name"), | |
'BillingPostalCode':component.get("v.opportunity.Account.BillingPostalCode"), | |
'BillingState':component.get("v.opportunity.Account.BillingState"), | |
'BillingStreet':component.get("v.opportunity.Account.BillingStreet") | |
} | |
}); | |
createRecordEvent.fire(); | |
} else { | |
console.log('Problem getting Case, response state: ' + state); | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment