Re: Copy attachment from Interaction to Incident (1087 Views)
Reply
Valued Contributor
alscpe
Posts: 82
Registered: ‎09-02-2008
Message 1 of 8 (1,413 Views)

Copy attachment from Interaction to Incident

We need a function there can copy all attachment from Interaction to the related Incident. We has created a trigger on the SYSATTACHMENT “After add” and added the JavaScript below. The script is copying the attachment to the Incident, but the files are corrupt.

Does anyone here on the forum have a good idea or solution how to copy attachment from Interaction to Incident.

if (record.application == "incidents") {
var fScrelate=new SCFile("screlation");
var query = "source=\""+ record.topic +"\"";
var rc = fScrelate.doSelect(query);
while (rc == RC_SUCCESS) {
var fSysattachment = new SCFile("SYSATTACHMENTS");
fSysattachment.application = "probsummary";
fSysattachment.topic = fScrelate.depend;
fSysattachment.filename = record.filename;
fSysattachment.type = record.type;
fSysattachment.mimetype = record.mimetype;
fSysattachment.segment = record.segment;
fSysattachment.size = record.size;
fSysattachment.uid = record.uid;
fSysattachment.doAction("add");
rc = fScrelate.getNext();
}
}
Respected Contributor
Kelalek
Posts: 255
Registered: ‎07-30-2009
Message 2 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

Hey,

I've used a following code:

table: screlconfig, filename: problem

Add to the "Post open expressions" line:
if (filename($L.related)=""probsummary"" and filename($L.primary)=""incidents"") then ($L.void=rtecall(""blobcopy"", $L.rc, ""incidents"", incident.id in $L.primary, ""probsummary"", number in $L.related))"

It should work...
Respected Contributor
Kelalek
Posts: 255
Registered: ‎07-30-2009
Message 3 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

And to add some guidance:

Open Database Manager in Service Manager, write screlconfig (enter) and find a relation config record for a table called problem.

Rest of the job is just copy-pasting and saving changes.
Valued Contributor
alscpe
Posts: 82
Registered: ‎09-02-2008
Message 4 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

Thanks for the reply

There are two step in my problem.

The first step are when a Interaction with attachment are escalatet to a Incident. Here i'm allready are using the "script" you has provide, and it is working very well, if one Interaction are related to a new Incident. If one Interaction are related to a exsisten Incident, it is not working, but that is okay for now.

The second step are when a Interaction there allready are related to a Incident, must be added with a new Attachment, through the ESS interface or through a e-mail update from the customer.

WHen that's happen, i will also copy the new attachment to the related Incident, and that part it is not working with the JavaScript. The attachment in incident are created, but are corrupt
Honored Contributor
Jan-Peter Hanshen
Posts: 302
Registered: ‎07-27-2006
Message 5 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

Hi,

we are using the "doInsert" method to copy attachments from interactions to incidents.

One more fact to keep in mind: I think you need to remember whether an attachment has been copied already to incident or not. (Example: If an ess ticket already has one attachment and the user adds a second attachment, you only want to transfer the new att, right ?

That's why why have a field tk.tranfer.time in dbdict SYSATTACHMENT, where we post the timestamp of the transferral and look only for attachments with transfertime=NULL.

JS goes like this:
function passAttachment( incident )
{
var attachment = new SCFile("SYSATTACHMENTS");
var attachment2 = new SCFile("SYSATTACHMENTS");
var query = "application=\"incidents\" and topic=\"" + incident.incident_id + "\" and tk.transfer.time=NULL";

var rc = attachment.doSelect( query );
if ( rc == RC_SUCCESS ) {
while ( rc == RC_SUCCESS ) {
rc1 = system.functions.fduplicate(attachment2,attachment);
attachment2.application = "probsummary";
attachment2.topic = incident.tk_incident_id;
rc2 = attachment2.doInsert();
attachment.tk_transfer_time = system.functions.tod();
rc3 = attachment.doUpdate();
rc = attachment.getNext();
}
}
}

Hope it helps,
Jan
Advisor
D8482
Posts: 37
Registered: ‎08-09-2010
Message 6 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

Hi ALL,

Is the issue resolved ?

Regards,
D8482
Valued Contributor
Kristen Branson
Posts: 95
Registered: ‎06-08-2009
Message 7 of 8 (1,413 Views)

Re: Copy attachment from Interaction to Incident

I used this:
copy this code to the probsummary format control javascript tab (on add):

var fromid=vars.$file.incident_id;
var toid=vars.$file.number;
var returncode = system.library.AMP_mvattachment.move_attachment(fromid, toid);

Then add a new scriptlibrary called AMP_mvattachment with the following code:

function move_attachment(fromid, toid)
{
if (fromid!=null && toid!=null) {
var fSattach = new SCFile("SYSATTACHMENTS");
var rc = fSattach.doSelect("topic=\""+fromid+"\"");
var rc1 = rc;

if ( rc == RC_SUCCESS ){
while ( rc == RC_SUCCESS ) {
fSattach.application = "probsummary";
fSattach.topic = toid;
/* This is to move the attachment*/
/* rc1=fSattach.doUpdate();*/
/*This is to copy the attachment*/
rc1=fSattach.doInsert();
rc =fSattach.getNext();
}
}
}
}
Advisor
Ferd9324
Posts: 39
Registered: ‎02-28-2012
Message 8 of 8 (1,087 Views)

Re: Copy attachment from Interaction to Incident

Hey

if I wanted wanted to record interaction tickets numbers to a field in probsumary (IM.update) and vice versa, could the fix you listed here work for that?  thx

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.