Highlighted
Member..
Member..
378 views

Error inserting data in the activity table from a script

Jump to solution

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.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Knowledge Partner
Knowledge Partner

Re: Error inserting data in the activity table from a script

Jump to solution

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.

Regards,
Breno Abreu

If you feel this was helpful please click the KUDOS! thumb below!

View solution in original post

0 Likes
4 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: Error inserting data in the activity table from a script

Jump to solution

Your code seems all wrong. 

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

....

;  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!

Regards,
Breno Abreu

If you feel this was helpful please click the KUDOS! thumb below!
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: Error inserting data in the activity table from a script

Jump to solution

Your code seems all wrong. 

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

....

;  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!

Regards,
Breno Abreu

If you feel this was helpful please click the KUDOS! thumb below!
0 Likes
Highlighted
Member..
Member..

Re: Error inserting data in the activity table from a script

Jump to solution

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");
}

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: Error inserting data in the activity table from a script

Jump to solution

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.

Regards,
Breno Abreu

If you feel this was helpful please click the KUDOS! thumb below!

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.