CREATE AUTO IM TASK

Dear Hp Community,

First of all ,Thank you for all your answers.I created auto task function.First,I create a new task.And then,I assigned this task to one assignment group.After that,when I changed the status of this imTask record,one more task occured.Everything is normal until now.But,I dont want an exception situation for this auto task .If I have two tasks,this function mustnt work.I mean that this function must be valid for one task .How can I provide this situation?What do I should add to this code ?

Best Regards,

 

function AutoCreateTaskPendingOnSite($rec , $oldRec, $action)

{

try{

if($rec != null){

var imTask = new SCFile( 'imTask' );

imTask.id = $rec.last_task_no;

imTask.category = "Investigation";

imTask.affected_item = $rec.affected_item;

imTask.brief_description = $rec.brief_description;

imTask.parent_incident = $rec.parent_incident;

imTask.priority_code = $rec.priority_code

imTask.initial_impact = $rec.initial_impact

imTask.severity = $rec.severity

imTask.incident_category=$rec.incident_category

imTask.subcategory=$rec.subcategory

imTask.product_type=$rec.product_type

imTask.problem_type=$rec.problem_type

imTask.due_date=$rec.due_date

imTask.folder=$rec.folder

imTask.itsProject=$rec.itsProject

imTask.itsSubProject=$rec.itsSubProject

imTask.itsUserId=$rec.itsUserId

imTask.location=$rec.location

imTask.itsBrand=$rec.itsBrand

imTask.itsModel=$rec.itsModel

imTask.itsContractBeginDate=$rec.itsContractBeginDate

imTask.itsContractEndDate=$rec.itsContractEndDate

imTask.itsCallerName=$rec.itsCallerName

imTask.itsCallerEmail=$rec.itsCallerEmail

imTask.itsCallerTel1=$rec.itsCallerTel1

imTask.itsCallerExtention=$rec.itsCallerExtention

imTask.itsCallerPortablePhone=$rec.itsCallerPortablePhone

imTask.itsProjectStatus=$rec.itsProjectStatus

imTask.itsProjectStartDate=$rec.itsProjectStartDate

imTask.itsProjectEndDate=$rec.itsProjectEndDate

imTask.itsCustomerLocation=$rec.itsCustomerLocation

imTask.itsCircuitInfo=$rec.itsCircuitInfo

imTask.itsTemosNo=$rec.itsTemosNo

imTask.itsCircuitType=$rec.itsCircuitType

imTask.itsRequestorName=$rec.itsRequestorName

imTask.itsRequestorPhone=$rec.itsRequestorPhone

imTask.itsRequestorEmail=$rec.itsRequestorEmail

imTask.itsCity=$rec.itsCity

imTask.itsDistrict=$rec.itsDistrict

imTask.itsAddress=$rec.itsAddress

imTask.itsSMType=$rec.itsSMType

imTask.contact_name=$rec.contact_name

imTask.logical_name=$rec.logical_name

imTask.itsTuruncuHatNo=$rec.itsTuruncuHatNo

imTask.its_OzelMusteriKodu=$rec.its_OzelMusteriKodu

imTask.its_CANo=$rec.its_CANo

imTask.description=$rec.description;

 

 

 

 

 

imTask.assignment="Service Desk";

 

//imTask.assignment="Service Desk";

 

 

//imTask.assignment="Service Desk";

 

 

 

var its = imTask.doAction("add");

 

 

 

 

 

 

//var its = imTask.doAction("add");

 

if(its == RC_SUCCESS){

print(imTask.id ' imTask Açıldı ve İlgili Ekibe Aktarıldı.')

}

 

 

 

}

 

}catch(error){

print('ITS_imTask.AutoCreateTaskPendingOnSite' error.toString());

}

}

 

 

 

 

 

 

  • Hi, I saw your question because I had the same problem, but I did this "WorkAround" in order to assign a Correct ID number to imTask Record. 

     

    Firstly there are an OOB rule set with this code. 

    Set Last Task No via JavaScript

    var $ = lib.c.$;
    var file =vars.$L_file;
    value=$("#incidentService").getLastTaskNo(file['number']);

    After that assign of Last Task No I did my code.

    var imTask = new SCFile( 'imTask' );
    if (record.last_task_no < 10){imTask.id = record.number '-00' record.last_task_no}
    if (record.last_task_no >= 10 && record.last_task_no<100){imTask.id = record.number '-0' record.last_task_no}
    if (record.last_task_no >= 100){imTask.id = record.number '-' record.last_task_no}
    imTask.affected_item = record.affected_item;
    imTask.brief_description = record.brief_description;
    imTask.parent_incident = record.number;
    imTask.priority_code = record.priority_code;
    imTask.initial_impact = record.initial_impact;
    imTask.severity = record.severity;
    imTask.incident_category=record.category;
    imTask.subcategory=record.subcategory;
    imTask.product_type=record.product_type;
    imTask.problem_type=record.problem_type;
    imTask.due_date=record.expected_resolution_time,
    imTask.folder=record.folder;
    imTask.location=record.location;
    imTask.logical_name=record.logical_name;
    imTask.ticket_owner=record.ticket_owner;
    imTask.description=record.affected;
    imTask.tg_pais=record.tg_pais;
    imTask.tg_tipo_sitio=record.tg_tipo_sitio;
    imTask.tg_zona=record.tg_zona;
    imTask.tg_validar_noc=record.tg_validar_noc;
    imTask.coord_dept="GESTOR CONFIGURACIONES CNOC";
    imTask.category="TAREA GESTION ACTIVOS CNOC";

    var Tarea = imTask.doAction("add");


    if(Tarea == RC_SUCCESS){

    print(imTask.id ' Se creo de Forma automática una tarea de incidentes para su revisión.')

    }

     

    Now I have an Auto ImTask with a correct counters in its ID field.

    Regards.