Error
This content is not currently supported on this browser.
+ Start a Discussion
Sandra OSandra O 
Hello - I am getting a Unekpected Token Illegal for my button to assign ownership to the person that clicks the button.

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

// identify the record 
var c = new sforce.SObject("Checklist__c"); 
c.id = "{!Checklist__c.Id}"; 

// make the field change 
c.Ownerid= {!$User.Id}; 


// save the change 
sforce.connection.update([c]); 

//refresh the page 
window.location.reload();
Best Answer chosen by Sandra O
Sandra OSandra O
Answered my own question...

I needed to change c.Ownerid= {!$User.Id}; to c.OwnerId="{!$User.Id}"
Dhaval PanchalDhaval Panchal 

Hello,

 

I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.

 

Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error

 

Below is the code:

 


    public void deleteCustomField(String fullname) throws Exception
    {
        CustomField customField = new CustomField();
        customField.setFullName(fullname);
        
        UpdateMetadata updateMetadata = new UpdateMetadata();
        updateMetadata.setMetadata(customField);
        updateMetadata.setCurrentName(fullname);
        
        AsyncResult[] asyncResults  = metadataConnection.delete(new Metadata[] {customField});
 
        long waitTimeMilliSecs = ONE_SECOND;
 
        do
        {
            printAsyncResultStatus(asyncResults);
            waitTimeMilliSecs *= 2;
            Thread.sleep(waitTimeMilliSecs);
            asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
        } while (!asyncResults[0].isDone());
 
        printAsyncResultStatus(asyncResults);
    }

 


    private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
        if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
            throw new Exception("The object status cannot be retrieved");
        }

        AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object

        if (asyncResult.getStatusCode() != null) {
            System.out.println("Error status code: " +
                    asyncResult.getStatusCode());
            System.out.println("Error message: " + asyncResult.getMessage());
        }

        System.out.println("Object with id:" + asyncResult.getId() + " is " +
            asyncResult.getState());
    }

 

Is there any other solution (any app) to removing custom fields?

 

Thanks in advance,

 

Dhaval Panchal

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal

Using ANT and SFDC Migration tool I am now able to delete bulk custom fields.

Download Apache Ant using below link:

Extract and copy this folder where you want to keetp (i have copied this folder to "C" drive : C:\apache-ant-1.9.2)
Set path in environment variables for ant.
To set environment variables
-> Right click on My Computer -> Property -> Advance System Setting -> Click on Environment variables button.
-> click on System variables -> Click on New -> Give variable name = ANT_HOME and variable value = [your and path]
see below images.


Now go to your salesforce account
click on
Setup -> Develop -> Tools -> Force.com Migration Tool.
Download "salesforce_ant_28.0" and extract this zip file.
You will file "ant-salesforce.jar" file in extracted folder, copy this
jar file to "C:\apache-ant-1.9.2\lib"

Now go to folder salesforce_ant_28.0 -> sample
open file "build.properties" and provide your username, password and token there.
In sample folder you will find xml file formates using that you can deploy components.

cnewmancnewman 
Hi Everyone,

Is there anyway I can have a confirmation box ask which action, from two options, I want to perform or cancel the operation?

I need a button on the Opportunity, that once pressed asks if you want to postone, close or cancel the action. First two options will change the status accordingly and the last will close the box and action nothing.

I'm familiar with the normal Yes/No confirmation box, not sure if this is possible?

Thanks
Chris
Best Answer chosen by cnewman
srlawr uksrlawr uk
If you check out this accepted answer on StackOverflow you'll see that in order to have a three button javascript alert box, you need to expand outside of native javascript support. JQuery libraries are easy to inlude in visualforce pages, and hopefully with a bit of tweeking the JS block provided in this answer will ive you what you want..

http://stackoverflow.com/questions/9091001/how-to-show-confirmation-alert-with-three-buttons-yes-no-and-cancel-as-it

I imagine (of course!) instead of just popping up an alert as to which button you pressed you are going to shoot off and do some apex remoting to call a controller method?
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());
  }

 }


}

john.cjohn.c 
I just got a new laptop and trying to get Eclipse up and running again.  When I go to create a new project and enter my credentials and click Next, it says fetching and then I get this screen.  Any help would be appreciated.

User-added image
Best Answer chosen by john.c
john.cjohn.c
This has something to do with large fonts and the UI for that dialog not dynamically sizing.

You can do two things (for now):
1) maximize that window
2) reduce your font size
American DataAmerican Data 

Hello,

I'm experiencing some wierd behavior when attempting to obtain a SoapBindingStub.

I attempt to access such an object by performing the following:

try {
   binding = ( SoapBindingStub ) new SforceServiceLocator().getSoap();
   logger.info( "getSFConnection> UserInfo = " + binding.getUserInfo() );
  } catch ( Exception e ) {
   logger.error( "getSFConnection> Could not get a SoapBindingStub", e );
  }

When I run this code segment, the attempt to get the binding throws an Exception.  My stack trace looks as follows:

2005-08-12 10:16:43,433 [ERROR] com.americandatacorp.salesforce.SFBinding - getSFConnection> Could not get a SoapBindingStub

AxisFault

faultCode: {urn:fault.enterprise.soap.sforce.com}UNKNOWN_EXCEPTION

faultSubcode:

faultString: UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

faultActor:

faultNode:

faultDetail:

{urn:fault.enterprise.soap.sforce.com}fault:

UNKNOWN_EXCEPTION

Destination URL not reset. The URL returned from login must be set in the SforceService

UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:44)

at java.lang.reflect.Constructor.newInstance(Constructor.java:315)

at java.lang.Class.newInstance3(Class.java:367)

at java.lang.Class.newInstance(Class.java:305)

at org.apache.axis.encoding.ser.BeanDeserializer.(BeanDeserializer.java:125)

at org.apache.axis.encoding.ser.BeanDeserializer.(BeanDeserializer.java:111)

at com.sforce.soap.enterprise.fault.UnexpectedErrorFault.getDeserializer(UnexpectedErrorFault.java:85)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)

at java.lang.reflect.Method.invoke(Method.java:391)

at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:176)

at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:117)

at org.apache.axis.encoding.DeserializationContextImpl.getDeserializer(DeserializationContextImpl.java:466)

at org.apache.axis.encoding.DeserializationContextImpl.getDeserializerForType(DeserializationContextImpl.java:481)

at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:172)

at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)

at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

at javax.xml.parsers.SAXParser.parse(Unknown Source)

at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)

at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)

at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)

at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:826)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:142)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)

at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)

at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)

at org.apache.axis.client.Call.invokeEngine(Call.java:2610)

at org.apache.axis.client.Call.invoke(Call.java:2599)

at org.apache.axis.client.Call.invoke(Call.java:2279)

at org.apache.axis.client.Call.invoke(Call.java:2200)

at org.apache.axis.client.Call.invoke(Call.java:1714)

at com.sforce.soap.enterprise.SoapBindingStub.getUserInfo(SoapBindingStub.java:1903)

at com.americandatacorp.salesforce.SFBinding.getSFConnection(SFBinding.java:80)

at com.americandatacorp.salesforce.SFBinding.(SFBinding.java:53)

at com.americandatacorp.salesforce.SFBinding.getInstance(SFBinding.java:64)

at com.lactagen.automatedmailing.configuration.ConfigurationFileReader.readFile(ConfigurationFileReader.java:69)

at com.lactagen.automatedmailing.configuration.ConfigurationFactory.configure(ConfigurationFactory.java:120)

at Test.main(Test.java:57)

I believe I'm following the use of the API correctly to obtain such a binding object.  Could anyone provide me with some direction on what might be going wrong?

For the record, I'm using java version 1.4.2, and have several other java libraries in my classpath that are required for this integration (J2EE, JDOM, Log4j, Commons-net, + the ones required for Sforce).

Thanks for any assistance in advance.

 

Best Answer chosen by Admin (Salesforce Developers) 
DevAngelDevAngel

Hi American Data,

The problem is that you are asking the binding to do a getUserInfo call in your log statement prior to your login call.

Check the line directly following bingin = (SoapBindingStub) new SforceServiceLocator().getSoap();

Cheers

MilanMilan 
Hello Friends,
 
I tried seeing many posts on INVALID_TYPE: Must send a concrete entity type but I am still confused and still havent been able to rectify my code. So I am posting my issue here.
 
I am trying to CREATE a Lead using PARTNER API. The steps followed are as follows:
  1. Login and retrieve the Server URL and Session ID. (This works)
  2. Set the new Session ID and use the retrieveed Server URL from step 1 above to make subsequent call for getUserInfo( ) . (This one works too, which means I am pointing to the right URL and have the session ID set correctly in the header)
  3. Try to create a Lead with the code snippet as follows:

Code:

              SObject[] sObject = new SObject[1];
  MessageElement[] lead = new MessageElement[5];
  lead[0] = new MessageElement(new QName("FirstName"),"Joe");
  lead[1] = new MessageElement(new QName("LastName"),"Doe");
  lead[2] = new MessageElement(new QName("Company"),"John Doe Inc");
  lead[3] = new MessageElement(new QName("Email"),"johndoe@jdoe.com");
  lead[4] = new MessageElement(new QName("Phone"),"4156832669");
  sObject[0] = new SObject();
  sObject[0].setType("Lead");
  sObject[0].set_any(lead);
         SaveResult[] sr = null;
         try {
            sr = stub.create(sObject);
         } catch (Exception ex) {
            System.out.println("An unexpected error has occurred." + ex.getMessage());
           return;
         }


 
I get the following error :

An unexpected error has occurred.INVALID_TYPE: Must send a concrete entity type.

I am using PARTNER API. Any clue what should I do ?Thanks for any insight.

Regards,

Milan

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
You're sending it to the wrong endpoint, your request is going to .../c/ which the enterprise API, it should be ../u/ see the endpoint URL in the partner WSDL.
tbessietbessie 
Hello all...

So, in the Apex documentation, all of the examples have:

soapBindingStub.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), ...);

... whereas in the example sent by Salesforce for setting the CallOptions for using Salesforce Professional, it has:

soapBindingStub.setHeader("SforceService", "CallOptions", callOptions);

I'm a little confused -- if every example in the docs uses the namespaceURI as the namespace, why have we been told to use "SforceService", which is the partName from the QName returned by the SforceServiceLocator, this time around?

- Tim

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
The apex docs are correct, it should be the namespaceURI.