Salesforce Apex-返回类型映射无效<;字符串,EmbeddedClass>;

Salesforce Apex-返回类型映射无效<;字符串,EmbeddedClass>;,salesforce,apex,Salesforce,Apex,我有一个Salesforce Apex类,它增强了自定义按钮的功能。我想为后端键/值对提供前端的信息 我正在努力的是能够让这个新类保存。我收到的错误是: 返回类型无效:映射到第37行第51列 我已经检查了传递到ResponseWrapper.value的所有值是否都是字符串列表。在这一点上,我不太确定该怎么做 global class ButtonCaseHandler { private static final String defaultNewCaseRecordType = 'ID1'

我有一个Salesforce Apex类,它增强了自定义按钮的功能。我想为后端键/值对提供前端的信息

我正在努力的是能够让这个新类保存。我收到的错误是:

返回类型无效:映射到第37行第51列

我已经检查了传递到ResponseWrapper.value的所有值是否都是字符串列表。在这一点上,我不太确定该怎么做

global class ButtonCaseHandler {

private static final String defaultNewCaseRecordType = 'ID1';

private static List<String> getGhsOpenCases(String memberId, String dependentId){
    List<String> result = new List<String>();
    try{
        //1. check all GHS open cases for this member within the last 14 days
        List<Case> openCases = [
            SELECT Id, casenumber,super_diagnosis__c, CreatedDate
              FROM Case
             WHERE recordTypeId IN ('ID1','ID2')
               AND createdDate >= LAST_N_DAYS:14
               AND status = 'Open'
               AND Account.member_id__c = :memberId
               AND (Account.dependent_id__c = :dependentId OR Account.dependent_id__c = null)
          ORDER BY CreatedDate ASC
        ];

        for(Case c : openCases){
            result.add('Case, '+c.casenumber+', has a super diagnosis of '+ c.super_diagnosis__c + 'and was created on '+ c.createdDate.format('dd-MMM-yyyy'));
        }
    }
    catch(Exception e){
    }

    return result;
}

webService static Map<String,ResponseWrapper> AccountCreateCase(Id aId){
    Map<String, ResponseWrapper> result = new Map<String,ResponseWrapper>();
    try{
        Account currentAccount = [
                                    SELECT Id, Viewing_User_Profile_Name__c, member_id__c, 
                                           Policy__c, Name, dependent_id__c
                                      FROM Account 
                                     WHERE Id = :aId
                                     LIMIT 1
                                ];        

        //create the mapping between profile names and case record types
        Map<String,String> profileNameToReRecordTypeId = new Map<String,String>();
        profileNameToReRecordTypeId.put('RCNAME1','ID1');                                
        profileNameToReRecordTypeId.put('RCNAME2','ID2');
        profileNameToReRecordTypeId.put('System Administrator','ID1');

        String caseRecordType = profileNameToReRecordTypeId.get(currentAccount.Viewing_User_Profile_Name__c);

        if(String.isBlank(caseRecordType)){
            caseRecordType = defaultNewCaseRecordType;
        }

        ///validation if it's a GHS profile
        if(currentAccount.Viewing_User_Profile_Name__c == 'RCNAME1'){
            List<String> ghsOpenCasesString = ButtonCaseHandler.getGhsOpenCases(currentAccount.member_id__c,currentAccount.dependent_id__c);

            if(!ghsOpenCasesString.isEmpty()){
                ResponseWrapper oc = new ResponseWrapper();
                oc.value = ghsOpenCasesString;
                result.put('openCases',oc);
                ResponseWrapper ic = new ResponseWrapper();
                ic.value = new List<String>{'true'};                    
                result.put('invokeConfirm',ic);
            }
        }

        //create the URL hack for the time being. 
        ///we will want to update this later on to create the case and relocate to the newly created case
        String relocateUrl = '/500/e?RecordType=URLTORELOCATETHEUSERTO';

        ResponseWrapper ru = new ResponseWrapper();
        ru.value = new List<String>{relocateUrl}; 
        result.put('relocateUrl',ru);


    }
    catch(Exception e){
        System.debug('Error in AccountCreateCase method: ' + e);
        //instantiate the error long class
        ErrorLog errorLog = new ErrorLog();               
        ErrorLog__c methodErr = new ErrorLog__c(
            method_name__c = 'AccountCreateCase',
            method_source__c = 'ButtonCaseHandler',
            stack_trace__c = e.getMessage(),
            application_data__c = '{"accountId": '+aId+'}'
        );
        errorLog.logError(methodErr, true, '');   
    }

    return result;
}

global class ResponseWrapper {
    webService List<String> value {get; set;}
}    
全局类ButtonCaseHandler{
私有静态最终字符串defaultNewCaseRecordType='ID1';
私有静态列表getGhsOpenCases(字符串memberId、字符串dependentId){
列表结果=新列表();
试一试{
//1.在过去14天内检查该成员的所有GHS未决案件
列出未结案件=[
选择Id、案例编号、超级诊断、创建数据
从案例
其中recordTypeId位于('ID1','ID2')
和createdDate>=最后几天:14
和状态='打开'
和Account.member\u id\u c=:memberId
和(Account.dependent\u id\u c=:dependentId或Account.dependent\u id\u c=null)
按CreatedDate ASC订购
];
对于(案例c:开放案例){
结果.add('Case'+c.casenumber+',具有超级诊断'+c.super_diagnosis__c+',并且是在'+c.createdDate.format('dd-MMM-yyyy')上创建的;
}
}
捕获(例外e){
}
返回结果;
}
webService静态映射AccountCreateCase(Id辅助){
映射结果=新映射();
试一试{
帐户当前帐户=[
选择Id、查看用户配置文件、姓名、成员Id、,
策略,名称,从属id
从帐户
其中Id=:aId
限制1
];        
//创建配置文件名称和案例记录类型之间的映射
Map ProfileNameToRecordTypeId=新映射();
profileNameToReRecordTypeId.put('RCNAME1','ID1');
profileNameToReRecordTypeId.put('RCNAME2','ID2');
ProfileNameToRecordTypeId.put('System Administrator','ID1');
字符串caseRecordType=ProfileNameToRecordTypeId.get(currentAccount.Viewing\u User\u Profile\u Name\uC);
if(String.isBlank(caseRecordType)){
caseRecordType=defaultNewCaseRecordType;
}
///验证是否为GHS配置文件
如果(currentAccount.Viewing\u User\u Profile\u Name\u c=='RCNAME1'){
List GHSOPENCASESTRING=ButtonCaseHandler.getGhsOpenCases(currentAccount.member\u id\u c,currentAccount.dependent\u id\u c);
如果(!ghsOpenCasesString.isEmpty()){
ResponseWrapper oc=新的ResponseWrapper();
oc.value=ghsOpenCasesString;
结果。put('openCases',oc);
ResponseWrapper ic=新的ResponseWrapper();
ic.value=新列表{'true'};
结果。put('invokeConfirm',ic);
}
}
//暂时创建URL黑客。
///我们将在稍后更新此内容以创建案例并重新定位到新创建的案例
字符串relocateUrl='/500/e?RecordType=URLTORELOCATETHEUSERTO';
ResponseWrapper ru=新ResponseWrapper();
ru.value=新列表{relocateUrl};
结果。put('EURL',ru);
}
捕获(例外e){
System.debug('AccountCreateCase方法中的错误:'+e);
//实例化错误长类
ErrorLog ErrorLog=新的ErrorLog();
ErrorLog\uuuu c methodErr=新的ErrorLog\uuu c(
方法_name_uuc='AccountCreateCase',
方法\u源\u c='ButtonCaseHandler',
堆栈跟踪c=e.getMessage(),
应用程序_数据_uc='{“accountId”:'+aId+'}'
);
logError(methodErr,true,”);
}
返回结果;
}
全局类响应包装器{
webService列表值{get;set;}
}    
}


谢谢你的帮助

问题是由于当方法是web服务时,不支持将映射作为返回类型。SOAP不支持映射,所以您需要转换为列表列表,其中有一个键列表,然后是一个值列表

为什么这甚至是一个Web服务?您可以创建一个自定义按钮,启动运行逻辑的Visualforce页面。