+ Start a Discussion
Sushma PriyaSushma Priya 

Hi,

 

As part of a Project, we are in the process of identifying the

1. Number of ways to connect to an External System from Salesforce(As we need to connect to the external system, get required data from the external system and use that data in the Salesforce application) and

2. Finalizing the feasible/suitable approach of the above.

 

Can anyone please provide the different approaches of connecting Salesforce to External Systems and their feasibility in usage.

If you can give me a sample code for each of the approaches that would be of really great help for me.

 

Thanks in advance,

Sush.

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

To build this yourself, you would need to develop all the following features:

  • A transport mechanism to replicate the data to and from Salesforce.com using the AppForce API. There is no access to a physical database at Salesforce.com, and all data must be accessed using an API that delivers packets of 200 records at a time through their SOAP interface.
  • A data transformation mechanism (ETL) to map and modify raw data into a format recognized by the target system (such as changing yes-no to Boolean true-false for checkboxes)
  • A method of describing metadata to the gateway that is flexible and doesn’t break when the Salesforce.com schema is modified
  • A scheduling mechanism to tell the transport layer when to run and what timeframes to query records
  • A recovery mechanism to handle all possible network and system failures at Salesforce.com, which are a very frequent occurrence. There are days when the API interface is down for hours, which would cripple anything that requires direct API access. Relational Junction has built-in functionality to properly handle all outages, and to retry connections for up to 20 minutes at a time.
  • A restart mechanism to retry failed loads without missing records and without creating duplicate records
  • A technique to handle millions of Salesforce records without timing out. Relational Junction has a patented process to do just that which no other vendor has even attempted.
  • A method of determining which side wins when there are multiple updaters of the same record. Relational Junction can handle record ownership issues down to individual fields.
  • A logging mechanism to track job history and run statistics
  • A failure logging mechanism to trap record level exceptions with all data exposed for debugging purposes
  • A notification mechanism that will inform staff of problems without overwhelming them with information
  • A complete retesting of all functionality for every new release of Salesforce.com. There are generally four major releases each year, each of which requires code modification, often times without documentation until after the release is production.

Relational Junction was built by our company to solve all these problems. The products have been in hundreds of production customer sites since 2005, and have saved many projects from failure. The data recovery features have also saved careers, as Relational Junction is the only solution that not only backs up all data, archives deleted records,  can keep all versions of all records, and can recover the entire Account structure with all dependents intact and related to their parent records.

 

First, you cannot build a solution like ours in less than a year, even with totally committed and skilled resources. That is the typical time it takes a vendor with dedicated resources to develop a product in our space that has even the most rudimentary feature sets, has been tested as thoroughly as Relational Junction, and has been implemented successfully in hundreds of customer sites over many years. If time to market and reliability is at all important, you’ll leverage a package solution instead of building the infrastructure yourself.

 

Secondly, you cannot build nor maintain a solution as inexpensively as ours. The reason we have a product is because the effort involved is so significant that companies are not able to do this for themselves. Our annual pricing for all of this functionality translates into about $10 per hour in labor rates for the full suite, plus a year or more of development time. Given that even mature systems require ongoing maintenance, you will never be able to beat this price unless you can hire Java or C++ programmers for minimum wage. Salesforce API programming is a very specialized skill that is not readily available. I would venture from experience that development costs would far exceed $200,000 for a basic system that met the technical requirements outlined above. So, we have a 10-to-1 cost improvement over the home-grown approach. This is a conservative number because our solution is predictable and home-grown projects can fail or take longer than expected.

 

Thirdly, our database-centric solution makes it far easier to do integrations. Using Salesforce.com as a direct end-point complicates development and testing, since the data cannot be validated by conventional means short of visual inspection. It is also much harder to re-run tests, since you can only delete records one at a time from the user interface. Our approach lets your team using existing skill sets and tools, and leverages the power of a database. Not coincidentally, you then have a complete data warehouse on which you can run reports that cannot be done in Salesforce, such as anything with more than 2 levels, or “without” reports (“Opportunities without Tasks” is my favorite). Gartner has lately discovered and extolled the virtues of a hub-and-spoke integration approach instead of fragile point-to-point integration.

 

We are prepared to do the following to enable you to experience why our technology and methodology is far superior and much more economical than developing your own, and to ELIMINATE YOUR RISK. We will provide a 15 day Proof of Concept period at no cost. We will install the product, train your staff, walk them through the first integration, and provide any technical support through this POC period. There is no obligation involved, other than your time. All this could be done with a standard desktop or 1-proc rack-mounted computer. We do this with confidence that you will appreciate and buy our product because nearly every POC we’ve offered has resulted in a satisfied and intensely loyal customer.

 

Visit our listing on the AppExchange and see for yourself.

 

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.
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?
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());
  }

 }


}

louisa barrett 7louisa barrett 7 
Hi,

I want to put a 'Resend email' button on an Opportunity. The original email gets sent via a trigger when the Opp is closed/won but I want them to have the ability to resend it without having to choose the template or populate any other criteria.

The code below isn't working, I get various error messages, but mainly they centre around the TargetObjectID.
This is the first time I've used AJAX so I'm not sure the syntax is correct.
I've sent a single email with static subject and body text,  but I'm now trying to send an email template to a static contact which needs an OpportunityID so the merge fields within the email can be completed correctly.
I'm not entirely sure how to dynamically get the Opportunity ID from the page that is currently loaded, but I thought I'd just try hard coding it for now to see if it works.
The contact can be hardcoded as it will always be the same as will the Template ID.

The following code is on a custom button on the Opportunity page.
Thanks for any help,

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
// single mail request 
(function() { 
sforce.connection.sessionId = "{!$Api.Session_ID}"; 
var mail = new sforce.SingleEmailMessage(); 
var templatedId = "00X8E000000FKR0"; 
var contactId = "0038E00000PdJoI"; 
var opportunityId = "0068E0000077qF4"; 
mail.replyTo = "jsmith@acme.com"; 
mail.targetobjectid = (contactId); 
mail.WhatID = (opportunityId); 
mail.subject = "Test subject"; 
mail.plainTextBody = "Test body"; 
mail.templateId = (templateId); 
var result = sforce.connection.sendEmail([mail]); 
if(result[0].success == 'true') { 
alert("Finally it worked!."); 
} else { 
alert("I had a booboo."); 

alert(result); 
}());

Many thanks for any help.
Best Answer chosen by louisa barrett 7
Thermo DynamicsThermo Dynamics
Hi,

try this code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
// single mail request 
(function() { 
sforce.connection.sessionId = "{!$Api.Session_ID}"; 
var mail = new sforce.SingleEmailMessage(); 
var templatedId = "00X8E000000FKR0"; 
var contactId = "0038E00000PdJoI"; 
//var opp = new sforce.SObject(“Opportunity”); 
//opp.Id ='{!Opportunity.Id}'; 
var opportunityId = "{!Opportunity.Id}"; 
mail.replyTo = "jsmith@acme.com"; 
mail.targetObjectId= (contactId); 
//mail.whatId= (opp.Id); 
mail.whatId= (opportunityId); 
mail.templateId = (templatedId); 
var result = sforce.connection.sendEmail([mail]); 
if(result[0].success == 'true') { 
alert("Finally it worked!."); 
} else { 
alert("I had a booboo."); 
} 
alert(result); 
}());

If it helps make it as best answer.

Thanks,
Dilip.
nani edimudinani edimudi 

haii all ...i would like to know the code for seat allotment like red bus .........availability seats one color and booked seats one color ...help me with this
Best Answer chosen by nani edimudi
Carlos Campillo GallegoCarlos Campillo Gallego
Hi Nani,

It sounds like you're looking for someone to write the code for this project. These forums are not meant for that; you'll want to post over on the AppExchange site where you can match up with a developer looking to work on your project. 

https://appexchange.salesforce.com/developers

Regards
rramaiahrramaiah 

Any idea why I get a "field integrity exception" error when I try to update SOME PricebookEntry objects?  It doesn't happen for all Pricebooks/PricebookEntry objects, just some, but I can't figure out whether there's a pattern.  I'm definitely using a valid PricebookEntryId.  Any ideas are appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
rramaiahrramaiah
I figured out the problem.  In the web interface, the "Use Standard Price" checkbox was checked, making the value unalterable through the SForce API.