• Alex Ezhilarasan
  • NEWBIE
  • 245 Points
  • Member since 2016

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 34
    Replies
Hi,

I'm passing accountid as id and contactid in the url.

When the users click save, I need to update a datefield__c to today(without time) on contact object.

Here is my vf page - 
<apex:page controller="myAudit">
    <apex:form >
        <apex:pageblock >
          <apex:pageblockSection columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
              <apex:commandButton action="{!save}" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

My apex class:
public class myAudit {

   public myAudit() {
    account =  [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
   }

    public String account { get; set; }

    public String txtSurvey { get; set; }

    public PageReference save() {
         Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
            aq.Name = txtSurvey;
            aq.account__c = apexpages.currentpage().getparameters().get('id');
            insert aq;
            return null;
        }
}
 
  • April 17, 2017
  • Like
  • 0
Hi Guys, I have a quick question on custom field limitation. We are using Enterprise edition, will managed package fields count towards the 500 Custom Field limit/Object?

Hello to everyone, today I create Schedulable Apex class to send emails after 1 minute if trigger fire, i programmed callout as:
 

ScheduleCasePostWithFile scheduleMail = new ScheduleCasePostWithFile(C[0], F,'temp' + string.valueOf(DateTime.now()));
String CRON_EXP = string.valueOf(DateTime.now().addMinutes(2).format('s m h d M ? y'));
System.schedule('temp' + string.valueOf(DateTime.now()), CRON_EXP , scheduleMail);

But I am dealing with the problem "execution of AfterInsert caused by: System.AsyncException: Based on configured schedule, the given trigger will never fire. ()", if I change CRON_EXP to hardcoded nearest minute, all OK, so did anyone get this problem before and know how to deal with this?

Thanks.

Currently Logic is If a Account Contains two Opportunity if 1.Opportunity Stage is "Closed Won" and If I am Updating 2 Opportunity Stage = "Closed Lost" then it will Update Account Status = Customer. 

I want add One more Logic Like If Opportunity Stage = Closed Lost then Account Status should Be Lost. In the below Code. How to I Implement 

public static void AfterListUpdateHandler(List<Opportunity> newOpps){
        Set<Id> accIds = new Set<Id>();
        Set<Account> acclists = new Set<Account>();
            for(Opportunity opp : newOpps){
                if(opp.StageName == STAGE_CLOSED_LOST){
                    accIds.add(opp.AccountId);
                }             
            }
        System.debug('OppListStage1 ::>'+accIds);
        Opportunity [] OppListStage  = [SELECT Id,StageName,AccountId FROM Opportunity WHERE AccountId IN: accIds AND StageName =: STAGE_CLOSED_WON];
        System.debug('OppListStage2 ::>'+OppListStage);
        
            if(OppListStage.size()>0){
                for(Opportunity op : OppListStage){
                    Account acc = new Account();
                    acc.Id = op.AccountId;
                    acc.Account_Status__c = STATUS_CHURNED_CUST;
                    acclists.add(acc);              
                }
                if(checkRecursive.runOnce()){
                    update new List<Account>(acclists);
                    System.debug('opp1 ::>acclists'+acclists);
                }
                 
            }    
        }
Hi all, i want to run all test classes in production ? to know code coverage in production.
is this operation will effect or problem to the current  fuctionality due to" run all tests"??  ..
is there any effect to the live users at the time of run all tests operation??
if i get test classes failure during run all tests operation.. will it effect existing functionality or any problem to the live user??


thanks
sridhar
Hello!

I have been given the task of creating cases whenever a task with a specific subject is attached to a contact.  It works just fine for new contacts in the system, but every time marketing inserts new campaigns, a case is created for every past task with the subject as well.  So at times we can get 100+ cases created on old tasks.  The code that I am using is below:

Trigger:

trigger taskToCaseCreate on Task (after insert, after update) {
        if(checkRecursive.runOnce())
    {

    
    List<Task> newTaskList = new List<Task>();
    
    If (Trigger.isInsert){
        For(Task T: Trigger.new){
            If (T.WhoId != NULL){
                newTaskList.add(T);
            }
        }
    }
    
    If (Trigger.isUpdate){
        For(Task T : Trigger.new){
            String o = trigger.oldMap.get(T.ID).WhoID;
            If (T.WhoId != NULL && T.Subject.contains('Submitted Form')){
            If(Trigger.oldMap.get(T.Id).WhoId != Trigger.newMap.get(T.Id).WhoId && !o.startswith('003')){
                newTaskList.add(T);
            }
            }
        }
    }
    
       If(newTaskList.size() > 0){
    createCaseFromTask.createCaseFromTask(newTaskList);
    }
    }
}

Class:

public class createCaseFromTask {
    Public Static void createCaseFromTask(Task[] newTask){
        
        List<Case> newCase = new List<Case>();
        
         for (Task n:newTask){
             String s = n.WhoId;
             
                If(s.startswith('003') && n.subject.contains('Submitted Form') && (n.subject.contains('Demo') || n.Subject.contains('Contact'))){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Demo Request');
                   // newCase.add(c);
                     Insert c;
                }     
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Content Download')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Content Download');
                  //  newCase.add(c);
                     Insert c;
                  
                }
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Webinar')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Webinar');
                  //  newCase.add(c);
                     Insert c;
                  
                }
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Blog')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Subscribed to Blog Notifications');
                 //   newCase.add(c);
                     Insert c;
                   
                }  
                If(s.startswith('003') && n.subject.contains('Submitted Form') && !n.subject.contains('Blog') && !n.subject.contains('Webinar') && !n.subject.contains('Content Download') && !n.subject.contains('Demo') && !n.Subject.contains('Contact')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Submitted Form');
                  //  newCase.add(c);
                     Insert c;
                  
                } 
              //  Insert newCase;
                }
    }

}



