Having a problem while creating the activity. We used both ways to create activity. 1. By contact object (Name of Activity - Demo_a) 2. By CActivity object (Name of Activity - Demo_b) We see that the Activity is not saved on the database because activity.Save() is returning false value.
Trying to Create Activity but Activity.Save() returns false value
have a code sample?
Do you have a code sample of how you are instantiating the activity?
I've used something like this... where "Nominator" was an activity I created.
CActivity activity = new CActivity(contactUser, "NOMINATOR", contactId)
What kind of activity is it?
Just wondering.
I was missing the validate
I was missing the validate function. Now that I have applied it, the application is working fine thanks
Just built activity creation code
I just did this for a client that imports thousands of records and creates activities for each. I have had zero errors by invoking based from the contact object like this below. Nassir's suggestion is a good one too but if you are validating and handling errors do it at both the activity and contact levels. Here is a sample - cheers.
Joe John
John Consulting
//create the activity record for termination
CActivity _membAct = _contact.NewActivity("MEMBERSHIP");
_membAct.TransactionDate = DateTime.Now.Date;
_membAct.EffectiveDate = DateTime.Now.Date;
_membAct.ProductCode = "TERMINATION";
_membAct.ThruDate = DateTime.Now.Date;
_memberAct.Validate();
_membAct.Save();
if (_contact.Errors.ErrorCount > 0)
{
//this is where we would write to a log file
}
Worked fine, thanks, I was
Worked fine, thanks, I was missing the validate function.
Thanks for the tip
I will use NewActivity IBO method...much more streamlined than what i was using....good to learn something new about IBO.
Invoke Validate
iBO tries to respect the system configuration that was setup. So if you have any rules in the acitivty, it will make that those rules are satisfied.
So before saving, call CActivity object Validate() method. And then you can find the errors using CActivity object ErrorsCount and Errors.GetError(<index>) if there were any errors.
If there were no errors, then SAVE would succeed.
Nazer