You need to sign in to do that
Don't have an account?
CarlSpoon
INVALID_TYPE:sObject
Users in the Standard user profile are getting the following error message when they tried to execute a Java Script that creates a record the custom object – PricingRequest__c.
Faultcode:’sf:INVALID_TYPE,faultstring:INVALID_TYPE:sObject type ‘PricingRequest__c’ is not supported.Here is the code:
//##################################### //Handle the Database interaction for the Pricing Request Object function UpdatePricingRequest(){ //If an existing Pricing Request is being edited, no datanbase updates for the pricing Request Object if( prid != "null") return; // Creating a new Pricing Request, update the database. try { var pr = new sforce.SObject("PricingRequest__c"); //Populate the fields on the Pricing Request Object pr.Opp_Name__c = ['{!opportunity.id}']; pr.Status__c = ['New']; pr.PR_Flag__c = 0; pr.Sales_rep__c = ['{!opportunity.Owner.Name}']; //Save the Pricing Request Object into the database var result = sforce.connection.create([pr]); //Check if a PricingRequest Object was successfully saved in the database if (result[0].getBoolean('success')) { prid = result[0].id; databaseUpdate = ['success']; } else { databaseUpdate = ['failed']; alert("Failed to create Pricing Request: " + result[0]); } } catch(e) { alert("Create Pricing Request ERROR: " + e); databaseUpdate = ['failed']; }}
The Administrator’s profile was able to execute the script without error, but the Standard User profile failed. Do you know why there are getting this error?
Apparently, you have to give access to the new custom objects and VisualForce pages from the user's profile. And you have to check the "Customize Application" checkbox under the same profile.
All Answers
Here is the code:
//#####################################
//Handle the Database interaction for the Pricing Request Object
function UpdatePricingRequest(){
//If an existing Pricing Request is being edited, no datanbase updates for the pricing Request Object
if( prid != "null") return;
// Creating a new Pricing Request, update the database.
try
{
var pr = new sforce.SObject("PricingRequest__c");
//Populate the fields on the Pricing Request Object
pr.Opp_Name__c = ['{!opportunity.id}'];
pr.Status__c = ['New'];
pr.PR_Flag__c = 0;
pr.Sales_rep__c = ['{!opportunity.Owner.Name}'];
//Save the Pricing Request Object into the database
var result = sforce.connection.create([pr]);
//Check if a PricingRequest Object was successfully saved in the database
if (result[0].getBoolean('success')) {
prid = result[0].id;
databaseUpdate = ['success'];
} else {
databaseUpdate = ['failed'];
alert("Failed to create Pricing Request: " + result[0]);
}
} catch(e) {
alert("Create Pricing Request ERROR: " + e);
databaseUpdate = ['failed'];
}
}
Apparently, you have to give access to the new custom objects and VisualForce pages from the user's profile. And you have to check the "Customize Application" checkbox under the same profile.