• KosB
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I need the ability to pass a generic SObject to a SOAP web service.  When I specify the SObject type (ie. Account) it works fine.

 

The following works:

	webService static String testUpsert(Account o) {

		try {
			upsert o;
			return o.Id;
		} catch (Exception e) {
			return e.getMessage();	
		}
	}

 

When I change it to an SObject it fails.  In fact, it acts like the method doesn't exist (nothing gets returned).

 

The following does not work:

	webService static String testUpsert(SObject o) {

		try {
			upsert o;
			return o.Id;
		} catch (Exception e) {
			return e.getMessage();	
		}
	}

 

Here is the JavaScript code I'm using to execute the SOAP methods.

function doTest() {
	sforce.connection.init("{!$API.Session_ID}");
	var acc = new sforce.SObject("Account");
	acc.Name = "a - JS Test Account 1";
	var result = sforce.apex.execute("ws_Test", "testUpsert", {o:acc});
	alert('result - ' + result);
}

 

Any help is appreciated.