2 Replies Latest reply: Jun 11, 2013 11:21 PM by VinayEndla RSS

    Unable to create a FieldActivity from Batch Program

    Gurumoorthy
      Hi All,

      I am trying to create a Field Activity(FA) from a Batch Program. And I am able to create FA but once the FA is created the background process trying to create the FA Step and breaking the code. So the FA has been rolled back.
      the error message which I m getting is
      Text: Invalid step sequence (001) for this field activity type.
      Description: The step sequence for the field activity type may have changed. The step sequence is no longer valid.
      We recommend changing the field activity type for the field activity and the system will refresh the activity steps with the
      correct step sequence.

      pls any one could be give me any solution or suggestion or idea etc......
      And I've mentioned the code which i m using for to create FA and Exception which i am getting.

      Code for Creating FA
      FieldActivityType faType = new FieldActivityType_Id(typeOfFaToCreate).getEntity();
      ServicePoint servicePoint = new ServicePoint_Id("4603411688").getEntity();
      FieldActivity_DTO fieldActivityDTO = this.createDTO(FieldActivity.class);
      if(faType.getIsEligibleForDispatch() == Bool.TRUE){
           FieldServiceClass fieldServiceClass = faType.getFieldServiceClass();                    
           ServicePointOperationArea spOp = new ServicePointOperationArea_Id(fieldActivity.getServicePoint(), fieldServiceClass).getEntity();
           FieldServiceOperationalArea_Id fsOp = new FieldServiceOperationalArea_Id(spOp.getOperationsArea(), fieldServiceClass);
           FieldServiceControl fsc = new FieldServiceControl_Id(servicePoint.getSpType(), fsOp.getOperationsArea(), faType).getEntity();
           fieldActivityDTO.setDispatchGroupId(fsc.getDispatchGroup().getId());
           fieldActivityDTO.setIsEligibleForDispatch(Bool.TRUE);
      }
      fieldActivityDTO.setCreatedBy(FieldActivityCreatedByLookup.constants.BACKGROUND);
      fieldActivityDTO.setCreationDateTime(this.getProcessDateTime());
      fieldActivityDTO.setFieldActivityPriority(FieldActivityPriorityLookup.constants.PRIORITY_5_0);
      fieldActivityDTO.setFieldActivityStatus(FieldActivityStatusLookup.constants.PENDING);
      fieldActivityDTO.setFieldActivityTypeId(faType.getId());
      fieldActivityDTO.setServicePointId(servicePoint.getId());
      fieldActivityDTO.setScheduleDateTimeStart(this.getProcessDateTime());
      fieldActivityDTO.setUserId(this.getActiveContextUser().getId());
      this.startChanges();
      FieldActivity fa = fieldActivityDTO.newEntity();
      this.saveChanges();

      Error Message
      com.splwg.base.api.batch.ThreadAbortedException: com.splwg.shared.common.ApplicationError: (Server Message)
      Category: 9
      Number: 11401
      Call Sequence: ;CIPOFASL;CIPOFACP
      Program Name: CIPOFACP
      Text: Invalid step sequence (001) for this field activity type.
      Description: The step sequence for the field activity type may have changed. The step sequence is no longer valid.
      We recommend changing the field activity type for the field activity and the system will refresh the activity steps with the
      correct step sequence.
      Table:
      Field:
      at com.splwg.base.api.batch.SingleTransactionStrategy.concreteExecuteWork(SingleTransactionStrategy.java:64)
      at com.splwg.base.api.batch.AbstractExecutionStrategy.executeWork(AbstractExecutionStrategy.java:184)
      at com.splwg.base.support.batch.JavaBatchWork.executeThreadWork(JavaBatchWork.java:108)
      at com.splwg.base.support.batch.JavaBatchWork.access$300(JavaBatchWork.java:29)
      at com.splwg.base.support.batch.JavaBatchWork$DoExecuteWorkInSession.doBatchWorkInSession(JavaBatchWork.java:91)
      at com.splwg.base.support.batch.BatchWorkInSessionExecutable.run(BatchWorkInSessionExecutable.java:45)
      at com.splwg.base.support.batch.JavaBatchWork.doExecuteWork(JavaBatchWork.java:50)
      at com.splwg.base.support.grid.AbstractGridWork.executeWork(AbstractGridWork.java:69)
      at com.splwg.base.support.grid.node.SingleThreadedGrid.addToWorkables(SingleThreadedGrid.java:48)
      at com.splwg.base.support.grid.node.AbstractSingleThreadedGrid.processNewWork(AbstractSingleThreadedGrid.java:49)
      at com.splwg.base.api.batch.StandaloneExecuter$ProcessNewWorkExecutable.execute(StandaloneExecuter.java:504)
      at com.splwg.base.support.context.SessionExecutable.doInNewSession(SessionExecutable.java:37)
      at com.splwg.base.api.batch.StandaloneExecuter.submitProcess(StandaloneExecuter.java:166)
      at com.splwg.base.api.batch.StandaloneExecuter.runOnGrid(StandaloneExecuter.java:131)
      at com.splwg.base.api.batch.StandaloneExecuter.run(StandaloneExecuter.java:118)
      at com.splwg.base.api.batch.StandaloneExecuter.main(StandaloneExecuter.java:281)
      Caused by: com.splwg.shared.common.ApplicationError: (Server Message)

      Thank you,
      Guru.