cancel
Showing results for 
Search instead for 
Did you mean: 

Errors While creating an Email Activity?

former_member221072
Participant
0 Kudos

Hi Experts,

I am creating an Email Activity  with the type code "39"  in the Before Save script file of Activity while saving the Activity Task(TypeCode: 542).

But i am getting the following errors with the standard code which sap has given in the repository explorer for Email Activity Creation..!!

these are the errors:

Please enter a process type.

Save failed. Technical error due to object ID not determined. Please report an incident.

Identity is invalid or could not be determined. Please check.

Date is invalid or could not be determined. Please check.

Save failed..

Why is that i am getting these errors?? i used the code which is there in the 1402 repository explorer..

Thanks,

Mani

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mani,

the problem was solved with the following workaround! Is working fine

Please check:


former_member221072
Participant
0 Kudos

Hi Allesandro,

Great Work..!!

I raised an incident to SAP, I am waiting for the response , If they can't fix this then i will implement the workaround.

I have everything ready to implement your work around.

Thank you for the work around.

Thanks,

Mani

Answers (1)

Answers (1)

Former Member
0 Kudos

In 1402 Cloud for Customer we re-architected the activity BO backend to make it more lean and simple. You will notice there are 2 "activity" BOs in the repository explorer, one that has been "deprecated" and the other "active". I have a working sample using the sample provided in the repository explorer to create activity tasks via a custom action. What I noticed is that if you don't reference the right "activity" you will inadvertently write code that will reference the deprecated activity. Your code will activate, but will not work. Once I referenced the right "activity" and then corrected the code (the new activity BO structure is different so the type-ahead code completion results are different) everything worked correctly.

As an FYI, pre 1402 ABSL code and UI designer configuration for any activity related SDK work (emails, tasks, appointments, phone calls) will need to go through this refactoring to use the new activity BO. The old activity BO is deprecated and custom business logic/custom UI referencing this old activity BO will not work anymore in 1402.

Here is my sample

/*

    Add your scripting language implementation for:

        Business Object: ServiceContract

        Node: Root

        Action: CreateActivityTask

      

    Note:

      - To access the elements of the business object node,

        use path expressions, for example, this.<element name>.

      - To use code completion, press CTRL+J.

*/

import ABSL;

import AP.PC.ActivityManagement.Global;

//Activity: Root node

var elActivityRoot :  elementsof Activity;

var instActivity;

// Activity: define party node

var elActivityParty : elementsof Activity.Party;

var instParty;

// Activity: define text collection

var elActivityTxtCollTxt:      elementsof Activity.TextCollection.Text;

var elActivityTxtCollTxtCntnt: elementsof Activity.TextCollection.Text.TextContent;

var instActivityTxtColl;

var instActivityTxtCollTxt;

// Activity: define attachment folder

var elActivityAttachmDoc:      elementsof Activity.AttachmentFolder.Document;

var instActivityAttachm;

// Activity: maintain Business Object type - mandatory (12 = Appointment; 39 = Email; 86 = Phonecall; 542 = Task)

elActivityRoot.TypeCode = "542"; // create Task

// Activity: maintain description - mandatory

elActivityRoot.SubjectName = "Task created for Contract";

elActivityRoot.ServiceContractIDForActivity = this.ServiceContractID;

// Activity: create new instance

instActivity = Activity.Create(elActivityRoot);

/*

// Activity: Organizer party - mandatory

if (! instActivity.OrganizerParty.IsSet()) {

        // supply party either with ID: MC2471 or Name: Kate Jacob or Email: Kate.Jacob@silverstar.us, etc.

        elActivityParty.PartyName = "MC2471";

        instActivity.OrganizerParty.Create(elActivityParty);

    }

// Activity: Attendee party - optional

elActivityParty.PartyName = "MCPC9785";

instActivity.AttendeeParty.Create(elActivityParty);

*/

// Activity: Set Employee Responsible (optional, because party determination applies rules for automatic determination)

if (! instActivity.EmployeeResponsibleParty.IsSet()) {

        elActivityParty.PartyName = this.EmployeeResponsibleID;

        instActivity.EmployeeResponsibleParty.Create(elActivityParty);

    }

