English 中文(简体)
Apex - 范围 - 变量
原标题:Apex - scope - variables


I have tried a lot to get this done but I dont know how to get it working. This is a normal programming question nothing of a Apex/Salesforce riddle.

Scenario :我有一个连接对象,有两个父对象。 例如, 假设有 3 个对象, 父、 父、 2 和交叉点。 当只有一个连接对象连接到父、 1 和交叉点时, 我正试图获取父的代号( 这对我来说通过 SOQL 有效 ), 但当此唯一的一个交点对象被删除时; 当有一个交点对象时, 我正试图保存访问父1 的代号 。 注意: 这一切都发生在循环中, 每次您添加或删除连接对象时, 都会在循环中进行重复!

What I have tried: Pseudocode!

Public static String parent1Id;

for (everytime a junction object is added / deleted)
{

    if (listOfJunctionObjects.size() == 1)
    {
        parent1Id = [Do a SOQL to get the Id from the junction object];
    }

    if (listOfJunctionObjects.size() == 0)
    {
        //CANNOT ACCESS THE parent1Id here
        //The if statements get executed at different times everytime
        the for loop runs
    }
}

what I think what I think is right: I think the parent1Id 应该保存在某种常数或某样东西中, 这样每次执行第一个时, 如果对父1Id 的语句相同的话!

求你帮帮我 我真的需要你的帮助

最佳回答

我在父母1号上添加了一个字段, 我储存了父母1号的代号, 然后通过多次迭代访问它。

问题回答

暂无回答




相关问题
passing form variables into a url with php

I have the following form which allows a user to select dates/rooms for a hotel reservation. <form action="booking-form.php" method="post"> <fieldset> <div class="select-date">...

Error: "Cannot modify the return value" c#

I m using auto-implemented properties. I guess the fastest way to fix following is to declare my own backing variable? public Point Origin { get; set; } Origin.X = 10; // fails with CS1612 Error ...

C-style Variable initialization in PHP

Is there such a thing as local, private, static and public variables in PHP? If so, can you give samples of each and how their scope is demonstrated inside and outside the class and inside functions?

C#/.NET app doesn t recognize Environment Var Change (PATH)

In my C# app, I am programmatically installing an Oracle client if one is not present, which requires adding a dir to the PATH system environment variable. This all works fine, but it doesn t take ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

How to dynamically generate variables in Action Script 2.0

I have a for loop in action script which I m trying to use to dynamically create variable. Example for( i = 0 ; i &lt 3 ; i++) { var MyVar+i = i; } after this for loop runs, i would like to ...

热门标签