cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create a Document flow ( ActivityTask ) for a Service Ticket On Save using ABSL script.

Former Member
2,695

Hi Experts,

My scenario is on save of a service ticket I need to create ActivityTask as follow up document with some default values and it should be visible in Document flow tab of the service ticket.

I used below code in the Event-BeforeSave.absl of the ServiceRequest.XBO

import ABSL;

import AP.FO.Activity.Global;

import AP.Common.Global;

import AP.PC.ActivityManagement.Global;

var ServiceTicketKey : BusinessTransactionDocumentKey;

//ActivityTask: Root node

var elTaskRoot : elementsof ActivityTask;

var instTask;

// ActivityTask: define party node

var elTaskParty : elementsof ActivityTask.Party;

var instParty;

// ActivityTask: define service order text collection

var TXT_TYPE_BODY_TEXT = "10002";

var elTaskTxtCollTxt: elementsof ActivityTask.TextCollection.Text;

var elTaskTxtCollTxtCntnt: elementsof ActivityTask.TextCollection.Text.TextContent;

var instTaskTxtColl;

var instTaskTxtCollTxt;

var elPeriod: elementsof ActivityTask.Period;

// ActivityTask: maintain description - mandatory

elTaskRoot.Name.content = "Service Ticket " + this.ID.content.RemoveLeadingZeros();

// ActivityTask: create new instance

instTask = ActivityTask.Create(elTaskRoot);

// Task: Call Particpant

if (! instTask.ProcessorParty.IsSet()) {

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;

instTask.ProcessorParty.Create(elTaskParty);

}

else

{

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;

instTask.ProcessorParty.Create(elTaskParty);

}

// Task: Set Employee Responsible mandatory

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

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; // Set Employee ID

instTask.EmployeeResponsibleParty.Create(elTaskParty);

}

else

{

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; // Set Employee ID

instTask.EmployeeResponsibleParty.Create(elTaskParty);

}

// Create a text of type "Body Text"

instTaskTxtColl = instTask.TextCollection.Create();

elTaskTxtCollTxt.TypeCode.content = TXT_TYPE_BODY_TEXT;

instTaskTxtCollTxt = instTaskTxtColl.Text.Create(elTaskTxtCollTxt);

elTaskTxtCollTxtCntnt.Text.content = "Body text of the Task activity";

instTaskTxtCollTxt.TextContent.Create(elTaskTxtCollTxtCntnt);

// trying to add service ticket as Reference to the ActivityTask

ServiceTicketKey.BusinessTransactionDocumentID = this.ID; //Service Ticket ID

ServiceTicketKey.BusinessTransactionDocumentTypeCode = this.ProcessingTypeCode; // “Type Code = “SRRE”

instTask.AddReferenceWithDataProvision(ServiceTicketKey);

but no effect. I can see a new task created but it is not attached to the Service ticket as Follow-up or reference document.

Any clues.

I even tried

ActivityTask.CreateWithReference( )

But unable to set default values on the Task.

Regards,

Chella.

Accepted Solutions (1)

Accepted Solutions (1)

former_member226
Employee
Employee

Hi,

You are not passing any thing to 'BusinessTransactionDocumentReference' node to create a document flow entry. This is mandatory to link the document with Predecessor or Successor status. Please refer the attached code through which I am able to attach the activity with Service Request via ABSL.

import ABSL;
import AP.CRM.Global;
var t1 : elementsof ServiceRequest.BusinessTransactionDocumentReference;
t1.BusinessTransactionDocumentReference.ID.content = "46433"; // Activity task ID to be attached 
t1.BusinessTransactionDocumentReference.TypeCode = "542";   // Type code for Activity Task ( Refer Data Type BusinessTransactionDocumentReference for Allowed values )
t1.BusinessTransactionDocumentRelationshipRoleCode = "1"; // Mention if it is Predecessor or Successor ( Refer Data Type BusinessTransactionDocumentRelationshipRoleCode for Allowed values)
this.BusinessTransactionDocumentReference.Create(t1);

Please let know in case you have any issues.

Thanks

Saurabh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I am trying similiar scenario.But to create order from quote. Below code is added

I added below code in CustomerQuote BeforeSave

SalesOrder.CreateWithReference(this);

Sales order got created ,but it doesn't create as reference. New order doesn't have any information related to quote , ie no account ,items/or other info. Also document flow is empty.

Please help

Thanks,

Resmi

Former Member
0 Kudos

Hi Saurabh,

Thanks for your reply.

It worked using ActivityTask.CreateWithReference(this);

this points to the ServiceRequest BO

import ABSL;
import AP.FO.Activity.Global;
import AP.Common.Global;
import AP.PC.ActivityManagement.Global;

//ActivityTask: Root node
var elTaskRoot : elementsof ActivityTask;

var  instTask = ActivityTask.CreateWithReference(this);

// ActivityTask: define party node
var elTaskParty : elementsof ActivityTask.Party;
var instParty;

instTask.Name.content = "Subject Ticket " + this.ID.content.RemoveLeadingZeros();

if (! instTask.ProcessorParty.IsSet()) {
		elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;
		instTask.ProcessorParty.Create(elTaskParty);
	}
	else
	{
		instTask.ProcessorParty.Delete();
		elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; 
		instTask.ProcessorParty.Create(elTaskParty);
	}
	


Thanks,

Chella.

Former Member
0 Kudos

Hi B.Chella,

I have a similar problem, I want to create a sub ticket for a ticket as following document, I try the similar code like you provide.But it dump, I don't know why,please help me,thank you.The following link is the question.

https://answers.sap.com/questions/298641/how-to-create-follow-up-documentalso-service-reque.html

Jack.Hua

Best Regard

0 Kudos

Hi bchella.pandian,

Please Would you say me how modify the "EmployeeResponsibleParty" because I tried firt delete it and create a new it bud this not work. The Task get the customer of ticket but I need assign a different customer.

Thanks.