自定义Salesforce Lightning App,显示“您无权访问此记录”

问题描述

名为“ Stack”的自定义闪电应用程序提供“您无权访问此记录,请联系” 尝试遵循How To Implement Full Search in Case Type using Salesforce?

中的步骤

enter image description here

这是自定义对象ERT案例类型数据的组织范围默认值

enter image description here

这是stack.aspx的 Apex 代码

                public class Stack {
                      @AuraEnabled(cacheable=true)
                    public static List<LookupSearchResult> search(String searchTerm,List<String> selectedIds){
                        if(String.isBlank(searchTerm) || searchTerm.length() < 2){
                            return null;
                        }
                        String t = '%' + searchTerm + '%'; // decide how you want to search,"starts with","includes" or what
                        
                        List<ERT_Case_Type_Data__c> records = [SELECT Id,Name,Level_1__c,Level_2__c,Level_3__c
                            FROM ERT_Case_Type_Data__c
                            WHERE Level_1__c LIKE :t OR Level_2__c LIKE :t OR Level_3__c LIKE :t
                            ORDER BY Level_1__c,Level_3__c
                            LIMIT 20];
                        
                        /* You could also experiment with SOSL?
                        records =  [FIND :('*' + searchTerm + '*') IN ALL FIELDS 
                            RETURNING Case_Type_Data__c(Id,Level_3__c)][0];
                        */
                        
                        List<LookupSearchResult> results = new List<LookupSearchResult>();
                        for(ERT_Case_Type_Data__c ctd : records){
                            results.add(new LookupSearchResult(ctd.Id,'ERT_Case_Type_Data__c','standard:case_wrap_up',ctd.Name,String.join(new List<String>{ctd.Level_1__c,ctd.Level_2__c,ctd.Level_3__c},'; ')
                            ));
                        }
                        return results;
                    } 

                }

这是 Aura组件(HTML部分)

                <aura:component implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="Stack">
                    <aura:attribute access="global" type="List" name="selection" default="[]"/>
                    <aura:attribute access="global" type="List" name="errors" default="[]"/>

                    <lightning:card title="New Case Type">
                        
                        <lightning:recordEditForm aura:id="myForm" objectApiName="ERT_Case_Type__c" onsubmit="{!c.onSubmit}" onsuccess="{!c.onSuccess}">
                        <lightning:messages />
                        <c:Lookup selection="{!v.selection}" onSearch="{!c.lookupSearch}" onSelection="{!c.useSelected}" errors="{!v.errors}" label="Search" placeholder="Search Case Types Data"/>
                        <lightning:inputField aura:id="Level_1__c" fieldName="Level_1__c" />
                        <lightning:inputField aura:id="Level_2__c" fieldName="Level_2__c" />
                        <lightning:inputField aura:id="Level_3__c" fieldName="Level_3__c" />
                        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="save" label="Save" />
                    </lightning:recordEditForm>
                    </lightning:card>
                </aura:component>

这是 Aura组件-JS控制器部分

({
    lookupSearch : function(component,event,helper) {
    // Get the lookup component that fired the search event
    const lookupComponent = event.getSource();
    const serverSearchAction = component.get('c.search');
    lookupComponent.search(serverSearchAction);
},useSelected: function(component,helper) {
    const selection = component.get('v.selection');
    const errors = component.get('v.errors');
    
    if (selection.length) {
        if(errors.length){  // Clear errors,if any
            component.set('v.errors',[]);
        }
        let levels = selection[0].subtitle.split('; ');
        component.find('Level_1__c').set('v.value',levels[0]);
        component.find('Level_2__c').set('v.value',levels[1]);
        component.find('Level_3__c').set('v.value',levels[2]);
    }
},onSubmit: function(component,helper) {
    debugger;
    event.preventDefault();       // stop the form from submitting
    var fields = event.getParam('fields');
    fields.Case__c = component.get('v.recordId'); // link to "this" Case
    component.find('myForm').submit(fields);
},onSuccess: function(component,helper){
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        "title": "Success!","message": "Case Type saved OK,refreshing","type": "success"
    });
    toastEvent.fire();
    $A.get('e.force:refreshView').fire(); // reload page
   }
})

请帮助我消除此访问错误

关于, 卡罗琳

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)