function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mh1974mh1974 

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?

Message Edited by mh1974 on 04-28-2009 01:25 AM
Message Edited by mh1974 on 04-28-2009 01:25 AM
Message Edited by mh1974 on 04-28-2009 01:28 AM
Best Answer chosen by Admin (Salesforce Developers) 
mh1974mh1974

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

werewolfwerewolf

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.

mh1974mh1974

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 was selected as the best answer
Mitesh SuraMitesh Sura

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

Nazeer AhamedNazeer Ahamed