4

Looked to do something smart and immediately ran into problems. I thought I will trim the page layouts by using record types. For that I need to run a batch (or data loader), but problem I get an error mentioned in title.

Now I am not exactly sure how Execute Anonymous works but the name implies that it indeed could be related to permissions. Although I found there was a bug previously, but it is now marked as fixed.

Here's my code:

list <Line_del__c> linesToUpdate = [select id from Line_del__c where Team_s_Dept_s_del__r.name='BOPS'];
RecordType rtype = [Select id From RecordType Where SobjectType = 'Line_del__c' and name='office' limit 1]; 

for (Line_del__c lines: linesToUpdate){
    lines.recordtypeid=rtype.id;

}
try{
update linesToUpdate;
} catch (DmlException ex){
            system.debug(ex);
        } 

As a side note - can I disable record types? Users now cannot edit their items from a list view. If I would update the record types I could enter them as a criteria into list view filter.

Thanks

1
  • 1
    Execute Anonymous doesn't run code 'anonymously', it runs as the currently connected user, which is you, with all of your Profile & Permission Set granted privileges.
    – Mark Pond
    Commented May 15, 2014 at 17:12

2 Answers 2

13

1) Check if the recordtype is active

2) See if the profile of the user editing the record has access to the recordtype

Go to Setup --> Administration Setup --> Profiles ( Search for the users profile ) and search for Custom Record Type Settings on the page and check if the "Office" record type is available for the users profile

1
  • Yes, the record type wasn't set active for the profiles. Couldn't figure it out until started some URL hacking. Created a second record type. Thanks.
    – dzh
    Commented May 15, 2014 at 17:19
1

Is it possible that you have an inactive record type named "office"?

The bug you listed was related to person accounts which does not apply to your issue given the object type.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .