[英]Using SOQL query to look up an item by id
I have a visual force page that needs to return the name of a property location to be loaded into the input field on page load. 我有一个视觉强制页面,需要返回属性位置的名称以在页面加载时加载到输入字段中。 (I click edit and the name is already there when page loads. See screenshot of original before I started making a cusome visual force page).
(我单击“编辑”,并且在页面加载时名称已经存在。在开始制作cusome visual force页面之前,请参见原始屏幕截图)。
So I figured I could use my apex page to do a query and then send over a variable to the visual force page. 因此,我认为可以使用我的顶点页面进行查询,然后将变量发送到视觉力页面。 However when I query the Location it returns me the numerical id not the properties name itself.
但是,当我查询位置时,它会返回数字ID而不是属性名称本身。 The query I am attempting to use is:
我尝试使用的查询是:
for (EventPackageRevenueBreakdown__c ETR : [ SELECT UnitPrice__c, Location__c
From EventPackageRevenueBreakdown__c]){
test = ETR.UnitPrice__c;
prop = ETR.Location__c;
}
I'm not sure how to say look at this property ID and get the name of it and then add it to my visualforce page. 我不确定怎么说该属性ID并获取其名称,然后将其添加到我的visualforce页面。 Sorry I am new at this and it is my second day on the job out of college.
抱歉,这是我的新手,这是我大学毕业后的第二天。
Is it possible for you to add a bit more detail? 您是否可以添加更多细节? Are you aware of the table and/or database structure?
您知道表和/或数据库的结构吗?
Your problem is that, apparently, the [Location__C] column from the [EventPackageRevenueBreakdown__c] table is actually the property ID rather than the property name. 您的问题是,显然,[EventPackageRevenueBreakdown__c]表中的[Location__C]列实际上是属性ID,而不是属性名称。
So... your first task is to figure out the actual table structure. 所以...您的首要任务是弄清楚实际的表结构。 IF there is a property name column in the same table, simply replace the [Location__C] column with whatever the property name column is.
如果在同一表中有一个属性名称列,则只需将[Location__C]列替换为任何属性名称列即可。 Now, IF there is no property name column in the table, you must locate another table where the names are stored, along with the corresponding ID ([Location__C]).
现在,如果表中没有属性名称列,则必须找到另一个存储名称的表以及相应的ID([Location__C])。 Once you do this you can query the property name with a JOIN.
完成此操作后,您可以使用JOIN查询属性名称。
Does this make sense? 这有意义吗? If you are able to provide more detail in your question, you can get a stronger answer.
如果您能够在问题中提供更多详细信息,则可以获得更强大的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.