Count of attachments for device table

Hello.

I made next functional.

Concept: When operator add/remove attachment to device table (into CI) then put amount of attachments into field in device table (attach.count)

Implementation:

1) triggers for SYSATTACHMENTS table: "before add" and  "before delete"

if (record.application == "device" && record.segment==0)
{
lib.HPCinteroperabilityHelpers.scheduleActionWithName(record.topic " - MOS.DEVICE.CALC.ATTACH", record, "MOS.DEVICE.CALC.ATTACH")
}

 2) Shcedule wich create shcedule record wich start ioaction

3) ioaction:

var TargetTable="device";
var TargetField="logical.name";
var AttachTopicVal=vars.$L_file.topic;
var result=lib.HPCMOSLinkedRecords.CalcAttach(TargetTable,TargetField,AttachTopicVal);
if ( result == false)
{
var returnCode = system.library.HPCinteroperabilityHelpers.rescheduleActionWithName(AttachTopicVal " - MOS.DEVICE.CALC.ATTACH",vars.$L_file, "MOS.DEVICE.CALC.ATTACH");
}

4) Script library (wich called from 3) ) calculate amount of attachments and save it to device table and then transfer result of "save" to 3) (true or false)

And there is a problem.

When i add attahment for device table all works fine, but if i delete attachment from device the new value does not appear.

(see attachments - real extension TXT)

Tags:

Parents
  • First, what version of HPSM are you on?

    Second, that seems to be a roundabout way of doing it.  Adding a schedule record to come back around and modify a CI record...

    Are you adding the attachment from the device record itself?  Like, if you're on the CI record, you select Add Attachment?  If so, then you can simply do a formatctrl query to get an on-display count.  Or we use this code in the device formatctrl initialization expressions:

    $L.void=rtecall("rinit", $L.rc, $L.attachment, "SYSATTACHMENTS");$L.void=rtecall("count", $L.rc, $L.attachment, "topic=\"" logical.name in $file "\" and segment = 0", $countAttachment)

    If you're looking to save the value, you can change the $countAttachment variable to whatever field you want to populate in the record instead...

    (FYI: I am having issues opening your attachment.  Not sure if it's me or the site or the attachments themselves)

  • 1) SM 9.30

    2) $L.void=rtec.... this function just to calculate value - but problem is to save this result to device table while its opened.

    Operator open CI and enter to Attachments tab and then add or remove files from here. (So this action of operator just add new record or delete existing from SYSATTACHMENTS table)

    3) To open my attachments just save it and change extension to txt (this forum allow attach only picture extensions)

Reply
  • 1) SM 9.30

    2) $L.void=rtec.... this function just to calculate value - but problem is to save this result to device table while its opened.

    Operator open CI and enter to Attachments tab and then add or remove files from here. (So this action of operator just add new record or delete existing from SYSATTACHMENTS table)

    3) To open my attachments just save it and change extension to txt (this forum allow attach only picture extensions)

Children
No Data