Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 15, 2017 at 07:02 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 15, 2017 at 07:26 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 28 at 12:37 PM

    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

    Add comment
    10|10000 characters needed characters exceeded