cancel
Showing results for 
Search instead for 
Did you mean: 

Add contactsubject without adding an contact with di api

Former Member
0 Kudos

Hello,

Does someone has an example or solution for adding an contactsubject (cntctsbjct), with the di-api.

Add an contacttype is not a problem, but add an subject (linked with a contacttype) is.

Does someone has a solution?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Not sure whether I understand your question. Subject is a property of Contacts

object. So you need to create a business object of type oContacts / set the

Subject property (it is a string) / and add it in the DB.

But maybe I don't get what you mean ....

Answers (4)

Answers (4)

Former Member
0 Kudos

As old as this thread is, I still think it might help some who Google it and find this post. I recently had this issue and solved it with the following (C#) code to define the subject.

oContacts.Subject = "1";

The subject field is a string which takes a number in the form of a string. This will set the subject of the contact/activity to the first subject defined in the system.

You cannot add new subjects to an activity in oContacts because it does not contain a definition for it. It is held in a different table in the database OCLS. The field is not intended to have a million different subjects like say an email subject would over time. There might be a way to do that but I didn't look into it.

Hope this helps someone out there.

Peter

Former Member
0 Kudos

Hello,

I have changed it.

I am now making a button in the Activityform and when this button is pressed the activity will be added. But adding contact subject still don't work. The compiler getting out of the function. If I don't add subject the activity will be saved.

I rather prefer that the form updates with the saved data, but that is not working. I did try freeze, update and refresh... But only if I click to the next record, I see my saved data in the form. Can I use the api for this?

Does someone has a solution or workarround for these problems.

See my code:


If pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.BeforeAction = False Then
                If pVal.ItemUID = "CntrRvd" Then

                    Dim vCardcode = oForm.items.item("9").specific.value
                    '  oForm.close()
                    '// ***************************************************
                    Dim oContact As SAPbobsCOM.Contacts
                    oContact = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts)

                    oContact.CardCode = vCardcode
                    oContact.Closed = SAPbobsCOM.BoYesNoEnum.tNO
                    oContact.Activity = SAPbobsCOM.BoActivities.cn_Note
                    oContact.ActivityType = FindActivityTypeByName("Contract") '// finds activityType
                    oContact.Subject = "Received"
                    If oContact.Add() <> 0 Then
                        MessageBox.Show("Failed on add contact")
                    End If

Thanks for your help!

Former Member
0 Kudos

Add cardcode does not work for me.

But if I add a subject with :

SBO- activities- choose an activityType and define a new subject,

Cardcode is not asked.

I can cancel the activity but the activitySubject (linked with the activityType) is saved.

This documentation where you wrote about. Where can I get it?

Thanks and a nice weekend.

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Documentation is the SDK help file. It contains all the references for DI / UI / etc.

You can download it here from SDN. It is called SDK Help Center.

Former Member
0 Kudos

Yes, I want add a subject linked with a Type using the di-api.

This code is not working:

Dim oAc As SAPbobsCOM.Contacts

oAc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts)

oAc.Activity = SAPbobsCOM.BoActivities.cn_Note

oAc.ActivityType = 1

oAc.Subject = "test"

oAc.Add()

The table for the subject is: OCLS.

The table for the activityType is: OCLT

When add an subject in SBO without using the di-api and not add the activity it's no problem. Can someone help me, please

Thanks

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Aren't you miss the CardCode ? the documentation says that is mandatory ...

Former Member
0 Kudos

Hello,

I don't know what I do wrong?! Maybe it's a bug in SBO?

If I add an activity with subject it goes wrong, without a subject it's been saved.

Code for the DI-Api:


        Dim oAc As SAPbobsCOM.Contacts
        oAc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts)
        oAc.CardCode = vCardcode ' this must be a bp that exists
        oAc.Activity = SAPbobsCOM.BoActivities.cn_Note
        oAc.ActivityType = FindActivityTypeByName("Contract")
        oAc.Subject = "Ontvangen"
        oAc.Details = "TEST"
        oAc.Add()

I even tried it with the ui-api. Filling the form goes well but when I am pressing the add-button SBO gives a statusbarmessage (173-36). The value of the subjectcombobox is not valid.


'// Fill combobox subject
                    Dim oActSubjCombo As SAPbouiCOM.ComboBox
                    oActSubjCombo = oForm.Items.Item("35").specific
                    oActSubjCombo.ValidValues.Add(oActSubjCombo.ValidValues.Count + 1, "Ontvangen")
                    oActSubjCombo.Select("Ontvangen", SAPbouiCOM.BoSearchKey.psk_ByDescription)

Could someone explain how can I resolves this problems.

Maybe the first one is a bug in SBO, or does someone has a working example.

Or someone knows how I can generate a good value for add the subject with the UI-Api.

How that someone can help me, thanks.