0

Parent= Case Child = MyCustom__c

I have "New Cust" JS button on MyCustom__c related list - -> Now I go to my "Case" record (in Console) -> Go to related List "MyCustom" -> Click on"New Custom" Button

Throws following Errors

*Insufficient Privileges

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors.

Click here to return to the previous page.

What am I doing wrong here ? Any suggestions -

************ ** "New Custom" JS button code ************

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 
var url = window.location.pathname; 
url = url.substring(1, url.length); 
var result = sforce.connection.query("Select Id, Description, AccountId, Account.Name from Case where id=\'"+url+'\''); 
var Desc = result.getArray("records")[0].Description ; 
var nullbool = (result.getArray("records")[0].AccountId != null ? "true" : "false"); 
if(nullbool == "true") 
{ 
var AccName = result.getArray("records")[0].Account.Name; 
window.location.href='/setup/ui/recordtypeselect.jsp?ent=01I400000006gIa&retURL='+url+'&save_new_url=%2Fa4I%2Fe%3FCF00N40000002qgB2%3D06862219%26CF00N40000002qgB2_lkid%3D'+url+'%26retURL%3D%252'+url+'&00N40000002qgB8='+Desc+'&00Ne000000192L8='+AccName;
} 
else 
{ 
window.location.href='/setup/ui/recordtypeselect.jsp?ent=01I400000006gIa&retURL='+url+'&save_new_url=%2Fa4I%2Fe%3FCF00N40000002qgB2%3D06862219%26CF00N40000002qgB2_lkid%3D'+url+'%26retURL%3D%252'+url+'&00N40000002qgB8='+Desc; 
}

I found one know issue here ---- but didn't understood much from there -

https://success.salesforce.com/issues_view?id=a1p30000000SxweAAC

1

To analyse your issue, I created a button with exact code and it gave me the same insufficient privilege error.

I noticed that you are redirecting the user to create a new Case and URL looks like

https://ap2.salesforce.com/setup/ui/recordtypeselect.jsp?ent=01I400000006gIa&retURL=50028000006DePw&save_new_url=%2Fa4I%2Fe%3FCF00N40000002qgB2%3D06862219%26CF00N40000002qgB2_lkid%3D50028000006DePw%26retURL%3D%25250028000006DePw&00N40000002qgB8=null

But then I compared this URL with standard Case creation page with record type selection, it looks like

https://ap2.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Case&retURL=%2F500%2Fo&save_new_url=%2F500%2Fe%3FretURL%3D%252F500%252Fo

I have highlighted the "ent" parameter in both the URL and when I replaced the same in your code, it worked fine. Update your code to include updated ent parameter.

Update

Just realised, that you probably redirecting the user to create another object. In that scenario, verify that

  1. You have create permissions for that object
  2. You have access to record types for that object.
  • * I am creating child object record for case * Yes I do have permission on Object and access for the record Types too. * Do I need to change "ent= ?????" according to my child object ? – Salesforce Steps Dec 9 '15 at 10:42
  • 1
    Go to your child object tab and create new record. It will ask you to select the record Type. Just copy that ent parameter and replace in your code. – Salesforcesmarty Dec 9 '15 at 11:09
  • ent=01I400000006jOW this is the one ... I tried this by editing existing URL part ent=01I400000006gIa.... still ame error – Salesforce Steps Dec 9 '15 at 11:57
  • Just to confirm, if you set ent as Case, it is working fine for you as well, but not for the custom object, so that we can be sure there is nothing because of the URL? – Salesforcesmarty Dec 9 '15 at 12:12
  • Yes, If I set ent as Case it works , but if I do ent=01l400000006jOw i.e. for the Custom object then it does not work – Salesforce Steps Dec 9 '15 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.