To add to this, we insert everything into the system as a lead.  Then we have a piece of code that autoconverts the lead to a contact and deduplicates it in the process.  So marketing inserts their lists as leads, and then the leads run through the code, get converted to contacts, then merged.  It seems that when they merged, all the tasks are retriggered.  I tried turning the oldmap ID into a string and skipping it when the old ID is a contact as well but it is still creating the cases.  Any help would be much appreciated.

Thanks!
Once you complete a superbadge, you can no longer view the challenge list. Is there a list somewhere of all the superbadge challenges so I can go back and review them?
Hi all,

I am struggling since hours trying to find out what the root cause is and how to solve it, but til now without success.

I am trying to deploy a test class.
Here the following relationship: Account has a master detail relationship with Admissions (Admisiones), Study Interests (Intenciones de Estudio), Enrollments (Matriculaciones), Pre-enrollments (Preinscripciones) and Actas.

When trying to deploy the test class, I am getting these errors:
 
EnvioDeCorreoTest	ActaTest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.ActaTest: line 146, column 1

EnvioDeCorreoTest	Admisiontest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Admisiontest: line 36, column 1

EnvioDeCorreoTest	Intencionesestudiotest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Intencionesestudiotest: line 54, column 1

EnvioDeCorreoTest	Matriculaciontest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Matriculaciontest: line 98, column 1

EnvioDeCorreoTest	Preinscripciontest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Preinscripciontest: line 73, column 1

EnvioDeCorreoTest	Titulotest	System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Titulotest: line 122, column 1
My code has the following Method:
 
