You need to sign in to do that
Don't have an account?
INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST when I try to update a record with the good picklist api name value
Hi !
I got this error when I run a custome quick action which called an apex server side controller:
Something went wrong CloneInvitationLead.apxc:50: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: INVITATION_WRONGCONTACT: [OPS_Invitation_reason__c]
It is weird because the API NAME of the picklist OPS_Invitation_reason__c mentionned is the right one...
I then relaxed at the picklist definition level the conditions: "Restrict picklist to the values defined in the value set".
It worked but another weird things is that it did not create a new value in the picklist value set. It means that the value which was stared by the error and seems wrong is finally the right one...
Here is an snippet of my code concerned by this error:
Id cleanId = (Id) oldId;
// Load the old Lead with all fields
String objectName = 'Lead';
String query = 'SELECT';
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
// Grab the fields from the Lead and append them to the queryString one by one.
for(String s : objectFields.keySet()) {
query += ' ' + s + ', ';
}
query = query.subString(0,query.Length()-2);
query += ' FROM ' + objectName;
query += ' WHERE Id = \''+ oldId +'\' LIMIT 1';
// Query the Lead object
Lead ld = database.query(query);
System.debug('Loaded <Lead ' + ld.Id + '>');
// Create the new Lead and clone the previous one
Lead newLd = ld.clone(false, false, false, false);
// Update form fields
newLd.FirstName = firstName;
newLd.LastName = lastName;
newLd.Email = email;
newLd.Phone = phone;
newLd.MobilePhone = mobilePhone;
newLd.Title = title;
// Update control fields
newLd.Status = 'INVITATION_NEW';
newLd.OPS_Primary_Lead__c = false;
newLd.OPS_LeadCloned__c = ld.id;
// Update qualification fields
newLd.OPS_BouncedEmail__c = false;
newLd.OPS_OpenedEmail__c = false;
newLd.OPS_Not_Responding__c = false;
newLd.OPS_SuppressedEmail__c = false;
// Insert new Lead in Production
insert newLd;
Can you help me please?
Try this.
Uncheck the "Restrict picklist " option for the picklist "OPS_Invitation_reason__c".
Thanks..