Highlighted
Absent Member.. Kunjappy Absent Member..
Absent Member..
1665 views

scrpt to delete records in device table

Jump to solution

HI,

 

Can someone please help me to write a script to delete data from device table?

 

i want to schedul this script on a daily basis

 

requirement:

 

search for type="a" and subtype="b"

 

then delete records one by one and exit

 

then schedule it on a daily basis

 

Please help

 

Regards,

Kunjappy

0 Likes
1 Solution

Accepted Solutions
Piku Absent Member.
Absent Member.

Re: scrpt to delete records in device table

Jump to solution
In backgroun using script it will work and tested it to.

instead of using
fdevice.doAction("delete")
try
fdevice.doDelete();

Regards
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
8 Replies
Piku Absent Member.
Absent Member.

Re: scrpt to delete records in device table

Jump to solution
Just want to mention, forum is to help and share knowledge , not to provide exact solution. So would suggest to try first yourself and this will help you too.

Regarding you issue, not sure why you need to delete the device on schedule basis, it could not be part of any valid process.
Device record should be overwritten or retied, not to deleted in system.

Below script can be used to delete the device,
var fdevice = new SCFile("device");
var fsel = fApproval.doSelect("type=\"a\" and subtype=\"b\"");
while (fsel == RC_SUCCESS)
{
fdevice.doAction("delete")
print(fdevice.id + “ deleted”)
fsel = fdevice.getNext();
}

Here ensure that delete button is accessible to background process , check condition of delete display option for same.

You can put this in the scheduler JS tab. To create the scheduler search forum, it is easy.
name : <desired>
id : <auto generated>
class : problem
schd class : problem
expiration : <next execution time you want>
action time : blank or any past time
Repeat interval : select other and put value 1 00:00:00
status : rescheduled
in js tab : put you new above js.

Also you might require adding the expression as below for ‘delete’ display option button of DS attached device state,
<Existing condition> or operator()=”problem”

Regards,
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
Absent Member.. John Stagaman Absent Member..
Absent Member..

Re: scrpt to delete records in device table

Jump to solution

You can do this easily by defining an unload script and configuring it to purge records. Then schedule it to run in the background on a daily interval. 

 

Not sure why you want to delete CIs daily though. 

----------------------------------------------------
Kudos - what, where, how, and why
Want Good Answers? Ask Good Questions...
Absent Member.. Kunjappy Absent Member..
Absent Member..

Re: scrpt to delete records in device table

Jump to solution

THanks for the reply.

 

I have the purge scripts ready. but not sure how to schedule it.

 

what i need to put in the Class, scheduled class, application (used for purginng) and query?

 

query i already used in the purge script, so what is that query in the schedule object?

 

Another method i thought of doing it using the java script. That is just an alternative way and thought i can learn both the methods.

 

Can you also help me with the scheduler as well.

 

so that i can try both the methods

 

kunj

0 Likes
Absent Member.. Kunjappy Absent Member..
Absent Member..

Re: scrpt to delete records in device table

Jump to solution

error while executing the script

 

Unrecoverable error in application:  se.call.process on panel call.rad.1
Unrecoverable error in application:  se.base.method on panel delete.record
Call MessageBox(YesNo)  from JS/trigger in same RAD thread is unsupported, please call in new thread, the corresponding lib is, Ford_Delete_NASVFA (apm.mb.yes.n
o,mb.yes.no)
Unrecoverable error in application:  se.call.process on panel call.rad.1
Unrecoverable error in application:  se.base.method on panel delete.record
Call MessageBox(YesNo)  from JS/trigger in same RAD thread is unsupported, please call in new thread, the corresponding lib is, Ford_Delete_NASVFA (apm.mb.yes.n
o,mb.yes.no)
Unrecoverable error in application:  se.call.process on panel call.rad.1
Unrecoverable error in application:  se.base.method on panel delete.record
Call MessageBox(YesNo)  from JS/trigger in same RAD thread is unsupported, please call in new thread, the corresponding lib is, Ford_Delete_NASVFA (apm.mb.yes.n
o,mb.yes.no)
Unrecoverable error in application:  se.call.process on panel call.rad.1
Unrecoverable error in application:  se.base.method on panel delete.record
Call MessageBox(YesNo)  from JS/trigger in same RAD thread is unsupported, please call in new thread, the corresponding lib is, Ford_Delete_NASVFA (apm.mb.yes.n
o,mb.yes.no)
nas9040180deleted
fmcnas1deleted
eccnas1deleted
aphnas1deleted

 

I think when we delete a record it asks for yes/no? how to put that condition in script as yes?

 

Also is it possible to use purge as action?

 

Regards,

Sreekannth

0 Likes
Piku Absent Member.
Absent Member.

Re: scrpt to delete records in device table

Jump to solution
In background for script SM do not ask so and tested too.
Do you have configuration in this display option? Also first try to manually execute the script.

Again will say not to delete as all Tickets having deleted CI will be orphan and you will not able to process/close them.

Regards,
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
0 Likes
Absent Member.. Kunjappy Absent Member..
Absent Member..

Re: scrpt to delete records in device table

Jump to solution

I used the purge archive to schedule the task.

 

But sill want to know why the script didnt work?

 

When we delete a record it asks for confirmation.similarly i believe we need to give a confirmation in the script to get the record deleted.

 

currently I'm getting the error message

 

Call MessageBox(YesNo)  from JS/trigger in same RAD thread is unsupported, please call in new thread, the corresponding lib is, Ford_Delete_NASVFA (apm.mb.yes.no,mb.yes.no)

 

 

how to provide "yes" using this script itself

 

0 Likes
Piku Absent Member.
Absent Member.

Re: scrpt to delete records in device table

Jump to solution
In backgroun using script it will work and tested it to.

instead of using
fdevice.doAction("delete")
try
fdevice.doDelete();

Regards
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
Absent Member.. Kunjappy Absent Member..
Absent Member..

Re: scrpt to delete records in device table

Jump to solution
Thanks Piku and John for your timely support
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.