You need to sign in to do that
Don't have an account?
Joe Xu 7
"sObject type 'sObject' is not supported." error in Onclick JavaScript
Hi, I'm trying to create an Onclick JavaScript custom button (as List Button for multi-record action) and hitting below error:
"sObject type 'sObject' 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."
This button is put on Account object's related list and the target object is filepicker__File__c which is from managed package. When I select filepicker__File__c records from Account's related list view, and click this custom button, it shows above error.
Below is my JavaScript:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.filepicker__File__c)};
var files = [];
if (records.length == 0) {
alert("Please select at least one record to update.");
} else {
for (var a=0; a<records.length; a++) {
var file = new sforce.SObject("filepicker__File__c");
file.filepicker__id = records[a].filepicker__id;
file.filepicker__AU_Access__c = "Yes";
files.push(file);
}
result = sforce.connection.update([files]);
if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
location.reload(true); /* redisplay the detail page */
}
}
Can someone help find out the cause? Thank you!
"sObject type 'sObject' 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."
This button is put on Account object's related list and the target object is filepicker__File__c which is from managed package. When I select filepicker__File__c records from Account's related list view, and click this custom button, it shows above error.
Below is my JavaScript:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.filepicker__File__c)};
var files = [];
if (records.length == 0) {
alert("Please select at least one record to update.");
} else {
for (var a=0; a<records.length; a++) {
var file = new sforce.SObject("filepicker__File__c");
file.filepicker__id = records[a].filepicker__id;
file.filepicker__AU_Access__c = "Yes";
files.push(file);
}
result = sforce.connection.update([files]);
if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
location.reload(true); /* redisplay the detail page */
}
}
Can someone help find out the cause? Thank you!
its support both Custome object and stadard object as well, so kinldy use the object API name properly, find your object API name from setup use that, for its working perfectly for custom and standard object as well.
below is my Object API name: rajam_karthik__Collage__c (see below pic)
Field: ID,name
those these things properly. it will work 100%
Hope this will help you.
Thanks
karthik
All Answers
use this Updated Code.
Hope this will help you,
Mark Best ANSWER if its work for you.
Thanks
karthik
{faultcode:'sf:INVALID_FIELD', faultstring:'INVALID_FIELD:
SELECT filepicker__Id, filepicker__AU_Access__c
^
ERROR at Row:1:Column:8
No such column 'filepicker__Id' on entity 'filepicker__File__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.', detail:{InvalidFieldFault:{exceptionCode:'INVALID_FIELD', exceptionMessage:'
SELECT filepicker__Id, filepicker__AU_Access__c
Check the Query in workbench or developer console.. for below statement,
so that you can use it here
if this filepicker__Id is the custome ID: use like below
"filepicker__Id__c"
var updateRecords = sforce.connection.retrieve("Id, filepicker__id, filepicker__AU_Access__c","filepicker__File__c", records);
filepicker__id filepicker__AU_Access__c these are the field are another custome object
" select id,filepicker__id__c,filepicker__AU_Access__c, from filepicker__File__c " check this query in workbench or developerconsole. or generated Partner WSDL or Enteriprise WSDL to check the fields are there in your Org.
howp this will help you,
Thanks
karthik
its support both Custome object and stadard object as well, so kinldy use the object API name properly, find your object API name from setup use that, for its working perfectly for custom and standard object as well.
below is my Object API name: rajam_karthik__Collage__c (see below pic)
Field: ID,name
those these things properly. it will work 100%
Hope this will help you.
Thanks
karthik
There are two bugs:
1. no need [] within sforce.connection.update()
2. need to use capital I for the field called in "updateRecords[a].Id"
Here is my complete successful code: