In salesforce we have two objects. The first is a Component pricing object (Comp_Pricing__c). This has records with component part numbers and pricing in their respective fields, Part_Number & Pkg_Price__c. We also have an object in which we put together proposals with quotes. In this object we use an apex class and trigger to run our calculations to determine quantities of parts needed. We would like to have the apex class, based on a variable (apPart), search through the records, find the corresponding part number and then pull back the price for use in further apex calculations. I believe I will need to run a query on the records but have no idea how to do this. Can I get some help?
0
votes
What is the particular problem? You don't know how to write a SOQL query? Here is a good guide - salesforce.com/us/developer/docs/officetoolkit/Content/…
– Andrii Muzychuk
@Chiz Yes and No. I believe the query should be as follows; SELECT Component_Pricing_r.Pkg_Price__c FROM Component_Pricing__r WHERE PRT_Pr_Ft = Component_Pricing_r.Name The Pkg_price__c needs to be then written to the variable Pr_Ft
– Jordan Klepper
My issue is two fold now. One, the query doesnt work and two, I am not sure how to get the query to pull the Pkg_Price__c from the queried record and assign it to the variable Pr_Ft
– Jordan Klepper
Table name should be Component_Pricing__c instead of Component_Pricing__r and instead of Component_Pricing_r.Pkg_Price__c just Pkg_Price__c. In WHERE clause the same - PRT_Pr_Ft = :Name You put our results into a List of Component_Pricing__c (List<Component_Pricing__r> cpList). Then: String Pr_Ft = cpList[0].Pkg_Price__c. Please, look at examples first.
– Andrii Muzychuk
@Chiz. I appreciate the further explanation of how to setup the query. I have the query and assignment working fine. My issue now is the query will only allow me to setup the WHERE clause as follows; WHERE Name = 'PRT_Pr_Ft'; If I just write the variable without quotes i get the following error (unexpected token; 'PRT_Pr_Ft'). PRT_Pr_Ft is declared as a string to begin with and Name is also a string. How do I get the WHERE clause to accept the PRT_Pr_Ft variable rather than quoted text?
– Jordan Klepper