Back up revision level and add "Obsolete" to the document description field

I have a C# server method that creates a new revision of a document then after some edits, moves the document to the "obsolete" state (not CN controlled).

  • I would like to add script that will
    • back up the revision level one increment (back to what it was prior to the new rev being created).
    • add "OBSOLETE" into the document description field

Can anyone help me with this?

Parents
  • Hi,

    can you give more background info? What do you mean with 'back up revision level'? Do you want to purge the item?

    Add "obsolete" into the description field is not a big deal. You may customize your Method to grant the necessary permission and then write the property myitem.setProperty("description","Obsolete");

  • 0 オフライン in reply to AngelaIp

    The only thing I have not been able to figure out is which part of the following script do I need to remove so the new affected item will have the same revision level as the original affected item. Because it is being obsoleted, i want the new affected item to be the same revision level and we just delete the files so they cannot be accidentally used.

    #region Version affectedIdItem with action Obsolete
            {
                IList<aCNAffectedItem> affectedItemList =
                (from affectedItem in sortedAffectedItemList
                 where
                 affectedItem.Action == aCNAffectedItem.ActionType.Obsolete
                 select affectedItem)
                .ToList();

                IList<ChangeControlledItem> versionedAffectedIdItemList =
                    affectedItemList
                    .Select(affectedItem => affectedItem.AffectedId)
                    .ToList()
                    .Version((sourceItem, versionItem) => { versionItem.ItemNumber = sourceItem.ItemNumber; versionItem.RevSequence = sourceItem.RevSequence; versionItem.Revision = sourceItem.Revision; versionItem.Classification = sourceItem.Classification; });

                versionedAffectedIdItemList.Unlock();

                affectedItemList = affectedItemList.Select((aCNAffectedItem affectedItem, int index) =>
                {
                    affectedItem.NewId = versionedAffectedIdItemList[index];
                    return affectedItem;
                }
                )
                .ToList();

                affectedItemList.Lock();
                affectedItemList.ApplyUpdate("new_id");
                affectedItemList.Unlock();
            }
            #endregion

Reply
  • 0 オフライン in reply to AngelaIp

    The only thing I have not been able to figure out is which part of the following script do I need to remove so the new affected item will have the same revision level as the original affected item. Because it is being obsoleted, i want the new affected item to be the same revision level and we just delete the files so they cannot be accidentally used.

    #region Version affectedIdItem with action Obsolete
            {
                IList<aCNAffectedItem> affectedItemList =
                (from affectedItem in sortedAffectedItemList
                 where
                 affectedItem.Action == aCNAffectedItem.ActionType.Obsolete
                 select affectedItem)
                .ToList();

                IList<ChangeControlledItem> versionedAffectedIdItemList =
                    affectedItemList
                    .Select(affectedItem => affectedItem.AffectedId)
                    .ToList()
                    .Version((sourceItem, versionItem) => { versionItem.ItemNumber = sourceItem.ItemNumber; versionItem.RevSequence = sourceItem.RevSequence; versionItem.Revision = sourceItem.Revision; versionItem.Classification = sourceItem.Classification; });

                versionedAffectedIdItemList.Unlock();

                affectedItemList = affectedItemList.Select((aCNAffectedItem affectedItem, int index) =>
                {
                    affectedItem.NewId = versionedAffectedIdItemList[index];
                    return affectedItem;
                }
                )
                .ToList();

                affectedItemList.Lock();
                affectedItemList.ApplyUpdate("new_id");
                affectedItemList.Unlock();
            }
            #endregion

Children
  • That doesn´t look like one of the default transitions handlers.

    You could remove the 'version' function block to prevent the new revisions:

       .Version((sourceItem, versionItem) => { versionItem.ItemNumber = sourceItem.ItemNumber; versionItem.RevSequence = sourceItem.RevSequence; versionItem.Revision = sourceItem.Revision; versionItem.Classification = sourceItem.Classification; });

    But I wonder if this Obsolete handler works at all? It doesn´t promote anything to Obsolete, but only versions the items.

  • 0 オフライン in reply to AngelaIp

    This script only creates the new revision. There is additional script that promotes the new version to obsolete.

    If I remove the section you referenced, will the new version get a new item number and still have the same classification, revision level, and revision sequence?

  • It´s still not clear what you want to do :) .

    Do you know want to get a new revision or do you want to prevent it? Or do you want a new item revision, but the previous (!) version shall become Obsolete? 

    'Version' is the Innovator term for creating a new Revision or Generation. So without version, you item revision will stay the same. In this case you will only have one Change Controlled item in the affected item. The Action Obsolete as far as I remember just changes the state property to Obsolete. If you want to get a new item_number, you will have to use "Renumber". 

    But when you already use a customized version of this Method, I cannot tell what will happen when you remove this block. The complete region is not part of the standard Method.

  • 0 オフライン in reply to AngelaIp

    I apologize for not being clear. I think you have already helped answer my question.

    I want to be able to obsolete a part or document after I delete any files that are in that document or part container. So I attached the document or part as an affected item, the script moves the original to In Change and creates a new one in the state of Preliminary. I lock the preliminary one, delete the files and back the revision level to the same as what it was in the original. Then after approved, the new one is moved to Obsolete and the old is moved to Superseded. The files are still available by going into Revisions and accessing them from the Superseded "copy" for historical access. 

  • Ok, so you basically use the new revision so you have an empty version of your item (which identical revision so it looks the same)

    Maybe you just have some kind of lifecycle problem? When your new revision is preliminary, you cannot promote directly to Obsolete. Do you have a lifecycle path for this usecase?

  • 0 オフライン in reply to AngelaIp

    It gets promoted to In Change where we delete the files. Then gets promoted to the Checker and In Review. Then after validation by the Checker, it gets approved and promoted from In Review to Obsolete.

  • 0 オフライン in reply to AngelaIp

    I deleted the following from the method but it creates an exact duplicate and I get an error that the same item is on the CN more than once. I want a new version, I just do not want the revision level to increase. How do i do that?

    .Version((sourceItem, versionItem) => { versionItem.ItemNumber = sourceItem.ItemNumber; versionItem.RevSequence = sourceItem.RevSequence; versionItem.Revision = sourceItem.Revision; versionItem.Classification = sourceItem.Classification; });

                versionedAffectedIdItemList.Unlock();

  • 0 オフライン in reply to AngelaIp

    I think the part that does the index has to be removed or modified?

    .Version((sourceItem, versionItem) => { versionItem.ItemNumber = sourceItem.ItemNumber; versionItem.RevSequence = sourceItem.RevSequence; versionItem.Revision = sourceItem.Revision; versionItem.Classification = sourceItem.Classification; });

                versionedAffectedIdItemList.Unlock();
                    
                affectedItemList = affectedItemList.Select((aCNAffectedItem affectedItem, int index) =>
                {
                    affectedItem.NewId = versionedAffectedIdItemList[index];
                    return affectedItem;
                }
                )
                .ToList();

                affectedItemList.Lock();
                affectedItemList.ApplyUpdate("new_id");
                affectedItemList.Unlock();
            }