Forum Discussion

dkinsley's avatar
dkinsley
Ideator I
6 years ago
Solved

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?

  • 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.

10 Replies

  • 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");

    • dkinsley's avatar
      dkinsley
      Ideator I

      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

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        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.