Salesforce 顶点

Posted

技术标签:

【中文标题】Salesforce 顶点【英文标题】:Salesforce Apex 【发布时间】:2013-09-27 15:30:49 【问题描述】:

我需要帮助来获得适合课程的语法。我有两个班级说class1class2。两者都有一个子类类型作为返回类型。如何将变量从一个类返回到另一个类,解析如下?

public class class1 

    public class Result1 
    
        public Decimal a1  get; set; 
        public Decimal b1  get; set; 
        public Decimal c1  get; set; 
        public Decimal d1  get; set; 
    

    public Result1 method1 (id recId) 
      
        ... some logic...
        ......

        Result1 r1 = New Result1();
        r1.a1 = some value;
        r1.b1 = some value;
        r1.c1 = some value;

        return r1;
    


global class class2 

    global class Result2 
    
        public Decimal a2get;set;
        public Decimal b2get;set;
        public Decimal c2get;set;
        public Decimal d2get;set;
    

    global Result2 method() 

        ... some logic...
        ......

        Result2 r2 = New Result2();

        class1 c1 = new class1();

        **r2 = c1.method1(rid);** <-- How can I get the result1 from method1 and parse it and assign                 it to each variable in r2?

        like r2.a2 = c1.method1(rid).a1;
        like r2.b2 = c1.method1(rid).b1;
        like r2.c2 = c1.method1(rid).c1;

   

【问题讨论】:

【参考方案1】:

class1.Result1 r2 = c1.method1(rid);

【讨论】:

【参考方案2】:

谢谢安德鲁,我得到了如下解决。希望它会帮助别人。

public class class1 

    public class Result1 
        public Decimal a1 get; set;
        public Decimal b1 get; set;
        public Decimal c1 get; set;
        public Decimal d1 get; set;
    

    public Result1 method1 (id recId ) 
        //... some logic...

        Result1 r1 = New Result1();
        r1.a1 = some value;
        r1.b1 = some value;
        r1.c1 = some value;

        return r1;
    



global class class2 

    global class Result2 
        public Decimal a2 get; set;
        public Decimal b2 get; set;
        public Decimal c2 get; set;
        public Decimal d2 get; set;
    

    global Result2 method()  
        //... some logic...

        Result2 r2 = New Result2();

        class1 c1 = new class1();
        class1.Result1 r1 = new class1.Result1 ();
        r1 = c1.method1(rid);

        r2.a2 = r1.a1;
        r2.b2 = r1.b1;
        r2.c2 = r1.c1;
   


【讨论】:

以上是关于Salesforce 顶点的主要内容,如果未能解决你的问题,请参考以下文章

Salesforce:如果当前用户有权更新当前记录,如何仅呈现顶点。记录级别的安全性

APEX 中的 Salesforce UserInfo 会话类型

使用Salesforce.com平台中的APEX在数字前使用零生成xls文件

salesforce是啥意思

在不使用SalesForce Webview的情况下登录iOS的SalesForce?

salesforce啥意思