• chidev
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies

I'm trying to query something in a custom button JavaScript.  The query uses a reference field on the custom object record.  However the {!} returns with referenced object's name instead of id, so I can't use it in a SOQL statement.  For instance,with SFDC_Projects__c defined as a lookup/reference on SFL5_Time__c object,

soql=soql + "'{!SFL5_Time__c.SFDC_Projects__c}'";

gets 'steves project" instead of the id for the project.  Since I'm trying to find out another object that's related to the same project, I really need the id instead of the name.

 

The same way works just fine in APEX trigger.  What did I miss in the JavaScript/AJAX Toolkit environment?

  • August 02, 2010
  • Like
  • 0

I'm trying to query something in a custom button JavaScript.  The query uses a reference field on the custom object record.  However the {!} returns with referenced object's name instead of id, so I can't use it in a SOQL statement.  For instance,with SFDC_Projects__c defined as a lookup/reference on SFL5_Time__c object,

soql=soql + "'{!SFL5_Time__c.SFDC_Projects__c}'";

gets 'steves project" instead of the id for the project.  Since I'm trying to find out another object that's related to the same project, I really need the id instead of the name.

 

The same way works just fine in APEX trigger.  What did I miss in the JavaScript/AJAX Toolkit environment?

  • August 02, 2010
  • Like
  • 0

Hi,

 

  I have a basic new sobject as an example called essay__c with one field called name__c.

 

I'd like to have a custom button on the accounts tab that when pressed creates a new essay record. I'm trying thew following code in the button but it doesn't work:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var t1= new sforce.SObject("essay__c "); t1.name__c = "jim";

var result = sforce.connection.create([t1]);

 

It's probably something really stupid. Does anyone know why please?

 

Thanks,

James.

Hello.. I've run into a problem I have not seen before with Eclipse. I have a test case for a simple custom Controller. When I add this code to my test Apex class I get the following error.

Severity and Description Path Resource Location Creation Time Id Save error: Unable to perform save on all files: An unexpected error has occurred. Please try again, or check the log file for details. SFDC-Production/src/classes Tester.cls line 1 1258989848164 3832

 Checking the Eclipse log I see this:

!ENTRY com.salesforce.ide.core 2 0 2009-11-23 07:24:08.117 !MESSAGE WARN [2009-11-23 07:24:08,101] (ProjectService.java:handleDeployResult:1892) - Save failed! !ENTRY com.salesforce.ide.core 2 0 2009-11-23 07:24:08.132 !MESSAGE WARN [2009-11-23 07:24:08,132] (ProjectService.java:handleRetrieveResult:2037) - Nothing to save to project - retrieve result is empty !ENTRY com.salesforce.ide.core 4 0 2009-11-23 07:24:08.148 !MESSAGE ERROR [2009-11-23 07:24:08,148] (BuilderController.java:handleException:134) - Unable to perform save on all files. !STACK 0 java.lang.NullPointerException at com.salesforce.ide.core.services.ProjectService.setRunTestFailureMarker(ProjectService.java:2303) at com.salesforce.ide.core.services.ProjectService.handleRunTestMessages(ProjectService.java:2278) at com.salesforce.ide.core.services.ProjectService.handleRunTestResult(ProjectService.java:2198) at com.salesforce.ide.core.services.ProjectService.handleDeployResult(ProjectService.java:1904) at com.salesforce.ide.core.project.BuilderController.handleSaves(BuilderController.java:118) at com.salesforce.ide.core.project.BuilderController.build(BuilderController.java:95) at com.salesforce.ide.core.project.BuilderController.build(BuilderController.java:75) at com.salesforce.ide.core.project.OnlineBuilder.incrementalBuild(OnlineBuilder.java:79) at com.salesforce.ide.core.project.OnlineBuilder.build(OnlineBuilder.java:49) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:624) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:166) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:197) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:246) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:249) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:302) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:334) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:137) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

 This Test apex class looks like this:

 

static testMethod void testCPcontrollerApex() { Contact con = [select Id, Name from Contact where Id = '0035000000VnUZk']; User u = [select Id, ContactId from User where ContactId = :con.Id]; u = [SELECT id, UserName, CompanyName, Email FROM User WHERE Id=:u.id]; System.assertEquals('Tom.Sample@company.com',u.UserName);// Test to make sure the case was inserted. System.assertEquals('Tom.Sample@company.com',u.Email); PageReference pageRef = Page.CP_Welcome_Message2; // Get the VF Page that uses this controller. ApexPages.currentPage().getParameters().put('Id', u.id); //Do this first so controller has a user Id to work with. CPcontroller controller = new CPcontroller(); controller = new CPcontroller(); // Instantiate the new controller.. controller.getUser(); controller.getContact(); }

 This same test class works fine in my sandbox environment.  I can save other apex class changes fine, only this piece of code fails to save. Any ideas what the problem is?

 

Regards,