You need to sign in to do that
Don't have an account?
SObject JS Remoting Error - Please provide an 'id' or 'sobjectType' value.
The salesforce.com docs states remoting methods can take the following values as arugments, "primitives, collections, typed and generic sObjects, and user-defined Apex classes...". There appears to be an issue with generic sObject. Take a look at the following Visualforce page and the related remoting method.
<apex:page showHeader="true" sidebar="true" controller="RemotingSObject"> <input value="Click Me" onclick="doRemote();" type="button"/> <script type="text/javascript"> function doRemote(){ var obj = { sobjectType: 'Account', Name: 'My new account' }; //You can see there is a value of sbojectType set console.log(obj); Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemotingSObject.receiveSObject}', obj, function(result, event){ console.log(event); console.log(result); }); } </script> </apex:page>
The Class:
public with sharing class RemotingSObject { @RemoteAction public static void receiveSObject(SObject obj) { system.debug(obj); } }
If you look in the browsers JavaScript console you will see this error message:
Visualforce Remoting Exception: Unable to determine SObject type: SObject. Please provide an 'id' or 'sobjectType' value.
Makes no sense as an sobjectType value is being supplied. Oddly enough if you provide an id value it works...but if you are trying to insert a new sObject you do not yet have an id value to use.
Any ideas on how to make this work? Bug?
Thanks,
Jason
Roger that. We will fix in the next patch. Stay tuned.
All Answers
Roger that. We will fix in the next patch. Stay tuned.
Cool, thanks.
Case # for this was 08708634 if you want to sync up internally.
Alternative solution thats working fine for me :
Here am passing String as parametes in Remote Action Call & using Json deserialize method to get Account object.
This also works for List<SObject>.
Unfortunately this isn't really a solution as it requires you to hard code the cast of the string to an Account object type, (Account).
Hardcoding object types defeats the purpose of working with sObjects.
Yes, we have to hard code the type.
But if you have to perform the DML statement then we can hardcode List<SObject> And can perform DML statement.
Am also work on an app http://screencast.com/t/m8zHrXNnH which also have the same requirement.
@cwall_sfdc, can you please confirm whether it was resolved and patched?