Error inserting data in the activity table from a script

Good morning I would appreciate the collaboration in this item.

I have configured the following rule that is executed when a service is updated

rule
system.library.Virtualizacion.Incidentesvirtualizacion(record);

la regla anterior realiza el llamado del siguiente script

script
function Incidentesvirtualizacion(number)
{
var IM = new SCFile ("probsummary")
var FIM= IM.doSelect("number=\"" IM.number "\"")
print(IM.number)
$Incidentegrupoa = IM.Incidente_grupo;
$Motivoincidente = IM.Motivo_incidente;
$Descripcionmotivo = IM.Descripcion_motivo;
print($Incidentegrupoa)
print($Motivoincidente)
print($Descripcionmotivo)
if (FIM==RC_SUCCESS)
{
var AIM= new SCFile ("activity")
var typeacm="Analysis and diagnosis";
AIM.number= IM.number;
AIM.datestamp= system.functions.tod();
AIM.operator= system.functions.operator();
AIM.type= typeacm;
AIM.description [0]= "Es incidente del grupo: " $Incidentegrupoa " Motivo del incidente:" $Motivoincidente " Descripción: " $Descripcionmotivo;
print(AIM.description)
AIM.doInsert();
}
print("fin")
}

the novelty appears when updating the service from sm, sm informs me that there is a syntaxerror error: syntax error.

  • Your code seems all wrong. 

    Access your script Virtualizacion and click on compile. It'll show all syntax errors to you (one by one :D ).

    ....

    ;  missing at ending of each command.

    SCFile (  - there is no space here..

    AIM.description [0] - no space here.

     ...

    Declare local variables with var. Do not use such thing as $Incidentegrupoa for local javascript variables.

     

     

    Good luck!

  • Your code seems all wrong. 

    Access your script Virtualizacion and click on compile. It'll show all syntax errors to you (one by one :D ).

    ....

    ;  missing at ending of each command.

    SCFile (  - there is no space here..

    AIM.description [0] - no space here.

     ...

    Declare local variables with var. Do not use such thing as $Incidentegrupoa for local javascript variables.

    Good luck!

  • add the; in the lines and validate from sl in service manager and inform me that there is no error about the script.

    When I test with a fixed number the script works without problems, the error occurs when I want the function defined in the script to be executed when updating an IM.

    function Incidentesvirtualizacion(number)
    {
    var IM = new SCFile("probsummary");
    var FIM= IM.doSelect("number=\"" IM.number "\"");
    //var FIM= IM.doSelect("number=\"IM32972\"");
    print(IM.number);
    var DatIncidentegrupo = IM.Incidente_grupo;
    var DatMotivoincidente = IM.Motivo_incidente;
    var DatDescripcionmotivo = IM.Descripcion_motivo;
    print(DatIncidentegrupo);
    print(DatMotivoincidente);
    print(DatDescripcionmotivo);
    if (FIM==RC_SUCCESS)
    {
    var AIM= new SCFile("activity");
    var typeacm="Analysis and diagnosis";
    AIM.number= IM.number;
    AIM.datestamp= system.functions.tod();
    AIM.operator= system.functions.operator();
    AIM.type= typeacm;
    AIM.description[0]="Es incidente del grupo: " DatIncidentegrupo " Motivo del incidente:" DatMotivoincidente " Descripción: " DatDescripcionmotivo;
    print(AIM.description);
    AIM.doInsert();
    }
    print("fin");
    }

  • Verified Answer

    Your function receives the record.number and you are passing the record - this is the error.

    Change the calling parameter to record.number and test. 

    Another point is: why are you not using normal activityactions to add this activity? Your script has nothing special, try to use the default functions as much as possible, it'll make yourl life much easier.

  • Verified Answer

    Your function receives the record.number and you are passing the record - this is the error.

    Change the calling parameter to record.number and test. 

    Another point is: why are you not using normal activityactions to add this activity? Your script has nothing special, try to use the default functions as much as possible, it'll make yourl life much easier.