if (! instActivity.MainActivityParty.IsSet()) {

        elActivityParty.PartyName = this.CustomerID;

        instActivity.MainActivityParty.Create(elActivityParty);

    }

if (! instActivity.MainContactParty.IsSet()) {

        elActivityParty.PartyName = this.ContactID;

        instActivity.MainContactParty.Create(elActivityParty);

    }

// Activity: set start and end time

instActivity.ScheduledStartDateTime.content = GlobalDateTime.ParseFromString("2014-01-14T13:30:00Z");

instActivity.ScheduledEndDateTime.content = this.EndDate.ConvertToGlobalDateTime();

//GlobalDateTime.ParseFromString("2014-01-14T15:00:00Z");

// Create a text of type "Body Text"

instActivityTxtColl = instActivity.TextCollection.Create();

elActivityTxtCollTxt.TypeCode.content = "10002";

instActivityTxtCollTxt = instActivityTxtColl.Text.Create(elActivityTxtCollTxt);

elActivityTxtCollTxtCntnt.Text.content = "Body text of the Activity Appointment";

instActivityTxtCollTxt.TextContent.Create(elActivityTxtCollTxtCntnt);

// Create an attachment of type "Link"

instActivityAttachm = instActivity.AttachmentFolder.Create();

elActivityAttachmDoc.Description.content = "PDI Comment for Attachment";

elActivityAttachmDoc.CategoryCode = "3";

elActivityAttachmDoc.Name = "SAP";

elActivityAttachmDoc.AlternativeName = "SAP Homepage";

elActivityAttachmDoc.ExternalLinkWebURI = "http://www.sap.com";

instActivityAttachm.Document.Create(elActivityAttachmDoc);

former_member221072
Participant
0 Kudos

Hi Rei Kasai,

thanks for the reply..

I have also created the email activity using the code which was provided in the repository explorer for Email Activity creation.i.e:

Here is the code which i have used in the before save of the Activity BO,( this code is from repository explore of 1402).

if ( this.TypeCode == "542")

{

if (this.ZTaskStatus == ZTaskStatusCode.CO_OPEN )

{

var elActivityRoot :  elementsof Activity;

var instActivity;

// Activity: define party node

var elActivityParty : elementsof Activity.Party;

var instParty;

// Activity: define text collection

var elActivityTxtCollTxt:      elementsof Activity.TextCollection.Text;

var elActivityTxtCollTxtCntnt: elementsof Activity.TextCollection.Text.TextContent;

var instActivityTxtColl;

var instActivityTxtCollTxt;

// Activity: define attachment folder

var elActivityAttachmDoc:      elementsof Activity.AttachmentFolder.Document;

var instActivityAttachm;

// Activity: maintain Business Object type - mandatory (12 = Appointment; 39 = Email; 86 = Phonecall; 542 = Task)

elActivityRoot.TypeCode = "39"; // create Email

elActivityRoot.GroupCode.content = this.GroupCode.content;

// Activity: maintain description - mandatory

emailSubject = "Test";//"Task OPENED - Number " + this.ID.RemoveLeadingZeros() + "(See in the CRM the task number)";  

elActivityRoot.SubjectName = emailSubject;

// Activity: create new instance

instActivity = Activity.Create(elActivityRoot);

// Activity: Organizer party - mandatory

if (! instActivity.MessageFromParty.IsSet()) {

        // supply party either with ID: MC2471 or Name: Kate Jacob or Email: Kate.Jacob@silverstar.us, etc.

  elActivityParty.PartyName = "8000000011";

  instActivity.MessageFromParty.Create(elActivityParty);

  }

// Activity: Attendee party - optional

elActivityParty.PartyName = "8000000011";

instActivity.MessageToParty.Create(elActivityParty);

// Activity: Set Employee Responsible  mandatory

if (! instActivity.EmployeeResponsibleParty.IsSet()) {

  elActivityParty.PartyName = "8000000011" ;

  instActivity.EmployeeResponsibleParty.Create(elActivityParty);

  }

// Create a text of type "Body Text"

instActivityTxtColl = instActivity.TextCollection.Create();

elActivityTxtCollTxt.TypeCode.content = "10002";

instActivityTxtCollTxt = instActivityTxtColl.Text.Create(elActivityTxtCollTxt);

elActivityTxtCollTxtCntnt.Text.content = "Body text of the Activity Email";

instActivityTxtCollTxt.TextContent.Create(elActivityTxtCollTxtCntnt);

}      // End of ZTask Status check

}     // end of type code check

with this code i am creating a email activity in the before save of the Activity BO.

I am creating a email activity with some conditions when the ActivityTask is saved.

I.e i have check with type code 542 in the Activity BO Before save script file.



With all these i am getting the below errors :

Please enter a process type.

Save failed. Technical error due to object ID not determined. Please report an incident.

Identity is invalid or could not be determined. Please check.

Date is invalid or could not be determined. Please check.

Save failed..

I checked it in the debugging but i could't get anything, its executing all my ABSL code and throwing this errors?

thanks,

Mani

Former Member
0 Kudos

Lemme ask you a question.

Which Business Object are you working on? Are you not able to create a Notification Rule for the same?

former_member221072
Participant
0 Kudos

Hi,

I am working on Activity BO(1402).

I have added an extension field for status i.e ZStatus, I am not using the standard status field.

When ever the status value is Completed i have to trigger notification to Customer Contact. But there is no provision in Notification rule to send email notification to Customer Contact  in Activity Task BO.

Can you suggest me if you know anyway to add other partner functions to recipient determination.?

because of this reason i am not using notification rule.!

With the ABSL logic its giving me above errors while saving the Task.!

Thanks,

Mani

Former Member
0 Kudos

Okay. I copy pasted the code from RepositoryExplorer and without a change in an alphabet, everything worked like a charm. I can see the EmailActivity I created in system.

May be a config issue that is stopping you from creating an EmailActivity ? Or are they originating from EmailTask ? Did you check this part?


Only diff. is you are assigning the GroupCode from Task to Email? elActivityRoot.GroupCode.content = this.GroupCode.content;

  • Can you try commenting this line?

  • If the above check doesn't give any success, then can you try commenting whole BeforeSave code and try saving a Task alone?

former_member221072
Participant
0 Kudos

Hi,

Even i have used the same code from repository.still i am getting these errors.

If i save activity Task alone its saving . the only issue is with email activity code.

I could't able to find anything in debugging, since its executing all the code, no dump is coming, after executing complete code its giving me these errors.

In 1311 it used to work..! Do we need to do any configuration in new 1402 for Email Activity.

Please suggest if we have any configuration setting required?

In which BO Script file you have created the EmailActivity??

I am feeling these errors are coming only because i am creating Email activity in Activity Extension since the same logic will trigger for two times for saving task as well as Email, but i have maintained all the conditions with type code..!

elActivityRoot.GroupCode.content = this.GroupCode.content;, this line i have added only for testing,since i am getting error as Please enter Process type..!  without this also same issue..!!

Thanks,

Mani

Former Member
0 Kudos

Oops. I am not yet into 1402. So, didn't think in that way. I used CustomBO for creating EmailActivity.

Yup. What you said might be true.

So, you can try something funky.

Have an Indicator as Extended field in Activity XBO.

Along with your conditions, check the value of this extended field (indicator) as well and create an EmailActivity in your XBO only when it is false.

As it goes into if condition and starts executing scripts for creating EmailActivity, then set the indicator value to true when you are creating EmailActivity it. This should stop this chain! Try this?

Former Member
0 Kudos

I have the same problem and this workaround is not working

It seems that if you are in an activity BO you cannot create an email activity and save both.

I don't know if there is a solution. I hope so.

Still looking for a workaround

PS: SAP said that there will be fix for this issue

Former Member
0 Kudos

Okay. I am able to replicate the problem. I gave it up. This is indeed a bug.

There are complex workarounds to overcome this as of now but it is better to wait for SAP to resolve.

Former Member
0 Kudos

I tried the following workaround without success:

1) Create the email instance in a different save process than the one where the activity modifications are saved

2) Create the email instance in a mass data run (you have to retrieve the main activity, create the email and then save both, so it's not working. Also the minimum schedule time is 1 hr)

The problem exists when you try to save the activity and the email (also an activity) in the same dialog step/database transaction)

Actually I am trying the last one. I will let you know