Radhika,
I suspect that your Entry object 'userEntry' contains a blank Attachment
field, and is as such, re-blanking it....try this

Stat=userEntry.get(Integer.valueOf(7)).getIntValue();
Entry statusEntry = new Entry();
if(Stat == 0){
  statusEntry.put(Integer.valueOf("7"), new Value("Config Check"));
}
if(Stat == 2){
  statusEntry.put(Integer.valueOf("7"), new Value("Start Processing"));
}

asu.setEntry(formName, entryID, userEntry, null, 0);


On Mon, Dec 18, 2017 at 6:09 AM, Narayanan, Radhika <
[email protected]> wrote:

> Hi,
>
>
>
> Thanks Eric Roys and LJ Longwing. Now while I’m able to copy the
> attachment from ITSM 9.1.03 server to ITSM 8.1.02 server, it lasts for less
> than a second. I’ve 2 Java API programs. The first one , running on source
> server, copies the attachment from 9.1 server to 8.1 server. After this, I
> can open the attachment on 8.1 server successfully. Less than a second
> later, a second Java API program running on 8.1.02 server is supposed to
> modify the status of that record [whose attachment I just copied] which is
> a completely independent operation. It updates the status successfully, but
> right after that, I can no longer open the attachment. Attachment shows 0
> KB on 8.1 server now.
>
>
>
> 9.1 server code that is able to copy attachment successfully:
>
>        String entryIdOut = asu1.createEntry("INT:TSF:Inbound:StagingForm",
> userEntry);
>
>                                  
> userEntry1=asu1.getEntry("INT:Inbound:StagingForm",
> entryIdOut, null);
>
>                                  userEntry1.put(Integer.parseInt("910000023"),
> new Value(attachValue));
>
>                                  asu1.setEntry(formName, entryIdOut,
> userEntry1, null, 0);
>
>
>
> <ATTACHMENT FINE AFTER THIS>
>
>
>
> 8.1 server code modifies only status, not attachment file:
>
>      Stat=userEntry.get(Integer.valueOf(7)).getIntValue();
>
>                               if(Stat == 0){
>
>                                   userEntry.put(Integer.valueOf("7"), new
> Value("Config Check"));
>
>                                   asu.setEntry(formName, entryID,
> userEntry, null, 0);
>
>                               }
>
>                                if(Stat == 2){
>
>                                   userEntry.put(Integer.valueOf("7"), new
> Value("Start Processing"));
>
>                                   asu.setEntry(formName, entryID,
> userEntry, null, 0);}
>
> <NOW ATTACHMENT DISAPPEARED>
>
>
>
> Am I not using the correct syntax? Should I update the attachment each
> time even if I’m not modifying it? Please advise.
>
>
>
> *Thanks,*
>
> *Radhika Narayanan*
>
>
>
> *From:* ARSList [mailto:[email protected]] *On Behalf Of *Roys,
> Eric
> *Sent:* Friday, December 15, 2017 10:46 PM
>
> *To:* ARSList
> *Subject:* Re: Transfer attachment from one AR Server to another AR
> Server through Java API
>
>
>
> Radhika,
>
>
>
> Here is example of getting an attachment from an existing record and
> creating new record with the attachment.
>
> In your case, the write new record would be with ARServerUser for your
> other instance to complete the attachment
>
> from one system to another system process.
>
>
>
>
>
> //make the call to remedy to get an entry object
>
> Entry e = svr.getEntry(<yourForm>, <anEntryId>, null);
>
> //get actual content of attachment by getting blob for attachment field
>
> byte[] content = svr.getEntryBlob(<yourForm>, <anEntryId>, <yourFieldId>);
>
> //get just the attachment value from interesting attachment field
>
> AttachmentValue attachValue = (AttachmentValue)e.get(<
> yourFieldId>).getValue();
>
> //set content with the byte array from getBlob
>
> attachValue.setValue(content);
>
>
>
> //Then just do create Entry with new Entry object containing
>
> //the AttachmentValue
>
> Entry newEntry = new Entry();
>
> newEntry.put(<yourFieldId>, new Value(attachValue));
>
> //add any additional field values here
>
>
>
> //then write to new record
>
> System.out.println(svr.createEntry(<yourForm>, newEntry));
>
>
>
>
>
>
>
> Hope that helps 😊
>
>
>
> Eric
>
>
> ------------------------------
>
> *From:* ARSList <[email protected]> on behalf of LJ LongWing <
> [email protected]>
> *Sent:* Friday, December 15, 2017 9:54:56 AM
> *To:* ARSList
> *Subject:* Re: Transfer attachment from one AR Server to another AR
> Server through Java API
>
>
>
> Radhika,
>
> To retrieve an attachment from the source server you need to do two calls,
> one from an entry perspective to get the file name and size, and another
> from a getblob to get the actual attachment info....then when moving the
> attachment to the remote system you need to do the opposite setBlob....I
> don't think you then need to do the setEntry....are you doing the setBlob
> on the destination system?
>
>
>
> On Fri, Dec 15, 2017 at 7:42 AM, Narayanan, Radhika <
> [email protected]> wrote:
>
> Hi List,
>
>
>
> I’m trying to transfer an attachment from a custom form on ITSM 9.1.03 to
> another custom form on ITSM  8.1.02 through Java API.
>
> Here is the syntax used in the Java  program. The issue is that the while
> the file name is visible on 8.1.02 form after the transfer, when I open the
> file there is nothing within. I other words , an empty file got
> transferred. Something amiss, but what?
>
> attach = asu.getEntryBlob("INT:Inbound:StagingForm",
> userEntry.getEntryId(), Integer.parseInt("910000023"));
>
>
>
> Even before sending, the actual content inside the attachment from that
> record appears to get emptied. What can we do about this? Please advise.
>
>
>
> Thanks.
>
>
>
>
> --
> ARSList mailing list
> [email protected]
> https://mailman.rrr.se/cgi/listinfo/arslist
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__mailman.rrr.se_cgi_listinfo_arslist&d=DwMFaQ&c=qk747rkER3kecdav6nsl8A&r=-cQc4A-bmNJm7Q20qdrfWRlA0iXtV9n1oBLzUziNI80&m=jb-fkpFj2sH6DvBp5AGvpmGqpz7bPF9cr1Z6N9ZkWk8&s=rCDAynw5eZCCdUx-S0Z9qt5FlK-tchepHf56blAIKhw&e=>
>
>
>
> --
> ARSList mailing list
> [email protected]
> https://mailman.rrr.se/cgi/listinfo/arslist
>
>
-- 
ARSList mailing list
[email protected]
https://mailman.rrr.se/cgi/listinfo/arslist

Reply via email to