public static void InsertAccount() {

        Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
        account = new Account(Name = 'Test Account', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
        insert account;
        
   }
What it does is to insert a new account with record type "Alumnos" (Students).

My test class EnviodeCorreoTest looks like this:
 
@isTest(SeeAllData=true)
private class EnvioDeCorreoTest {

    static Preinscripci_n__c preinscripcion;
    static Product2 postgrado;
    static Account account;

   public static void InsertAccount() {

        Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
        account = new Account(Name = 'Test Account', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
        insert account;
        
   }
   
 @isTest 
    static void Admisiontest() {
        
        InsertAccount();
        InsertPostgrado();
        InsertContacto();
        Admisi_n__c admision = new Admisi_n__c();
        admision.Nombre_de_la_cuenta__c = account.Id;
        admision.Idioma_de_preferencia__c = 'Español';
        admision.Programa_Acad_mico__c = postgrado.Id;

        insert admision;
        
        Test.startTest();
        EnvioDeCorreo.enviarCorreoAdmision(admision, 'Notificaci_n_de_registro_de_Admision');
        Test.stopTest();
    }

...
the rest of the methods for enrollments, pre-enrollments, etc. look similar

What I don't understand is, where is the issue. The error is pointing to the field "Name" of the object Account, so far I understand. If I am executing the deployment as Admin, I have access to this field. In the method Admisiontest() I am calling the InsertAccount() method.
All error lines are also pointing to the line:

InsertAccount();

Can please somebody help me to find the answer?. I am stuck in this issue and can not deploy to Production :(.

 
So I have a Visualforce page that I have created that is related to a standard controller and also an extension to an 'Apex' controller. I've taken the 'Trailhead' training on testing an Apex class, but I can't seem to successfully apply what I learned in the Trailhead tutorial to my project and get there to not be syntax errors in my test code. I have only working on my first Visualforce/Apex project for a week now, so I'd sure welcome any suggestions anyone might have. The primary Methods that I am calling from the Visualforce Page are 'Save', 'Add' and 'Delete', so any help in any of those methods that I could then apply to the others would be greatly appreciated.

VISUALFORCE CODE:
<apex:page standardController="Request__c" extensions="TrController" >
    <!-- The following code will fix a problem with the calendar autospawning when the time entries are displayed. -->
    <script>
        function setFocusOnLoad(){ Coment.focus(); }
    </script>
   
    <!--Because we will be defining 'Input' fields, we must wrap our code in a 'Form' block. -->
    <apex:form id="Time_Entry_Form">
        <apex:pageBlock title="CDCR - Salesforce Time Reporting for Requests" id="Time_Entry_List">
           
            <!-- The following pageBlockButtons segment defines the two buttons that appear at the top of the Time entry form. -->
            <apex:pageBlockButtons id="Button_area">
                <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
                <apex:commandLink >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" class="btn">New</a>               
                </apex:commandLink>
               
                <apex:commandLink >
                    <a href="javascript: SaveEntry();" class="btn">Save</a>               
                </apex:commandLink>

            </apex:pageBlockButtons>
           
             <!-- The following pageBlockTable segment defines the time entry rows that will be displayed. -->
            <apex:pageBlockTable value="{!TimeEntries}" var="entry" id="Entry_Table_List">
                <apex:column width="45" headerValue="Action">
                    <a href="javascript:if (window.confirm('Are you sure?')) DeleteEntry('{!entry.Id}');" style="font-weight:bold">Del</a>               
                </apex:column>   
                <apex:column width="70" headerValue="Activity">
                    <apex:inputField value="{!entry.Activity__c}"/>
                </apex:column>   
                <apex:column width="70" headerValue="Date Worked">
                    <apex:inputField value="{!entry.Date_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Hours">
                    <apex:inputField value="{!entry.Hours_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Worked">
                    <apex:inputField value="{!entry.Minutes_Worked__c}"/>
                </apex:column>   
                <apex:column headerValue="Work Description">
                    <apex:inputField style="width:100%" value="{!entry.Work_Description__c}" id="comment"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <!-- This action block is executed based on the 'Delete' button being clicked on. -->
        <apex:actionFunction action="{!del}" name="DeleteEntry" reRender="Time_Entry_List">
            <apex:param name="EntryID" value="" assignTo="{!SelectedEntryID}"/>
        </apex:actionFunction>
       
         <!-- This action block is executed based on the 'New' button being clicked on. -->
        <apex:actionFunction action="{!add}" name="CurrRequest" reRender="Time_Entry_List">
            <apex:param name="EntryID" value="" assignTo="{!ReqID}"/>
        </apex:actionFunction>

         <!-- This action block is executed based on the 'Save' button being clicked on. -->
        <apex:actionFunction action="{!save}" name="SaveEntry" reRender="Time_Entry_List"/>
       
     </apex:form>
    <!-- The following script code is used in order to fix the problem with the calendar autospawning. -->
    <script>
        var Coment=document.getElementById('{!$Component.theForm.block.sec.item.comment}');
    </script>   
</apex:page>

CONTROLLER APEX CODE

public with sharing class TrController
{
    //This is the list for handling the group of time entries related to the parent object.
    public List<Time_Entry__c> TimeEntries {get;set;}
    //Used to get a hold of the entry record that is selected for deletion.
    public string SelectedEntryID {get;set;}
    //Used to get the parent request object ID from the Visual force page to the controller.
    public string ReqID {get;set;}
    public TrController(ApexPages.StandardController controller)
    {
        //Obtain the parent object Id from the the visualforce form.
        ReqId = Apexpages.currentPage().getparameters().get('Id');
        //Call the loaddata method to laod the time entries related to the parent object.
        LoadData();
     }
    public void LoadData()
    {
        //Obtain the first 15 bytes of the Parent Object ID to use for record selection.
        string RequestID = ReqId.substring(0, 15);
        //Load the related time entry records from the database.
        TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c from Time_Entry__c WHERE Related_Object__c=:RequestID order by ID DESC];

    }
    public void save()
    {
        //Update the Salesforce database with the data entred.
        update TimeEntries;
    }
    public void add()
    {  
       //Obtain the first 15 bytes of the Parent Object ID to use for record identification.
        string RequestID = ReqId.substring(0, 15);
        //Build the default values to the new time entry record.
        Time_Entry__c entry = new Time_Entry__c(Activity__c='Research', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='00', Related_Object__c=RequestID);
        //Insert the new default time entry row into the Salesforce database.
        Insert entry;
        //Call the method to reload the Visualforce list.
        LoadData();
    }
    public void del()
    {   
        //if we are missing the reference, then do nothing except return.
        if (SelectedEntryId == null)
        {
            return;
        }
        
        //If the record is within the collection, then delete it.
        Time_Entry__c tobeDeleted = null;
        for(Time_Entry__c a : TimeEntries)
        if (a.Id == SelectedEntryId)
            {
                tobeDeleted = a;
                break;
            }
        //If account record found then delete it.
        if (tobeDeleted != null)
            {
                Delete toBeDeleted;
            }
        //Refresh the list
        LoadData();

    }

}

Thank you in advance for your time.

Eric Anderson 
Hi Friends, I am new to SFDC development.

I wrote a batch apex class. When I try to run it from developer console. It's not printing debug statements of start and execute methods. directly it's going to finish method.

Can any one help me in this?
Hi,

I'm passing accountid as id and contactid in the url.

When the users click save, I need to update a datefield__c to today(without time) on contact object.

Here is my vf page - 
<apex:page controller="myAudit">
    <apex:form >
        <apex:pageblock >
          <apex:pageblockSection columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
              <apex:commandButton action="{!save}" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

My apex class:
public class myAudit {

   public myAudit() {
    account =  [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
   }

    public String account { get; set; }

    public String txtSurvey { get; set; }

    public PageReference save() {
         Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
            aq.Name = txtSurvey;
            aq.account__c = apexpages.currentpage().getparameters().get('id');
            insert aq;
            return null;
        }
}
 
  • April 17, 2017
  • Like
  • 0
i want to get results even if i give single letter in searchfield
help me in getting output i tried to manage but still errors 




public class OppNameSearchController {
    public string Name{set;get;}
    public Decimal amount{set;get;}
    public Opportunity Opp{set;get;}
    public string searchstring {get;set;} 
    public boolean show{set;get;}
    
    public void method()
    {
        
       if(searchstring != null && searchstring != '' ){  
    string searchquery='select Name, Amount from opportunity where Name like \'%'+searchstring+'%\'  Limit 10';  
    
     Opp = Database.query(searchstring); 
           show = true;

                   }
        else
        {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'There are no Opportunities with the Name -'  +searchstring);
            ApexPages.addMessage(myMsg);
            show = false;
        }
    }
    
    public void save()
    {
        Opportunity op = Opp;
        update op;
      }
     public void clear(){  
   opp.clear();  
   }  
}







<apex:page controller="OppNameSearchController" >
    <apex:form>
        <apex:pageBlock >
            <apex:pageBlockSection title="Search Filter" >
                Opportunity Name: <apex:inputText value="{!searchstring}"/>
                <apex:commandButton value="Search" action="{!method}" />
            </apex:pageBlockSection>
            <apex:pageMessages ></apex:pageMessages>
            
            
            <apex:pageBlockSection title="Searched Record" rendered="{!show}" >
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                                        hideOnEdit="editButton" event="ondblclick" 
                                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit">
                    <apex:outputField value="{!Opp.Name}"></apex:outputField>
                    <apex:outputField value="{!Opp.Amount}"/>
                </apex:inlineEditSupport>
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!clear}" value="reset"/>
            </apex:pageBlockSection>
        </apex:pageBlock>        
           
        
    </apex:form>
</apex:page>



 
Hi,
I have a custom object Manager__c with two fields
Name (Text) - Standard Field
Designation__c (Text(2)) // Just 2 characters.

I wrote the following class to insert two records and using Database.Insert to execute all records even if one fails.
Public class SampleCode
{
    public static void method1()
    {
        List<Manager__C> lstman = new LIst<Manager__c>();
        for(integer i=1;i<3;i++)
        {
           //Manager name as 1,2
           Manager__c man = new manager__C(name=string.valueof(i)); 
           lstman.add(man);
        }
        Database.saveResult[] insres = database.insert(lstman,false);
        for(Database.saveresult res: insres)
        {
            for(Database.Error er : res.getErrors())
            {
                system.debug(er.getmessage());
            }
        }
         
    }
}

I wrote the following trigger (before insert) to set the designation with more than allowed characters.
trigger Manager on Manager__c (before insert) {
    for(Manager__c man : Trigger.New)
    {
       //Following should make all the records error.
        man.Designation__c = 'Executive'; 
    }
}

When I execute the above apex class method, the records are not inserted (as expected).But i am not getting the system validation error messages (some thing like TOO long text...) in the debug statement.
I need a solution for this, like where to write the addError() method in the trigger or any other way. 
Note: All the records inserted in the list should fail and i need errors for all the records to get displayed in system.debug.
There is a very interesting problem that I am seeing. The below soql 

select Id,name from CaseTeamRole returns 2 rows 


 IdName
10B71a000000PBGRCA4Contributor
20B71a000000PBGWCA4Read Only

where as 

the soql 

select Id,name from CaseTeamRole name = 'Contributor' returns 0 rows. 

The happens only our full sandbox and on production our queries execute perfectly fine. 
Has anyone faced such an issue ? Need help in resolving it.
 
I have a trigger on Opps and need to execute some logic if the opp is associated to only one Account Record type. How do I do this?

trigger UpdateTeamMember on Opportunity (After insert, after update) {
    if(trigger.isUpdate){
        for(opportunity o : trigger.new){
            if(o.account.recordtypeid == 'xxxxx') >> does not work?

Any ideas?
  • April 03, 2017
  • Like
  • 1
Hi all, i want to run all test classes in production ? to know code coverage in production.
is this operation will effect or problem to the current  fuctionality due to" run all tests"??  ..
is there any effect to the live users at the time of run all tests operation??
if i get test classes failure during run all tests operation.. will it effect existing functionality or any problem to the live user??


thanks
sridhar
Hello!

I have been given the task of creating cases whenever a task with a specific subject is attached to a contact.  It works just fine for new contacts in the system, but every time marketing inserts new campaigns, a case is created for every past task with the subject as well.  So at times we can get 100+ cases created on old tasks.  The code that I am using is below:

Trigger:

trigger taskToCaseCreate on Task (after insert, after update) {
        if(checkRecursive.runOnce())
    {

    
    List<Task> newTaskList = new List<Task>();
    
    If (Trigger.isInsert){
        For(Task T: Trigger.new){
            If (T.WhoId != NULL){
                newTaskList.add(T);
            }
        }
    }
    
    If (Trigger.isUpdate){
        For(Task T : Trigger.new){
            String o = trigger.oldMap.get(T.ID).WhoID;
            If (T.WhoId != NULL && T.Subject.contains('Submitted Form')){
            If(Trigger.oldMap.get(T.Id).WhoId != Trigger.newMap.get(T.Id).WhoId && !o.startswith('003')){
                newTaskList.add(T);
            }
            }
        }
    }
    
       If(newTaskList.size() > 0){
    createCaseFromTask.createCaseFromTask(newTaskList);
    }
    }
}

Class:

public class createCaseFromTask {
    Public Static void createCaseFromTask(Task[] newTask){
        
        List<Case> newCase = new List<Case>();
        
         for (Task n:newTask){
             String s = n.WhoId;
             
                If(s.startswith('003') && n.subject.contains('Submitted Form') && (n.subject.contains('Demo') || n.Subject.contains('Contact'))){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Demo Request');
                   // newCase.add(c);
                     Insert c;
                }     
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Content Download')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Content Download');
                  //  newCase.add(c);
                     Insert c;
                  
                }
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Webinar')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Webinar');
                  //  newCase.add(c);
                     Insert c;
                  
                }
                If(s.startswith('003') && n.subject.contains('Submitted Form') && n.subject.contains('Blog')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Subscribed to Blog Notifications');
                 //   newCase.add(c);
                     Insert c;
                   
                }  
                If(s.startswith('003') && n.subject.contains('Submitted Form') && !n.subject.contains('Blog') && !n.subject.contains('Webinar') && !n.subject.contains('Content Download') && !n.subject.contains('Demo') && !n.Subject.contains('Contact')){
                    Case c = new Case(ContactId = n.WhoId, Status = 'New', Subject = 'Submitted Form');
                  //  newCase.add(c);
                     Insert c;
                  
                } 
              //  Insert newCase;
                }
    }

}



To add to this, we insert everything into the system as a lead.  Then we have a piece of code that autoconverts the lead to a contact and deduplicates it in the process.  So marketing inserts their lists as leads, and then the leads run through the code, get converted to contacts, then merged.  It seems that when they merged, all the tasks are retriggered.  I tried turning the oldmap ID into a string and skipping it when the old ID is a contact as well but it is still creating the cases.  Any help would be much appreciated.

Thanks!