+ Start a Discussion
md1md1 

Bad value for restricted picklist field: Read/Write INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST

Apex Gurus,

 

I'm trying to create Account Team members and setting the Account Share as 'Read/Write' for all objects but am getting the error  INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST. Here's the code:

 

Database.SaveResult[] saveResults = Database.insert(members,false);

AccountShare[] newShare = new AccountShare[]{}; //list of new shares to add

integer newcnt1=0;

for(Database.SaveResult sr : saveResults){

if(!sr.isSuccess()){

Database.Error emsg = sr.getErrors()[0];

system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);

}else{

newShare.add(new AccountShare(UserOrGroupId = members[newcnt1].UserId, AccountId=members[newcnt1].Accountid, AccountAccessLevel='Read/Write', OpportunityAccessLevel='Read/Write', CaseAccessLevel='Read/Write', ContactAccessLevel='Read/Write'));

}

newcnt1++;

}

if(newShare.size()>0){

System.debug('No. of shares to be created: '+newShare.size());

Database.SaveResult[] lsr0 =Database.insert(newShare,false); //insert the new shares

Integer newcnt0=0;

for(Database.SaveResult sr0:lsr0){

if(!sr0.isSuccess()){

Database.Error emsg0=sr0.getErrors()[0];

system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0);

}

newcnt0++;

}

System.debug('No. of shares created: '+newcnt0);

}


 

I get an error each line of team share that i'm trying to insert:

 

Bad value for restricted picklist field: Read/Write;getStatusCode=System.StatusCode.INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST 

Been stuck at it for 2 days now so appreciate any help possible to eradicate the above!

 

Thanks in advance,

-Manu 

Message Edited by md1 on 15-12-2009 02:55 PM
Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

check this doc

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_understanding.htm

 

i think you want 'Edit'

 

you are passing the label, not the api name

All Answers

Ron HessRon Hess

check this doc

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_understanding.htm

 

i think you want 'Edit'

 

you are passing the label, not the api name

This was selected as the best answer
md1md1

Thanks, Ron! That was just it! :)

 

Cheers,

-Manu