How to remove file attachments using the SDK

I am looking for ways to programmatically remove file attachments from work items.  If I recall correctly, the system only keeps the file for as long as the relationship exists, so that, in theory, the file is deleted from the database a soon as the
relationship is removed.
I found this
Using the SDK to Create and Edit Objects and Relationships Using Type Projections
Is this the only way or are the other, simpler ways for deleting relationships and/or file attachments?
Is this something I could do with the Orchestrator Remove Relationship activity?
A little background on this question: I have multiple different teams with varying data retention requirements for Service Requests.  My longest requirement is 3 years (audit) while most teams only require 90 days.  I was looking to add in some
jobs for some more aggressive file attachment grooming to keep the database smaller.
Thanks.

The relationship is defined as a membership/containment relationship. So, yes, if you delete the relationship, the file attachment (and the associated blob) are deleted as well.
Based on the background you described, I'm assuming you identify a bunch of work orders whose files you want to delete if they're older than X. So, for instance "Work Items with Y team; delete file attachments older than 90 days", "Work Items
with Q team; delete file attachments older than 3 years". Is that right?
If so, you don't necessarily need to delete relationships specifically...you can simply delete the file attachment objects which will delete the relationship, the file attachment object, and the associated blob (the file itself in the database).
Using the SDK, you will not need type projections for this. You'll only need the work item object(s) (an incident or service request or whatever), the GetRelatedObjects<>() method, and an IncrementalDiscoveryData object.
So, after you get all of the appropriate work items, you can use the following snippet to delete their file attachments if the attachments meet your age requirements
//Connect to the management group
String strMySCSMServer = "<my mgmt server>";
emg = new EnterpriseManagementGroup(strMySCSMServer);
IncrementalDiscoveryData idd = new IncrementalDiscoveryData();
ManagementPackRelationship relWorkItemHasFileAttachment = emg.EntityTypes.GetRelationshipClass(new Guid("AA8C26DC-3A12-5F88-D9C7-753E5A8A55B4")); //System.WorkItemHasFileAttachment
//Get the work item's related file attachments using it's Id
Guid myWorkItemGuid = new Guid("<some work item guid>");
IList<EnterpriseManagementObject> lstFileAttachments = emg.EntityObjects.GetRelatedObjects<EnterpriseManagementObject>(myWorkItemGuid, relWorkItemHasFileAttachment, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
//Loop through each file attachment
foreach (EnterpriseManagementObject emoFile in lstFileAttachments)
//Determine its age
DateTime AddedDate = (DateTime)emoFile[null, "AddedDate"].Value;
TimeSpan FileAttachmentAge = AddedDate.Subtract(DateTime.Now);
//Prep the file attachment for deletion if it's old enough, in this example, older than 90 days
if (FileAttachmentAge.Days > 90)
idd.Remove(emoFile);
//Submit the deletions to the database.
idd.Commit(emg);

Similar Messages

  • File Selection using the SDK

    Hello
    Is their a way that the SBO SDK UI exposes the file selection like the one use for add bit maps etc? I tried doing this by using writing code but cannot get this to display on the screen it is called from. The code is:
    Public Function Open_FileView()
       Dim OpenFileDialog1 As New OpenFileDialog
       OpenFileDialog1.InitialDirectory = "C:\"
       OpenFileDialog1.Filter = "txt files (.txt)|.txt|All Files (.)|."
       OpenFileDialog1.FilterIndex = 2
       OpenFileDialog1.RestoreDirectory = True
       If OpenFileDialog1.ShowDialog = DialogResult.OK Then
          Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
          MessageBox.Show(sr.ReadToEnd)
          sr.Close()
       End If
    End Function
    Thanks
    John

    Try something like this:
    System.Windows.Forms.Form winForm = new System.Windows.Forms.Form();
    winForm.TopMost = true;
    System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
    sfd.Filter = "XML (*.xml)|*.xml";
    if(sfd.ShowDialog(winForm)==System.Windows.Forms.DialogResult.OK) {
    //Do stuff
    This work for me (Save dialog, but openfiledialog works the same way)

  • How to connect to Akamai using RTMP SDK (Adobe Media Server Connector for C++)?

    We need to stream live video to Akamai using RTMP. But, we are trying to connect using ADOBE RTMP SDK (Adobe Media Server Connector for C++ 2.0.1), but have no idea regarding how to connect to Akamai using the SDK. How to make the SDK respond to the server challenges for password etc. If this can't be done using the RTMP SDK, we can use plain C++ for the purpose. But for that too, we don't have any idea regarding the steps involved to make it work. If anyone has any idea on how to connect to Akamai using the RTMP SDK or using plain C++ (a sample code will be very helpful), please help us out. If you can suggest any C/C++/.NET library too which will help us achieve it, we are ready to do so. Thanks in advance.

    hi,
    I am sorry I can not help you.  Could you do me a favor? I know you are using Adobe RTMP SDK.I want to know how to get it.
    I tried to contact adobe at [email protected] but it seems to be an invalid email address.if you know efficient way,
    please tell me.Thank you very much.

  • How do you remove the filename/path using the SDK

    I have a program that uses the Adobe Acrobat SDK . It creates aPDF file from a HTML file that gets created after the program cruches some data. It can create the PDF file fine but how do I get it to do it with out the file name and path in the lower left corner. We insert the created PDF file into another document and do not want to show the data on these created pages.
    Have searched through this site and can not see it mentioned.   HELP !!!

    I am not the programmer, he is out of the office today.
    What I see happen is that our program is used to create a database of the content of a multipage PDF file (an old doucment that has been scanned and OCR'd), the program then outputs the data as a HTML file (not the Adobe SDK).
    This HTML file is then converetd into a PDF file and attached to certain subsets of the original PDF file, its does a whole bunch of splitting and recombining of the document into the sections we need. It does this fine, no problems at all. All of this is done using our program and the Adobe SDK.
    The issue is that the PDF file (generally just one page) that gets created from the HTML file includes file name and file path at the lower left corner of the page. We are looking for the commands within the SDK that can turn the feature/function that creates this text on/off.
    As the Adobe Acrobat on this machine is used for many different jobs, some that require this text to be shown on other documents that are created (by using Acrobat itself and not the SDK) we really don't want to have to open Acrobat itself everytime we want to run this process.
    The SDK seems to have commands for pratically everything else, we were hoping it also has the commands within it that we can then program to not create this one area of text when converting the HTMl to PDF file from within our program..
    I hope that comes across OK
    PS
    I just ran a test creating a PDF file froma  webpage, and I can see the field Place Headers and Footers on a new page. I have tried creating the page with and without the Headers and Footers, that works fine. But can this be done just by using the SDK and if so where is that command located.
    Message was edited by: MichaelEastick

  • I keep getting an error code while trying to import a cd to my itunes: Error occurred while converting the file. The disc you are attempting to use is full. removing files and emptying the recycle bin will free up additional space.  What does this mean?

    I keep getting this error code while trying to import a cd to my itunes: "Error occurred while converting the file. The disc you are attempting to use is full. removing files and emptying the recycle bin will free up additional space."  What does this mean?

    Well it probably means exactly what it says... How much free space is there on your hard drive where the iTunes Media folder resides? I believe there is also an obscure bug that can occur when software doesn't read the true value of the free space properly, and the workaround is, perversely, to duplicate some content so that with less actual free space the software in question perceives it as more. I've no idea if iTunes is affected by such a bug.
    tt2

  • HT4889 How do change the ownership of files after using the migration assistant?

    After I copied all of my files across using the migration assistant, the tool is nice enough to assume that I want to use the same ID that I had on my PC.  This is not my case as I am using a different name on the mac.  How do I get the files from the other user name?  I have already set the sharing permissions so that I can see them on both user ids, however the only way I can see to update is to copy them all.  As I have about 1TB of files, this is a little inconvenient.  Any thoughts?

    Thanks.  It got me on the right track.  At the end, I copied the 1TB over and just deleted the other profile.  I tried to set the ownership to my regular ID by removing the lock from "Get Info" but I still had to move them out of the other "user" folder.

  • How to get Bursting file to use the same template as selected by user

    I have created an XML publisher bursting control file for a standard Oracle report Direct Debit letter.
    The user wants to be able to select from a number of different letter templates which is ok except that the bursting control file is fixed to use one template.
    How can I get the bursting control file to use the same letter template as selected by the user when running the report ?
    I am using XML Publisher 5.6.3 with bursting patch.

    Try these following, which come to my mind now as of now.
    In the bursting file, you can do the filtering and apply different template..
    <xapi:template type="rtf" location="/usr/template1" filter=".//DIRECT_DEBIT[./parameter_or_element='first_template']"></xapi:template>
    <xapi:template type="rtf" location="/usr/template2" filter=".//DIRECT_DEBIT[./parameter_or_element='second_template']"></xapi:template>
    second option..
    you can replace the element from the xml in the bursting control file.
    ${ELEMENT_NAME}
    can be used in the template name i guess..
    <xapi:template type="rtf" locale=""
    location="xdo://AR.${SHORT_NAME}.en.US/?getSource=true" translation="" filter="">
    </xapi:template>
    But in this short name has to be in XML file...
    I haven;t tried it...wil try it wheni get time..

  • How to find the File name using the FTP Adapter

    hi all,
    how to find the File name using the FTP Adapter with BPEL.
    Regards

    Found the solution for this.
    First In the mediator's routing rule use assign property $in.property.jca.file.FileName to $out.property.jca.file.FileName
    In the BPEL's receive activity go to the properties tab and get the property to a BPEL variable. That should do it.
    Thanks for the posts

  • How can I use the SDK(cs5 or cs6) draw a dot matrix bimap

    how can I draw a dot matrix bitmap?
    I want to use the SDK to draw a dot matrix bimap,like, Please someone help?Thanks a lot!

    I've moved your question to the InDesign SDK forum.

  • Startup disk is full and the laptop can't operate.  How I remove files for it to work?

    Startup disk is full and the laptop can't operate.  How I remove files for it to work?

    Can you turn on the Macbook Pro?
    If yes, can you see the hard drive icon?
    Have you emptied the trash?

  • How to remove SD Card from the Card Reader slot - Satellite A100?

    Hi,
    Is there anyone to help me? I inserted a 64 MB SD card in the card reader slot of my Toshiba A100 model. It's the first time i have inserted the card. The card is inside the slot. I can not take it out! I don't have any idea how to remove the card from the card reader slot. I can see the contents of my SD card, can open the files too. But how to remove it out from the slot. Please help me giving your idea to remove the card out from the slot.
    Arjun

    Hi
    In my knowledge the SD card slot doesnt has a any additional helps like the PCMCIA slot to remove the card.
    You have to remove it simply. Try to grab the card and move it out. You can try to use the pair of tweezers. Maybe it helps

  • How to remove links pointing to the same page?

    I have PDF documents with Links which point to sections referenced (e.g. link of text "Section 2.2" points to the actual page number of "Section 2.2"), but as the links are created from cross-references during rendition from Word to PDF, there are cases that the destination page number and source page number of the links are the same (e.g. links of text "Section 2.2" on page 9 are created with the destination of page 9 which is the actual page number of "Section 2.2"), I want to remove all these links, but I don't know how to get the destination page, I check the API reference and find that "PDLinkAnnotGetAction" may work , but I don't know how to use it, could you check me codes below and advise ? Your help is really appreciated!
    PDPage page;
    ASInt32 i,i2;
    AVDoc avDoc = AVAppGetActiveDoc();
    PDDoc pdDoc = AVDocGetPDDoc (avDoc);
    int pageNum = PDDocGetNumPages(pdDoc);
    for (i = pageNum - 1; i >= 0; i--)
    page = PDDocAcquirePage(pdDoc, i);
    int annotNum = PDPageGetNumAnnots(page);
    for (i2 = annotNum - 1; i2 >= 0; i2--)
      if...
      PDPageRemoveAnnot(i, i2);
    My Product Information:
    Acrobat Pro 8.1.6, Windows

    Start by reading the PDF standard (ISO 32000-1) to understand Actions vs. Destinations.
    Then for each annot, you'll want to see which it has (and in the case of an Action, if it has more than one).  Then you need to parse the action or dest to see what it is and where it goes.  If you don't like it, then you'll delete it.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Tue, 25 Oct 2011 09:25:32 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: How to remove links pointing to the same page?
    How to remove links pointing to the same page?
    created by OALD<http://forums.adobe.com/people/OALD> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/3989576#3989576

  • How to remove "all day" as the default setting in iCal?

    How to remove "all day" as the default setting in iCal? The iCloud calendar works by double-clicking but the local behaves differently.

    Hello Valerie,
    the default - "all day" or "time based" - depends on the view in iCal. In month view the default is "all day",
    in week view or day view it is a time interval, if you use "File -> New Event". If you add the event by double clicking into the calendar, it will depend on the section you are clicking - in the all day section you will add an all-day event, in the time-grid you will enter an event with start-end time.
    Regards
    Léonie

  • How come I can't use the back gesture in certain apps with my magic mouse on certain applications in Lion OS?

    How come I can't use the back gesture with my magic mouse on certain applications in Lion? I figured out that in Safari i have to use a 1 finger swipe to go back a page instead of 2 fingers like i used to do in Snow Leopard. But apps like iTunes and iPhoto and i can't do that. Any ideas? is there a setting im missing to make this work? It works in Safari but not any other applications, so im assuming theres no setting for this. Just want to know if this is just a bug that will be fixed in the next update or if its something I can fix now. Any help would be appreciated because its kind of annoying. Other than this minor issue I love Lion. Full screen apps are unbelievable.

    Hi.
    I managed to compile open-vm-tools and the kernel module against 3.14.5 kernel.  Here is the tarball with the all the files.
    I still have an issue : With vmware-player 6.0.2, I can't acces my shared folder :
    root@P146S011b ~ # lsmod | grep hgfs
    vmhgfs 41622 0
    vmw_vmci 47960 2 vmw_vsock_vmci_transport,vmhgfs
    root@P146S011b ~ # vmware-hgfsclient
    R
    D
    C
    root@P146S011b ~ # mount -t vmhgfs .host:/R /mnt
    Could not add entry to mtab, continuing
    root@P146S011b ~ # tail -1 /etc/mtab
    .host:/R /mnt vmhgfs rw,relatime 0 0
    root@P146S011b ~ # cd /mnt
    cd:cd:6: not a directory: /mnt
    1 root@P146S011b ~ #
    Forgot to add an install file with a depmod -a inside. You will have to run it by yourself

  • I have just bought a new Imac and it will not load my copy of FCE 3.5 as it says "PowerPC applications are no longer supported". So how do I get to use the version of FCE I am used to and have paid for ?

    I have just bought a new Imac and it will not load my copy of FCE 3.5 as it says "PowerPC applications are no longer supported". So how do I get to use the version of FCE I am used to and have paid for ?

    I do not have any experience with Final Cut, but if you have existing projects that you MUST access; then you are in need of a solution on your new iMac in Mountain Lion!
    Unfortunately you got caught up in the minor miracle of Rosetta.  Originally licensed by Apple when it migrated from the PowerPC CPU platform that it had used from the mid-1990's until the Intel CPU platform in 2006, Rosetta allowed Mac users to continue to use their library of PPC software transparently in emulation.
    However, Apple's license to continue to use this technology expired with new releases of OS X commencing with Lion (and now Mountain Lion).  While educational efforts have been made over the last 6 years, the fact is that Rosetta was SO successful that many users were caught unaware UNTIL they upgraded to Lion or Mountain Lion.
    Workarounds:
    1.  Purchase a used Mac that will run Snow Leopard (with the optional Rosetta installed) and continue to run FCE on that Mac (you can actually use Screen Sharing with a "headless" used Snow Leopard Mac Mini and use the 27" screen from your iMac to view and work FCE in the Mac Mini environment);
    2.  Upgrade to an Intel compatible version of FCE and hope it converts your existing projects to its newer format correctly.  There is much debate that the newer version of Final Cut are eliminating many needed features; for example Final Cut Pro X vs. Final Cut Pro 6 -- many users are staying with version 6;
    3.  Install Snow Leopard (with Rosetta) into Parallels and then install FCE in the Snow Leopard environment:
                                  [click on image to enlarge]
    Full Snow Leopard installation instructions here:
    http://forums.macrumors.com/showthread.php?t=1365439
    NOTE: STEP ONE of the instructions must currently be completed on a Snow Leopard or Lion Mac and the resulting modified Snow Leopard.cdr install file can then be moved over to your Mountain Lion Mac for completion of the remaining steps.
    NOTE 2:  Computer games with complex, 3D or fast motion graphics make not work well or at all in virtualization.

Maybe you are looking for