1

i have created component for creating new opportunity record whenever user click new opportunity button custom object detail page. It is working fine in lightning experience window but not in partner portal.

**Issue:** If i click the button on partner portal it's opening partially and immediately closing the window.

Can you anybody help me to fix the issue.

**`Component:`** 

<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global"
                controller="NewOpportunityCreation">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

Component Controller:

({
    doInit : function(component, event, helper) {
        var action = component.get("c.getEmployeeobject");
        action.setParams({"EmpId":component.get('v.recordId')});

        // Configure response handler

        action.setCallback(this, function(response) {           
            var state = response.getState();       
            if(state === "SUCCESS") {     
                var returnVal = response.getReturnValue();
                if($A.util.isEmpty(returnVal)){
                    $A.get("e.force:closeQuickAction").fire();
                    return;
                }
                var createRecordEvent = $A.get("e.force:createRecord");
                createRecordEvent.setParams({
                    "entityApiName": "Opportunity",
                    "defaultFieldValues": {
                        'AccountId' : returnVal.AccountId,
                        'Emp__c' : component.get('v.recordId')
                    },
                    "recordTypeId":returnVal.RecordTypeId
                });
                createRecordEvent.fire();
                $A.get("e.force:closeQuickAction").fire();
            } else if (state == "ERROR"){

            } 

        });
        $A.enqueueAction(action);           
    },
})

**Apex Class:**

public class NewOpportunityCreation {
    @AuraEnabled
    public static wrappClass getEmployeeobject(String EmpId){
        wrappClass wrapcls = new wrappClass();
        try{
            wrapcls.AccountId = [Select Account__c from Emp__c where Id=:EmpId].Account__c;
            wrapcls.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OPP').getRecordTypeId();
        }catch(Exception ex){
            System.debug('Exction Occured'+ex.getMessage());
        }
        return wrapcls;
    }

    public class wrappClass{
        @AuraEnabled
        public Id AccountId {get;set;}
        @AuraEnabled
        public Id RecordTypeId {get;set;}
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.