today I signed in on SF Stackexchange and I'm a newbie on Apex.
1 retry: This is what I have:
trigger ComplaintInitialize on Complaints__c (before insert, before update) { for(Complaints__c Complaint : Trigger.new) {
if(Complaint.RecordType_Name__c == 'ComplaintInitialize')
{
Id recordTypeId = Schema.SObjectType.Complaints__c.getRecordTypeInfosByDeveloperName().get('ComplaintOffice').getRecordTypeId();
If(String.isBlank(Complaint.Case__c) == false)
{
Case C = [Select Id, OwnerId, ContactId, Intermediary__c, Polisnummer_lookup__c, Account.FirstName, Account.LastName,
Contact.First_Name__c, Contact.LastName, Contact.MailingStreet, Contact.MailingPostalCode, Contact.MailingCity,
Contact.Gender__c, Contact.Phone, Contact.Email from Case Where Id =: Complaint.Case__c ];
Complaint.Employee__c = C.OwnerId;
User KB = [select Id from User where LastName = :'ComplaintOffice'];
Complaint.OwnerID = KB.id;
User H = [select Id, Email, Department, Division from User where Id =: C.OwnerId];
User TL = [Select Id from User Where Department =: H.Department AND IsActive =: true AND Function__c =: 'Complaint_Handler' LIMIT 1];
Complaint.Complaint_Handler__c = TL.Id;
so far so good
but her I got stuck: Illegal assignment from List<PeriodOfTime__c> to Complaints__c at line....
Complaints__c DT = [Select Id, Date__c, FirstContactDate__c, FirstContactDateAAV__c from PeriodOfTime__c Where Date__c =: date.today() LIMIT 1];
If(Complaint.Received_by__c == 'Complaint coordinator AAV')
{Complaint.Deadline__c = DT.FirstContactDateAAV__c;}
else
{Complaint.Deadline__c = DT.FirstContactDate__c;}
What am I doing wrong in the last part? (The 'Limit 1' is not nescessery because there is only 1 record in the database with date of today)