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
cjcindccjcindc 

picklist value in Trigger

Hi,

 

I have an inherited trigger in which I want to conditionally set the subject of a new task depending the value of a picklist field.  For some reason the trigger cannot read the picklist value... it's not blank, and never is, it actually has a default value.  Below is the significant snippet of the trigger.  The troublesome picklist field is name Initial_Lead_Type__c.  When I try to set my task subject directly to the picklist value, it ends up blank.  Any ideas?  Thanks in Advance.

 

trigger GuestCard_Sharing on Guest_Card__c (before insert, before update, after insert, after update)
{
if (Trigger.IsAfter)
{
.
.
.
if (Trigger.IsInsert)
{
Id leadrtid = [select id from Recordtype where SObjectType = 'Task' and Name = 'Pilot Lead Process' limit 1].id;
list<Task> newtasks = new list<Task>();
for (Guest_Card__c gc : Trigger.new)
{
//Only create Task for non-Leased GCs owned by real Users
if ((gc.Status__c != 'Leased')
&& (gc.Initial_Lead_Type__c != 'Email')
&& (((String)gc.OwnerId).substring(0,3) == '005'))
{
newtasks.add(new Task(
OwnerId = gc.OwnerId,
RecordtypeId = leadrtid,
AVB_Type__c = 'Lead Pursuit Process',

Subject_Sub_Category__c = gc.Initial_Lead_Type__c,

ActivityDate = system.today(),
AVB_Associate_First_Last_Name__c = gc.AVB_Associate__c,
WhatId = gc.Id
));
}
} //end for gc : trigger.new

if (newtasks.size() > 0)
insert newtasks;
}
.
.
.
}

 

Jeff MayJeff May

I would add some system.debug() statements to the code and check right before the assignment to see what the value is.