Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
({
handleLoad: function(component,event,helper){
},
doInit : function(component,event,helper){
//alert(component.get("v.recordId"));
var pageRef = component.get("v.pageReference");
console.log(JSON.stringify(pageRef));
var state = pageRef.state; // state holds any query params
console.log('state = '+JSON.stringify(state));
var base64Context = state.inContextOfRef;
console.log('base64Context = '+base64Context);
if (base64Context.startsWith("1\.")) {
base64Context = base64Context.substring(2);
console.log('base64Context = '+base64Context);
}
var addressableContext = JSON.parse(window.atob(base64Context));
console.log('addressableContext = '+JSON.stringify(addressableContext));
component.set("v.recordId", addressableContext.attributes.recordId);
},
handleSubmitClick: function(component,event,helper){
event.preventDefault(); // stop form submission
var eventFields = event.getParam("fields");
//eventFields["Active__c"] = true; //set fields value before submit
component.find('recordViewForm').submit(eventFields);
},
onCancel : function(component,event,helper){
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": component.get("v.recordId"),
"slideDevName": "related"
});
navEvt.fire();
},
handleSuccess: function(component, event, helper) {
//alert('success');
component.set("v.modalWindow",false);
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": component.get("v.recordId"),
"slideDevName": "related"
});
navEvt.fire();
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Response!",
"mode": 'sticky',
"type": 'success',
"message": 'Record has been created'
});
toastEvent.fire();
$A.get('e.force:refreshView').fire();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment