2

I am connecting salesforce with salesforce using partner wsdl.I have been able to login to the destination org from the source org and then I am caling custom webservice and passing some parameters to it which will be mapped to the account object in the destination org and then record is inserted and inserted record id is returned as response .

I am running this code anonymously.

My problem is that after making callout ,called web service is returning an Id as reponse successfully .However,When I try to see inserted record in destination org I do not see any record over there.I am not getting any error

Below given code has custom web service.I have taken this webservice exactly as given in the salesforce help.

Can somebody please suggests

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();

String username = 'james@yahoo.com'; String password = 'somepassword';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
soapSforceComSchemasClassAccountpla.Accountplan apx = new soapSforceComSchemasClassAccountpla.Accountplan();
soapSforceComSchemasClassAccountpla.SessionHeader_element SessionHeader = new soapSforceComSchemasClassAccountpla.SessionHeader_element();
sessionHeader.sessionid=loginResult.sessionid; apx.sessionheader=sessionHeader;

soapSforceComSchemasClassAccountpla.plan l = new soapSforceComSchemasClassAccountpla.plan();
l.name='Genius'; l.Plannumber=123456;

try {
    soapSforceComSchemasClassAccountpla.Plan opp=apx.createAccountPlan(l);

    system.debug('The output after value has been returned by us is' + opp);

    system.debug('The value of the vplan id is' + opp.planid);
} catch(Exception e) {
    System.debug('The exception has been raised is'+e);
}

Web Service:

global class AccountPlan {

       webservice String area;
       webservice String region;

       //Define an object in apex that is exposed in apex web service
       global class Plan {
          webservice String name;
          webservice Integer planNumber;
          webservice Date planningPeriod;
          webservice Id planId;
       }

       webservice static Plan createAccountPlan(Plan vPlan) {

           //A plan maps to the Account object in salesforce.com.
           //So need to map the Plan class object to Account standard object
           Account acct = new Account();
           acct.Name = vPlan.name;
           acct.AccountNumber = String.valueOf(vPlan.planNumber);
           insert acct;

           vPlan.planId=acct.Id;
           return vPlan;
  }      
}
  • 2
    You can't see the Account that was created in the web service in the Org that hosts the web service? Have you tried putting the Account Id directly into the URL? E.g. https://*instance*.salesforce.com/001X00000000001 – Daniel Ballinger Jul 8 '13 at 19:56
1

If you received success and Id of created object then it is sure that you have created object successfully. put the id returned by your code into url and check.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.