You need to sign in to do that
Don't have an account?

Custom button to create custom object
I'm developing a custom button / link for Cases. The button searches for a custom child object, which I'll call Bob (refered to in code as Bob__c) for now. Bob__c holds the value of the Case to which it belongs, so, I can search for any Bob__c that holds the current Case.Id. If it finds the object it gets displayed, if it does not find the object one gets created and then displayed.
It all works except that when I create the Bob__c obect using this code:
var objNewBob = new sforce.SObject("Bob__c");
objNewBob.CaseNumber__c = {!Case.Id}; //Store the Case number so it can be referenced later
var result = sforce.connection.create([objNewBob]); //Create fails
I see the following message:
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'sf:INVALID_TYPE', faultstring:'INVALID_TYPE: sObject type 'Bob__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', detail:{InvalidSObjectFault:{exceptionCode:'INVALID_TYPE', exceptionMessage:'sObject type 'Bob__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', row:'-1', column:'-1', }, }, }
I can't see what I'm doing wrong! Anyone got any answers please?
Create failed because the object being created was not called Bob__c, but, something else! Read the error,
INVALID_TYPE: sObject type 'Bob__c' is not supported
I found out what the object was really called by looking at my WSDL, but, could just as easily have looked at the object under the Create menu in Setup.
All Answers
1. Try using single quotes instead of double quotes.
2. This
objNewBob.CaseNumber__c = {!Case.Id};
Should read:
objNewBob.CaseNumber__c = '{!Case.Id}';
3. If 1 and 2 fail, check your profile perms to make sure you actually have permissions to see the Bob__c object.
Create failed because the object being created was not called Bob__c, but, something else! Read the error,
INVALID_TYPE: sObject type 'Bob__c' is not supported
I found out what the object was really called by looking at my WSDL, but, could just as easily have looked at the object under the Create menu in Setup.
This is old thered, but there could be one more reason as to why this may be happeneing. Make sure the sObject is "Deployed" and not "In Development" mode, other wise users not having "Customize Application" rights will see that error as well.
regards
SF Partner