On the Lightning for Outlook, I do have a record creation button component. Clicking on it gets the custom record type selection. Based on what we choose(radio button), force:createRecord event fires.
Ltng.cmp
<aura:iteration items="{!v.RTypeList}" var="rType">
<span class="slds-radio">
<input type="radio" aura:id = "radioId" id="{!rType}" name="options" value="{!rType}" />
<label class="slds-radio__label" for="{!rType}">
<span class="slds-radio--faux"></span>
<span class="slds-form-element__label">{!rType}</span>
</label>
</span>
</aura:iteration>
NOTE: RTypeList contains all the record type labels(using controller class).
Cmp.Js
var rTypeLabel= document.querySelector('input[name="options"]:checked').value;
var action = component.get("c.getRTypeId");
action.setParams({
"rTypeLabel": rTypeLabel
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var createRecordEvent = $A.get("e.force:createRecord");
var RTID = response.getReturnValue();
createRecordEvent.setParams({
"entityApiName": 'Account',
"recordTypeId": RTID
});
createRecordEvent.fire();
} else if (state === "ERROR") {
alert("ERROR! Please contact support!");
}
});
$A.enqueueAction(action);
Controller.apxc
@AuraEnabled
public static Id getRTypeId(String rTypeLabel){
System.debug('From Class: ' +rTypeLabel);
if(rTypeLabel!= ''){
Id rtypeid = Schema.SObjectType.Account.getRecordTypeInfosByName().get(recordTypeLabel).getRecordTypeId();
return rtypeid ;
}
return null;
}
Every time I run this component on an LightningAPP (to preview), debug log returns me the correct record type label. But when I run this same component on the "Lightning for Outlook", I get the log as "From Class: on" thus throwing me the error. Where I am doing wrong?