techie2 Contributor.
Contributor.
560 views

Service Manager attachment export

Hello Experts,

I am looking different ways to export the attachements of all the Service manager modules. Is there an easy way to do that? We are using SM 9.35. 

Thanks in advance

Tags (1)
0 Likes
10 Replies
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Service Manager attachment export

Probably the easiest way is to create a Javascript to export them to a local drive on your server. This is what we do as part of our archiving process.

0 Likes
techie2 Contributor.
Contributor.

Re: Service Manager attachment export

How do i create a javascript? Is there a code available? I am new to service manager area just trying to help. 

0 Likes
Highlighted
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Service Manager attachment export

$L.void=jscall("writeToFile.writeAttachToFile", $tablename, $topic)

You can call this from a Scheduled Task or where ever you want.  You need to to pass it the tablename and topic.  

Here is the below script:

function writeAttachToFile(application, topics){

var topic = topics.toArray();
//var path = 'e:\\A SM Alteration Attachments\\';
var path = '/download/attachments/';
var env = 'prod';

var SysAtt = new SCFile("SYSATTACHMENTS");
var x = 0;
print(topics);


do{

var attQry = 'application ="' + application + '" and segment = 0 and topic = "' + topic[x] + '"'
print(attQry);
var rca = SysAtt.doSelect(attQry)
print('Attachment Selection: ' + RCtoString(rca));

if (rca == RC_SUCCESS){
print('Some attachments were located');

do{
var rc;
rc = writeAttachmentToFile( path + env + '_' + SysAtt.topic + '_' + SysAtt.filename, application, SysAtt.topic, SysAtt.uid );
if ( rc == RC_SUCCESS )
{
print( "attachment successfully created for: " + SysAtt.topic );
}
else
{
print( "attachment failed for: " + SysAtt.topic , RCtoString(rc) );
}

}while (SysAtt.getNext() == RC_SUCCESS)

}
else{
print('No attachments located');
}

x += 1;

}while (x < topic.length)

}

/* To test the function - uncomment the following line and supply a value for $G_topics through the rad editor */
//var y = writeAttachToFile("probsummary",system.vars.$G_topics);

 

0 Likes
techie2 Contributor.
Contributor.

Re: Service Manager attachment export

Thanks for the code TomPowe. I am new to SM area and i am just trying to help them out on this and have very limited knowledge to use this code. Is there any other way out out? We were thinking of exporting the attachments to the other database without compressing it, so that the it can be retreived anytime as needed. Is this something we can do? or do we have an option to uncompress the existing database and pull it as neeeded? we are using oracle database. 

0 Likes
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Service Manager attachment export

There might be, but I'm unaware of any other way.

0 Likes
techie2 Contributor.
Contributor.

Re: Service Manager attachment export

Ok. Thanks for your prompt response.

Can you help me guide through to implement the code you have provided above in SM? I am going to try this in dev, what would be the first step i need to take and any changes I will have to make to the code? Again, thanks a lot for your help very much appreciated! 

0 Likes
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Service Manager attachment export

1. Go to Script Library, copy and paste the script above into it. Call the Script Library, writeToFile and then click Add.

 

2. In the script library, find the line that starts with "var path". Set that to a local path on your server where you want the attachments to download to.

 

3. Now, you'll need to call it from some place.  Here is an example of some code that would pull down an attachment for a single ticket:

 

$table="incidents"

$ticket="SD1234"

$L.void=rtecall("rinit", $L.sysattachments.code, $L.sysattachments.rec, "SYSATTACHMENTS")

$L.void=rtecall("select", $L.sysattachments.code, $L.sysattachments.rec, "application=$table and topic=$ticket")

if ($L.sysattachments.code=1 or $L.sysattachments.code=2) then ($topic={$ticket})

if ($L.sysattachments.code=1 or $L.sysattachments.code=2) then ($L.void=jscall("writeToFile.writeAttachToFile", $table, $topic))

 

0 Likes
techie2 Contributor.
Contributor.

Re: Service Manager attachment export

Thanks again, Do i have to manually plug in all the SD's? Isn't there an easy way to just export everything?

0 Likes
techie2 Contributor.
Contributor.

Re: Service Manager attachment export

Do i have to key in the SD's? Can't i export all at once?

$ticket="SD1234"

0 Likes
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Service Manager attachment export

No, of course, you could write some code to search up all the tickets and then loop through them all and pass the ticket numbers into the script.

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.