Error
This content is not currently supported on this browser.
+ Start a Discussion
CW83CW83 
I have a javascript button I am trying to create to update a picklist field on a custom object.  Here is the code for the button:

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

var p = new sforce.SObject('Projects__c');
p.id = "{Projects__c.Id}";
p.Status__c = "Closed";
result = sforce.connection.update([p]);
location.reload(true);

The code is not throwing errors on the object it is just not updating the field.  The page is reloading. Anything wrong with the code?

Best Answer chosen by CW83
logontokartiklogontokartik
Looks like you missed "!" in your merge field it must be {!Projects__c.Id}. Also you can alert on result.message if you want to see any errors.
jud008jud008 

According to SOAP API Developer's Guide - Introducing SOAP API: Development Platforms different versions of the WSC tool can be obtained from http://code.google.com/p/sfdc-wsc/ and http://mvnrepository.com/artifact/com.force.api/force-wsc.

 

However, the latest version on the google-code site is wsc-22 whereas the latest on mvnrepository is wsc-26. On the other hand, the link to source code given on mvnrepository (http://github.com/forcedotcom/wsc) seems to be dead.


Which is which and which version should one use?

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

WSC is now available from its new home on Github https://github.com/forcedotcom/wsc

Kevin WrightKevin Wright 

I feel I'm almost there :)

 

The code below connects to the Salesforce server but ultimately fails with a 'no endpoint' exception.

 

I think I'm just not passing on the protocol credentials such as service and url endpoint to the object making the call,  but

I'm only guessing.

 

Also are there any pieces of sample code that make a WebService call from Java as I've not been able to find any?

 

Can anyone help me please?

 

 

 

import com.sforce.soap.schemas._class.MyWebService.*;
import java.net.*;
import com.sforce.soap.enterprise.*;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.ExceptionCode;

 

public class TestCall{

 

 public static void main(String[] args){

                LoginResult loginResult;

  System.out.println("start of program");
  try{

  SoapBindingStub bind=  (SoapBindingStub) new SforceServiceLocator().getSoap();
                System.out.println("after call to getSoap()");
  bind.setTimeout(60000);

   
  loginResult = bind.login("myadminuser", "mypassword");
  System.out.println("straight after login call");
  bind._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());

    com.sforce.soap.enterprise.SessionHeader sh = new com.sforce.soap.enterprise.SessionHeader();
          sh.setSessionId(loginResult.getSessionId());
      
   
         bind.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
                          "SessionHeader", sh);
       
              

   MyWebServiceBindingStub stub = new MyWebServiceBindingStub();

   

   System.out.println("about to make call");
   stub.myMethod();
  }
    catch (LoginFault ex) {
            // The LoginFault derives from AxisFault

            ExceptionCode exCode = ex.getExceptionCode();
            System.out.println("######" + exCode);
            if (exCode == ExceptionCode.FUNCTIONALITY_NOT_ENABLED ||
                exCode == ExceptionCode.INVALID_CLIENT ||
                exCode == ExceptionCode.INVALID_LOGIN ||
                exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_DOMAIN ||
                exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_TIME ||
                exCode == ExceptionCode.ORG_LOCKED ||
                exCode == ExceptionCode.PASSWORD_LOCKOUT ||
                exCode == ExceptionCode.SERVER_UNAVAILABLE ||
                exCode == ExceptionCode.TRIAL_EXPIRED ||
                exCode == ExceptionCode.UNSUPPORTED_CLIENT) {
                System.out.println("Please be sure that you have a valid username " +
                     "and password.");
            } else {
                // Write the fault code to the console

                System.out.println(ex.getExceptionCode());
                // Write the fault message to the console

                System.out.println("An unexpected error has occurred." + ex.getMessage());
            }
  

  }
   catch(Exception e){
   System.out.println("error" + e.getMessage());
  }

 }

 


}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Kevin WrightKevin Wright

Success!! The following code sucessfully calls an Apex Web Service from Java. The System log indicates the call is being

made. I am sure there is a certain amount of duplication of operations in this code and it needs cleaning up. But it does work! :smileyhappy:

 

 

 

 

 

import com.sforce.soap.schemas._class.MyWebService.*;
import java.net.*;
import com.sforce.soap.enterprise.*;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.ExceptionCode;

 

public class TestCall{

 

