cancel
Showing results for 
Search instead for 
Did you mean: 

How can i add new activity by SDK?

Former Member
0 Kudos

Hi all experts,

What object should i declare to add/update activity (this table: OCLG)?

Thanks


TONY

Accepted Solutions (0)

Answers (1)

Answers (1)

AdKerremans
Active Contributor
0 Kudos

Hi Tony,

See the sample below.

CompanyService oCompServ = MyCompany.oComp.GetCompanyService();
ActivitiesService oActivityServ = (ActivitiesService)oCompServ.GetBusinessService(ServiceTypes.ActivitiesService);
Activity oAct = (Activity)oActivityServ.GetDataInterface(ActivitiesServiceDataInterfaces.asActivity);
ActivityParams oActParams;
oAct.CardCode="C30000";
oAct.HandledByEmployee = 2;
oAct.ActivityDate = DateTime.Parse("28/11/2012");
oActParams = oActivityServ.AddActivity(oAct);

Regards

Ad

Former Member
0 Kudos

Hi Ad Kerrenmans,

Thanks for your code. but after i run your code, it display an error like below:

and this is my source code that i added more:

Dim oCompServ As SAPbobsCOM.CompanyService

            oCompServ = PublicVariable.oCompany.GetCompanyService

            Dim oActivityServ As SAPbobsCOM.ActivitiesService = oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ActivitiesService)

            Dim oAct As SAPbobsCOM.Activity = oActivityServ.GetDataInterface(SAPbobsCOM.ActivitiesServiceDataInterfaces.asActivity)

            Dim oActParams As SAPbobsCOM.ActivitiesParams

            oAct.CardCode = "0020"

            oAct.HandledByEmployee = 11

            oAct.ActivityDate = Today.Date

            oAct.ActivityTime = Today.Date

            oAct.EndDuedate = DateTime.Parse("2/24/2013")

            oAct.EndTime = Today.Date

            oAct.Details = "Test from web"

            oAct.Notes = "Note from web"

            oAct.UserFields.Item("U_PTC").Value = "PTC from Web"

            oActParams = oActivityServ.AddActivity(oAct)

Please advise me.

Thanks

TONY

AdKerremans
Active Contributor
0 Kudos

Hi Tony,

I assume the error occurs on the last line or the code.

if you change

oActParams = oActivityServ.AddActivity(oAct)

to

oActivityServ.AddActivity(oAct)

is should work.

Regards

Ad

Former Member
0 Kudos

Hi Ad Kerremans,

Thanks for your second code. your code run well. i can add new activity.

beside of this, i want to update the existing activity by using activity code.but activity code property is read only property so i can't assign activity no to this field. oAct.ActivityCode=7

So do you know how i can do?

Thanks

TONY

AdKerremans
Active Contributor
0 Kudos

Hi Tony,

You should use set the code property of hte params object en use getbyparams to retrieve de activity.

It works the same as with UDO's

Regards

Ad

Former Member
0 Kudos

Hi Ad Kerremans,

thanks for your helpful code but i have a inquiries, how i can get the last activity key ? i can't use oCompany.GetNewObjectCode().

Thanks and Best Regards

Hoang Nghia