function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
devendra dhakadevendra dhaka 

Queue creation using apex triggers

I AM USING THIS CODE IN A TRIGGER TO AUTOMATE CREATION OF THE QUEUES .



Group g=new Group(Name='hello', Type='QUEUE');
insert g;


QueuesObject q= new QueuesObject (queueid=g.id, sobjectType='lead');

insert q;    ///   error is represented in this line


I am using this trigger on an object insertion.


If i use the same code in a visualforce page using apex controller, it works....


thanks in advance....

AmitSahuAmitSahu

PLEASE use only one question and do not repeat the question in different treads , which creates confusion.

 

Please let us know the error you are getting.....

devendra dhakadevendra dhaka

Review all error messages below to correct your data.
Apex trigger queueCreator caused an unexpected exception, contact your administrator: queueCreator: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Sobject Type: bad value for restricted picklist field: test__c,Lead: [SobjectType]: Class.QueueCreator.createQueue1: line 25, column 1

 

 

This is the error 'm getting...

 

I have written a trigger to create a queue , by uploading the data into a temp object 'test'

AmitSahuAmitSahu

queuesobject q = new queuesobject (queueid=groupt.id, sobjecttype='test__c;Lead;Case'); 

devendra dhakadevendra dhaka

you entered the wrong answer in this question thread...

 

 

how do i resolve this error ??