 public static void main(String[] args){

                LoginResult loginResult;

  System.out.println("start of program");
  try{

  SoapBindingStub bind=  (SoapBindingStub) new SforceServiceLocator().getSoap();
                System.out.println("after call to getSoap()");
  bind.setTimeout(60000);


  loginResult = bind.login("adminusername", "adminpassword");
  System.out.println("straight after login call");
  bind._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());

    com.sforce.soap.enterprise.SessionHeader sh = new com.sforce.soap.enterprise.SessionHeader();
          sh.setSessionId(loginResult.getSessionId());


         bind.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
                          "SessionHeader", sh);

   MyWebServiceServiceLocator locator = new MyWebServiceServiceLocator();

   //************ new stuff here.
      //ApexWebServiceTestService svc = new ApexWebServiceTestServiceLocator();

      java.net.URL url = new java.net.URL(locator.getMyWebServiceAddress());

   MyWebServiceBindingStub stub = new MyWebServiceBindingStub(url, locator);


              //SessionHeader sh = new SessionHeader();
              //sh.setSessionId(sessionId);

          String sforceURI = locator.getMyWebServiceAddress();
              stub.setHeader(sforceURI, "SessionHeader", sh);


   // ***********end of new stuff


   System.out.println("about to make call");
   stub.myMethod();
  }
    catch (LoginFault ex) {
            // The LoginFault derives from AxisFault

            ExceptionCode exCode = ex.getExceptionCode();
            System.out.println("######" + exCode);
            if (exCode == ExceptionCode.FUNCTIONALITY_NOT_ENABLED ||
                exCode == ExceptionCode.INVALID_CLIENT ||
                exCode == ExceptionCode.INVALID_LOGIN ||
                exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_DOMAIN ||
                exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_TIME ||
                exCode == ExceptionCode.ORG_LOCKED ||
                exCode == ExceptionCode.PASSWORD_LOCKOUT ||
                exCode == ExceptionCode.SERVER_UNAVAILABLE ||
                exCode == ExceptionCode.TRIAL_EXPIRED ||
                exCode == ExceptionCode.UNSUPPORTED_CLIENT) {
                System.out.println("Please be sure that you have a valid username " +
                     "and password.");
            } else {
                // Write the fault code to the console

                System.out.println(ex.getExceptionCode());
                // Write the fault message to the console

                System.out.println("An unexpected error has occurred." + ex.getMessage());
            }


  }
   catch(Exception e){
   System.out.println("error" + e.getMessage());
  }

 }


}

Ramon_Dev_BRRamon_Dev_BR 
Hello,

I created a WS service in SF and would like to access it in Java. I used this as a basis discussion here (https://developer.salesforce.com/forums?id=906F00000008qEkIAI), however I can not find some classes that were generated.
Ex: SforceServiceLocator and SoapBindingStub.

Generated the file through Enterprise.jar my enterprise.wsdl. Also I generated my classes through the WSDL service.

Could you help me please.

Thank you;
Best Answer chosen by Ramon_Dev_BR
Ramu_SFDCRamu_SFDC
Please review the blog post at the link below

http://manhntbkit.wordpress.com/2013/09/26/notes-web-services-in-salesforce/
DeLiDeLi 
On a custom object, I have created a simple javascript button which creates tasks on the click.

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

var t = new sforce.SObject("Task");

t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}'; 

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

if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}

I can't figure out how to set the t.What (Related To) field. I get the following error:

{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }

My searches tuned out nothing. :(
Any suggestion would be appreciated.

btw, I don't want to use the URL hack or the URLFOR function.

Thank you
Best Answer chosen by DeLi
phillip.southernphillip.southern
Hi, I think this might be duplicate question from the Answers board?  If so, I actually just answered there.....it should be WhatId as the parameter.
nelrib88nelrib88 
I have a third party cloud app that is already integrated with salesforce and available on appExchange.  I would like to take advantage of canvas to provide a better user experience.  I have gone through and created a new app and i can reach my third party app and login through the canvas previewer. I get to the login page of my app and i can log in but i would like it to be already logged in since users can connect through OAUTH and allow access already in my app.

I noticed that the canvas app would need to be a new salesforce app i can't just add it to my current package, is this right?
How do i automatically login the salesforce user to my app?
I see alot of heruko stuff but i do not use it my app is built using java on glassfish server, is it possible to create a salesforce canvas app with my existing java app?

I just want to be able to provide a dashboard for users in the form of a tab that allows them to use functions from my third party app in salesforce.
Best Answer chosen by nelrib88
Sonam_SFDCSonam_SFDC
Hi,

The third-party app that you have created and want to expose as a canvas app can be written in any language. The only requirement is that the app has a secure URL (HTTPS)
I would suggest you to go through the following guide to understand what you need to do to have your app as a canvas app inside Salesforce:
http://www.salesforce.com/us/developer/docs/platform_connectpre/canvas_framework.pdf

And you can add your canvas app as a component in a package - read more: 
http://www.salesforce.com/us/developer/docs/platform_connect/Content/quick_start_package_canvas_app.htm
firefoxfirefox 

Hi all, I am upgrading existing Axis code to Axis2. It's become even worse since the underlying Object model has also been changed.  

 

 -> Axis:

         - sObject.get_any() returns MessageElement.

-> Axis2:

          - I am facing trouble in finding relevant corresponding one. Is it the following?

             sObject.getExtraElement() ?

 

Let me know if someone has already faced similar problems. Please help.

Best Answer chosen by Admin (Salesforce Developers) 
firefoxfirefox

 

When you use - Axis2, partner.wsdl, here is how one should retrieve values of various fields in a SObject (we do not have Account, Contact, etc objects in partner.wsdl)

 

-- OMElement[] records = queryResponse.getResult().getRecords()[0].getExtraElement();

 

for(OMElement record : record){

String name = record.getLocalName();

String value = record.getText();

}

Sujeet KumarSujeet Kumar 

Hi,

 

I have a web application which is developed in apache tomcat 5.5, java, jsp, servelet.  Now i want to access data from force.com to my application. How I can access data and display into my application.  

 

If any document then please give a link and examples also.

 

Thanks

Sujeet Kumar

Best Answer chosen by Admin (Salesforce Developers) 
Rick.BanisterRick.Banister

Here's another suggestion. If your app requires a lot of calls to Salesforce because there are many objects objects being used, performance can be a limiting factor. Typical response per API call is about half a second. Do the math (multiply the number of objects accessed times half a second), and you may find you're better off with a local replicated database. Relational Junction offers bi-directional real-time replication between Salesforce and a local dataabase, making it a great platform for custom web applications. Using JDBC or Hibernate to access the database is a lot quicker to develop, as well, and you probably already know how to do that.

HammerHeadHammerHead 

 

Is there any way to search within field with data type as Long Text? I have read that it is not possoble through SOQL, but using something else (SOOL??) can we do it?

 

I would like ot fire query similar to this

select xyz__c from pqr__c where xyz__c like 'hammer%'

where  xyz__c is Long Text field

 

If it's not possible, is there any workaround? I really need to search for a string within a big text.

 

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
dkadordkador

No, you'd have to query for all objects and then do your own filtering.

QuartzQuartz 

I have been successfully using Axis to generation java source code from the Salesforce WSDL.  Recently Axis code generation started failing with the following error:

 

WSDLException (at /definitions/porttype): faultCode=INVALID_WSDL: Encountered illegal extension element '{http://schemas.xmlsoap.org/wsdl/}porttype' in the context of a 'javax.wsdl.Definition'. Extension elements must be in a namespace other than WSDL's

 

I discovered that the Salesforce WSDL is currently using all lower case for certain elements instead of the previous camel case.  eg: Using <porttype> instead of <portType> and <complextype> instead of <complexType>.  After changing these elements back to camel case Axis was able to generated the code without errors.

 

Is there a better way to address this problem than searching and replacing element names in the WSDL before code generation?

Best Answer chosen by Admin (Salesforce Developers) 
QuartzQuartz

SimonF was correct.  I used chrome to save the wsdl and set the Save as Type to be "All Files" instead of the default "XML Document" (because I wanted to save it as .wsdl).  In doing so I tripped over a chrome bug described here: http://groups.google.com/a/chromium.org/group/chromium-bugs/browse_thread/thread/6193aef2a96bdeb7?tvc=2

 

The resulting file was an xml document changed in subtle ways.  The comments were removed, the order of parameters of elements were rearranged and the camel case of certain elements was changed to lower case - causing the above error.  To avoid the problem I download the wsdl in chrome and set the Save as Type to be the default "XML Document".