cancel
Showing results for 
Search instead for 
Did you mean: 

URGENT: Service Call Activity Issue

Former Member
0 Kudos
372

Hi guys, I have a seriously irritating issue concerning the linking of an activity to service call.

As of Service Pack 01, Patch 36 (at least as far as I know) I get the following error when attempting to create and link an activity to a service call:

Error Code: -5002

Error Description: A service call activity does not exist

I use the folliwing code;

If oServ.GetByKey(MRI) Then
                If DocType = "QT" Then
                    oAct = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts)
                    oAct.Activity = SAPbobsCOM.BoActivities.cn_Task
                    oAct.CardCode = oServ.CustomerCode
                    oAct.DocEntry = DocID
                    oAct.DocType = 23
                    oDoc = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations)
                    If oDoc.GetByKey(DocID) Then
                        oAct.Notes = "Sales Quote: " & oDoc.Comments
                    End If
                    oAct.Details = "Sales Quote " & DocID & " auto created by MRI " & MRI & ""

                    If oAct.Add <> 0 Then
                        oApp.SetStatusBarMessage("Error adding Linked Document Activity for Sales Quote " & DocID & " : " & oComp.GetLastErrorDescription)
                        oLog.WriteLog("Error adding Linked Document Activity for Sales Quote " & DocID & " : " & oComp.GetLastErrorCode & oComp.GetLastErrorDescription, EventLogEntryType.Error)
                    Else
                        oServ.Activities.Add()
                        oServ.Activities.ActivityCode = oComp.GetNewObjectKey
                        oServ.Activities.SetCurrentLine(oServ.Activities.Count() - 1)
                    End If

 If oServ.Update <> 0 Then
                    oApp.SetStatusBarMessage("Error linking Expense Document " & DocID & ":" & oComp.GetLastErrorDescription)
                    oLog.WriteLog("Error linking Expense Document " & DocID & ":" & oComp.GetLastErrorCode & "-" & oComp.GetLastErrorDescription, EventLogEntryType.Error)
                End If

the Activity is added without any problem, but the error comes when linking it to the Service Call (oServ.Update)

Can you please help, I'm going insane with this problem.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

How did you solve the issue of the count returning 1 for (0 and 1) linked activities?

Thanks Matt.

Former Member
0 Kudos

this is how i got it to work:

ServiceCalls sc = null;
sc = (ServiceCalls)company.GetBusinessObject(BoObjectTypes.oServiceCalls);
if (!sc.GetByKey(callId))
      throw new Exception("Failed to add service call activity! Service call does not exist!");
if (sc.Activities.Count == 1)
{
         sc.Activities.SetCurrentLine(sc.Activities.Count - 1);
         string temp = sc.Activities.ActivityCode.ToString();
         if (!string.IsNullOrEmpty(temp) && !temp.Equals("0"))
                 sc.Activities.Add();
}
else
         sc.Activities.Add();
sc.Activities.SetCurrentLine(sc.Activities.Count - 1);
sc.Activities.ActivityCode = int.Parse(lastAcctivity);
if (sc.Update() != 0)
{
         company.GetLastError(out errorCode, out errorMsg);
          if (null != sc)
          {
                  System.Runtime.InteropServices.Marshal.ReleaseComObject(sc);
                  sc = null;
          }
throw new Exception(errorCode + " -> " + errorMsg);
}

You could either use that piece of code or make an insert in SCL5.

Nussi
Active Contributor
0 Kudos

Hi,

maybe it has something to do that you have not set the

ParentobjectId

Description:

Returns the source object ID of the activity:

-For Service Call object type: ServiceCallID.

-For Sales Opportunity object type: SequentialNo.

iam not sure if it will help you, but have a look at it

regards

David

Former Member
0 Kudos

Hi again David,

I thought it might be that, but the issue is that the ParentObjectID and ParentObjectType fields are read only. And I cant update/change them.

Or am I missing something?

Nussi
Active Contributor
0 Kudos

no, it was my mistake.

you have to do it like in the business one client.

use the ServiceCalls Object and add the activity.

regards

David

Former Member
0 Kudos

I have found the source of the problem. It seems that as of SP01 PL36 (+-) SBO does not require you to create a new activity line for the Service Call if it's the first activity to be linked. In other words, for the first activity to be linked you should not add oServiceCall.Activities.Add. However, this line of code is required for any additional activities to be added.

I do not agree with this methodology seeing as it only makes sence if you are linking a batch of Activities through a loop. The problem is that usually you will only want to link a single Activity at a time after a specific action was taken.

Also, the oServiceCall.Activities.count returns 1 if there is 1 OR zero activities linked to the service call.

Anyway, I hope this helps anyone struggling with this issue.