cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Cloud SDK : Copy PhoneCall Activity Notes fields into Custom Notes fields

Former Member
0 Kudos

Hi Experts,

Scenario : I have requirement to copy some fields ( Activity ID , Subject , Notes etc)  from standard activity ( Phone Call , Appointment , Task etc) into my custom business object node level data .

Issue : How to Copy Notes field from standard activity into my custom activity Notes fields my custom business object sample definition

businessobject BOCustomActivity {

[Label("Description")] element Descr : LANGUAGEINDEPENDENT_LONG_Text;

[Label("Start Date")] element StartDate : Date;

[Label("End Date")] element EndDate : Date;

node Cust_Act_send [0,n] {

     [Label("Activity ID")] element ActID : BusinessTransactionDocumentID;

     [Label("Activity Subject")] element ActName : EXTENDED_Name;

     [Label("Activity Type")] element ActType : LANGUAGEINDEPENDENT_MEDIUM_Text;

     [DependentObject(TextCollection)] node myNode;

  }

action UpdateData;

}

In the above business object under the node level i can assign the Activity ID,  Activity Subject , Activity Type from standard activity using Query and update the node level records,

But I want to assign Notes ( TextCollection Text ) from standard activity notes fields.

In the below screen we have 2 records from standard phone call activity.

I am using the below code to get the record from standard phone call activity.

import ABSL;

import AP.FO.Activity.Global;

var noderef : elementsof BOCustomActivity.Cust_Act_send;

var nodeins;

var query = PhoneCallActivity.QueryByElements;

var resultData = query.Execute();

// 2. Selection

var selectionParams = query.CreateSelectionParams();

selectionParams.Add(query.ID.content, "I", "BT", "2551", "2555");

// Result

resultData = query.Execute(selectionParams);

foreach ( var record in resultData)

{

  noderef.ActID = record.ID;

  noderef.ActName.content = record.Name.content;

  noderef.ActType = record.TypeCode.GetDescription();

                   (?)       = record.TextCollection.Text.TextContent.GetFirst().Text.content

  nodeins = this.Attachment.Create(noderef);

}

in the above code the Activity ID , Activity Name , Activity Type but how to copy the Notes ( TextCollection Text ) into the node element myNode (TextCollection) and assign and update on node level element .

I have check the post :

But did not solve the issue.

Please anyone have idea about the above requirement.

IF anyone want more explanation kindly let me know.

Many Thanks,

Mithun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello

try this (I didn't try in my system maybe some adjustements are needed)


if (record.TextCollectiont.IsSet() && record.TextCollection.Text.Count() > 0){

  foreach (var txtCnt in record.TextCollection.Text){

       if (txtCnt.Text.isSet()){

            if (!noderef.TextCollection.IsSet()){

                 noderef.TextCollection.Create();

            }

            var text = noderef.TextCollection.Text.Create();

            var textContent = text.TextContent.Create();

            textContent.Text = txtCnt.Text.TextContent.Text;

       }

  }

}

Former Member
0 Kudos

Hello Sir,

In my BO structure

businessobject BOCustomActivity {

node Cust_Act_send [0,n] {

     [Label("Activity ID")] element ActID : BusinessTransactionDocumentID;

     [Label("Activity Subject")] element ActName : EXTENDED_Name;

     [Label("Activity Type")] element ActType : LANGUAGEINDEPENDENT_MEDIUM_Text;

     [DependentObject(TextCollection)] node myNode;

  }

action UpdateData;

}

and in ABSL code :

var noderef : elementsof BOCustomActivity.Cust_Act_send;


Here the noderef is the reference of the only node Cust_Act_send.

When i type

noderef.mynode is not possible

or

nodefer.TextCollection.Create(); is also not possible in my case.

Do you have another ways similar with my businessobject  ?

Also where i can put the your code before node create or after node create?

Before this Code

nodeins = this.Cust_Act_send.Create(noderef);

or

After this code

nodeins = this.Cust_Act_send.Create(noderef);

Many Thanks,

Mithun

Former Member
0 Kudos

Hello,

yes sorry, I didn't notice.

In this case you have to put my code after the node creation, so after the line

nodeins = this.Cust_Act_send.Create(noderef);

then:

  1. if (record.TextCollectiont.IsSet() && record.TextCollection.Text.Count() > 0){ 
  2.   foreach (var txtCnt in record.TextCollection.Text){ 
  3.        if (txtCnt.Text.isSet()){ 
  4.             if (!nodeins.TextCollection.IsSet()){ 
  5.                  nodeins.TextCollection.Create(); 
  6.             } 
  7.             var text = nodeins.TextCollection.Text.Create(); 
  8.             var textContent = text.TextContent.Create(); 
  9.             textContent.Text = txtCnt.Text.TextContent.Text; 
  10.        } 
  11.   } 
Former Member
0 Kudos

Sorry Sir,

But i tried the above code getting below error.

because nodeins is simple variable

var nodeins;

and i am using nodeins at

nodeins = this.Cust_Act_send.Create(noderef);

and this statement create the node entry but not update myNode because this is DependentTextCollection       [DependentObject(TextCollection)] node myNode;

Can you please suggest me how to create or assign value to myNode text context?

Many Thanks,

Mithun

Former Member
0 Kudos

I replicated the case in my system. Some little changes but you are near to the solution

Former Member
0 Kudos

Thanks for sharing the ABSL code

Can you please share the BO definition of above code?

Many Thanks

Mithun

Former Member
0 Kudos
Former Member
0 Kudos

Hello sir,

I am getting exception or dump in the below code...

if (record.TextCollection.IsSet() && record.TextCollection.Text.Count() > 0) {

  foreach (var txtCnt in record.TextCollection.Text)

  {

       if (txtCnt.TextContent.IsSet())               // Error in this line

       {

            var text = nodeins.myNode.Text.Create();

            var txtcontent = text.TextContent.Create();

            txtcontent.Text = txtCnt.TextContent.Text;

       }

  }

}

Error Details : No access possible via a 'NULL' data reference.

Please suggest me whats wrong in the above code?

Many Thanks,

Mithun

Former Member
0 Kudos

uhmmmm

try modifying the line like this

if (txtCnt..isSet() && txtCnt.TextContent.IsSet()) 


one question: the selected PhoneCallActivity (in the particular case) has some text?

Former Member
0 Kudos

I tried using below code but getting same error.

Please check when i debug the record from query as below Phone Call Activity

When i update data the error comes at the statement as below .

Please suggest me whats wrong ........

Many Thanks,

Mithun

Former Member
0 Kudos

It is very strange,

I don't know

Did you try to separate the two conditions?

if (txtCnt..isSet()){



if (txtCnt.TextContent.IsSet()) {


...


}


}

Former Member
0 Kudos

Sorry

getting same error

Many Thanks,

Mithun

Former Member
0 Kudos

So you are getting an error on txtCnt instance, and this error is saying that the instance is null.

This is not possible because of the if condition that you put before (if(txtCnt.IsSet()){...})

Please try to reactivate the method and refresh the UI, if the problem persists I am really confused. Maybe you should raise an incident.

Anyway please note also that the PhoneCallActivity BO is deprecated and should not be used. You should use Activity BO instead.

Former Member
0 Kudos

Hello Sir,

Thanks for help me....

Many Thanks,

Mithun

Answers (0)