• Srikanth Cheera 16
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
If i click on new Button this page should be open?
what is the process.

<apex:page standardController="Order">
    <apex:form>
    <apex:pageBlock title="OrderEdit">
        <apex:pageBlockButtons location="Top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Delete" action="{!Delete}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Order Information">
        <apex:inputField value="{!order.name}"/>
            <apex:inputField value="{!order.AccountId}"/>
            <apex:inputField value="{!order.ContractId}"/>
            <apex:inputField value="{!order.Status}"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Error:Apex trigger TaskToCommunityTrigger caused an unexpected exception, contact your administrator: TaskToCommunityTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Class.TaskToCommunity.aftrupdate: line 27, column 1
=======================================================================
public class TaskToCommunity {

    public static void aftrupdate(Map<id,contact> oldmap,Map<id,Contact> newmap){

        list<Task> ta=new list<Task>();
        user u=[select id from user where alias='sree'];

        // profile p=[select id from profile where name='Partner Community User'];
        for(id key:oldmap.keyset()){
            Contact old=oldmap.get(key);
            Contact newmp=newmap.get(key);
            
            if(old.Phone!=newmp.Phone){
                Task t=new Task();
                t.OwnerId=u.id; 
               // t.OwnerId=p.id; 
                //t.OwnerId=userinfo.getUserId();
                t.Status='Pending';
                t.Priority='Normal';
                //t.WhatId=newmp.id;
                
                t.ActivityDate=system.today();
                t.Subject='Testing';
                ta.add(t);
            }
        }
        update ta;
    }
}
===============================================================================================
trigger TaskToCommunityTrigger on Contact (after update) {

    if(trigger.isafter && trigger.isupdate){
    TaskToCommunity.aftrupdate(Trigger.oldmap, Trigger.newmap);
}
}

 
Error:Apex trigger TaskToCommunityTrigger caused an unexpected exception, contact your administrator: TaskToCommunityTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Class.TaskToCommunity.aftrupdate: line 27, column 1
=======================================================================
public class TaskToCommunity {

    public static void aftrupdate(Map<id,contact> oldmap,Map<id,Contact> newmap){

        list<Task> ta=new list<Task>();
        user u=[select id from user where alias='sree'];

        // profile p=[select id from profile where name='Partner Community User'];
        for(id key:oldmap.keyset()){
            Contact old=oldmap.get(key);
            Contact newmp=newmap.get(key);
            
            if(old.Phone!=newmp.Phone){
                Task t=new Task();
                t.OwnerId=u.id; 
               // t.OwnerId=p.id; 
                //t.OwnerId=userinfo.getUserId();
                t.Status='Pending';
                t.Priority='Normal';
                //t.WhatId=newmp.id;
                
                t.ActivityDate=system.today();
                t.Subject='Testing';
                ta.add(t);
            }
        }
        update ta;
    }
}
===============================================================================================
trigger TaskToCommunityTrigger on Contact (after update) {

    if(trigger.isafter && trigger.isupdate){
    TaskToCommunity.aftrupdate(Trigger.oldmap, Trigger.newmap);
}
}