You need to sign in to do that
Don't have an account?
Moha
Id not specified in an update call
Hello, well i have a request i have Contact that participate in one Event or More, now if the contact is already participatin i'm able to retreive his details in this participation and show them then modify if he wants to, but if he doesn't have a participation in any event i can click on New button and Create new participation and my problem is when i click on Save it gives me an Error which is " Id not specified in an update call"
Hi Jamal,
1. As you have initialize the object Related_Events_and_Reports__c
as related = new Related_Events_and_Reports__c(); //THIS LINE MEANS YOU HAVE GIVEN MEMORY TO THIS INSTANCE
so it can not be null;
I will explain it with example
Related_Events_and_Reports__c related; //MEMORY IS NOT ASSIGNED SO IT WILL BE NULL
Related_Events_and_Reports__c related = new Related_Events_and_Reports__c(); //MEMORY IS ASSIGNED AND CAN NOT BE NULL
It will alway goes in else if condition.
public void save() {
if (related == null ) {// CONTROL NEVER COMES HERE
//means if it's new record insert it
insert related;
}
try {
else if (related != null ) { // CONTROL ALWAYS COMES HERE
// if the record already exist update it
update related; // BUT AS YOUR RECORD HAS NOT BEEN CREATED IT WOULD NOT GET UPDATED
}
isEdit=false;
}catch(DmlException e){
ApexPages.addMessages(e);
}
2. now if i change in the if(related != null) TO if(related.id != null){ update related; } it doesn't give me the Error but it doesn't insert in the Table
as related.Id will be null so it will not go into the elseif condition and hence not showing any error
Hope this has answer to your question.
Please click on star to give KUDOS(if it helps you).
hey thanks for the reply, oke i got it now do u have an idea how can i insert new record while clicking on New whithout creating another VisualForce Page that contains the Fields to Fill and Save !!!