You need to sign in to do that
Don't have an account?
Will_1
Compile Error on Bind - Newbie
I'm a newbie to Apex (and to Java for that matter).
I've created a custom object, Job, that has a lookup relationship to Opportunity. I'm trying to create a method that will get the account id off of the opportunity (based on the opportunity id stored on job), and then get some default custom fields off of account to populate in the job record. However, I can't even seem to get off of the ground with the method. My idea is that I would call this method from a trigger in Job.
The following code gives me the following compile error:
Save error: Didn't understand relationship 'Job__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. Staffing/src/unpackaged/classes JobCalculations.cls line 17 1210710065570 177
I have changed the reference to Job to be Job__r to no avail, and I have changed the reference to the field to be Job__c.Opportunity__r with no luck either. Does anyone have any advice for a newbie?
Code:
public class JobCalculations { public static void updateTargetMkups(Job__c myjob) { Opportunity o = [ SELECT Id, AccountId FROM Opportunity WHERE Job__c.opportunity__c = : Id]; } }
Now, the next problem for a newbie...
I've created the following Trigger to try to initiate the class and method above:
However, when I try to save this trigger, I receive the following error:
Save error: Method does not exist or incorrect signature: JobCalculations.updateTargetMkups(LIST:SOBJECT:Job__c).
I've tried to insert some type of object in the method call, but I cannot figure out the proper syntax. Any thoughts out there?
Anyone have any additional advice on this problem?
I have looked at this code over and over, and now that I have changed the method to include an array of Job__c, I would think that at least from a method signature perspective, this should work.
I tried something similar to this before to no avail, but I just did the following and I STILL get the same error??!!
Message Edited by TehNrd on 05-15-2008 01:44 PM
I just tried deleting both the class and the trigger. I then recreated the class (with no arguments), and there were no errors. I recreated the trigger definition, and I received no errors either. However, when I actually call the method within the trigger, THEN I receive the error. So, the shell of the trigger below saves with no errors, but when I add the method call in the second version, then I get the exact same error. I have checked for typo's in the method name over and over, but I cannot see any.
Are you using Eclipse? Do you have the latest verstion of Eclipse and the Force.com IDE. Maybe rebuild the projects in Eclipse.
Also try making the saves through the web editor.
Message Edited by TehNrd on 05-16-2008 09:48 AM
I am using Eclipse. I should be using the latest version of everything since I only set this up a little over a week ago. I actually do not know how to make these changes directly in the web version. When I go to these development objects within Salesforce, I do not see an option to edit them directly.
I just deleted my old project, and setup a new one and recreated both the trigger and the class, but I still have the same problem. Since this is the first development I am doing within Salesforce, I think it may be likely that there is some setup component that is not correct (user error, I'm sure). So, here are some random comments that may strike a chord with someone:
- I have setup the Eclipse Force.com project directly to my production environment. Does this matter in creating these objects?
- I can see the definition of my class, and the trigger in the development area of my salesforce.com account. The "body" of these objects never appears online, I only see the definitions.
- All of this code is "unpackaged".
Any thoughts are appreciated. Tehnrd, you have been very helpful. Maybe one of the administrators has an idea. I have to believe other newbies out there have the same challenges.
- I have setup the Eclipse Force.com project directly to my production environment. Does this matter in creating these objects?
Try it in a sandbox or setup a dev account I think your issue will be resolved.
Message Edited by TehNrd on 05-16-2008 10:31 AM
The test coverage is why your changes were not being saved to production.
All code in production must be covered by tests and since your trigger and class weren't, the saves were never committed, and that's why you couldn't see the code when you looked through the UI.
Technically code can be written in production if tests covered all the code. Yet you should never develop in production for a few reasons. You will miss bugs, we all make little mistakes, and you don't want these in production. Another reason is that I believe all test are run with any save, and for us to run all tests it takes about 4.5 minutes, and that just wouldn't be very productive.
Hope that all helps.
-Jason