2 Replies Latest reply on Oct 13, 2014 11:22 AM by Klaas Oudejans

    EPDM API for ChangeState drives me crazy :)

    Klaas Oudejans

      Dear all,


      I have an issue with the EPDM API I cannot seem to solve. I'm trying to obsolete files through the ChangeState Method (IEdmFile5). I think I have the problem isolated now. I want to obsolete a pdf, which is part of the category "Documents".
      Within this category there are three ways to go from a released file state to a Work in Process file state. The three transitions are called:


      • Unlock for ECO (Project files)
      • Unlock for ECO (Library)
      • Unlock for ECO (BM)


      Those different transitions relate to different locations in the vault, and the permissions are controller by user groups. When I am in the user profile "design engineer", I can only see the transition Unlock for ECO (Project Files) because that's my only permission.
      As soon as I am in a user profile that can see more than one of those transitions, it becomes messy. Let's say I am a user that can see all three transitions by user privilige.


      I am in location A when I right click a pdf. Location A is not part of the transition Unlock for ECO (Project Files). The Conditions for that transitions contains that the Filepath needs to be Location B.
      EPDM gives me the option to select Unlock for ECO (Project Files) in location A even though I can never do something there that will render a result. I can select that transition, but the files do not meet the condition Filepath needs to be location B.


      So the selectable transitions get filtered to your RMB context menu through user rights, but not through the conditions.


      The actual issue; ChangeState does not work when I have more than 1 transition as an option to reach a new state. When I have a profile that can see only 1 transition, the script works. When I see multiple transitions, it does nothing, but also does not throw an error.
      That makes me think that it selected the wrong transition for the file, rendered no valid files in it's solution and went ahead like nothing happened.


      I cannot specify which transition to use in the ChangeState method can I? Is there some other way to do this?


      The help gives some extra info on something similar:

      It is possible to create multiple workflows with two or more states having the same name. If poStateIdOrName contains the name of the destination state instead of its ID, and if several transitions from the file’s current state lead to new states all having the same name, SolidWorks Enterprise PDM randomly selects one of them. To be sure to which state the file transitions, specify a state ID in poStateIdOrName.


      But that's different from my situation as in my problem lies in the transitions.


      I have experimented intensively with the syntaxes here. By Going into the current state, and figuring out all potential next states, with the ID's, but the ID of the target is the same ID all the time.


      oObsoleteFile.ChangeState("Work in Process", sub_folder_pdf.ID, "", 0, 0);

      oObsoleteFile.ChangeState(targetState.ID, sub_folder_pdf.ID, "", 0, 0);


      I can't find any info on the internet for what to do with this problem, so does anybody here have an idea? Can I control which transitions state the syntax needs to use?


      oObsoleteFile.ChangeState(targetState.ID@[use_this_transition], sub_folder_pdf.ID, "", 0, 0);  ?????


      Any help would be greatly appreciated!!


      Is this the right forum by the way?

        • Re: EPDM API for ChangeState drives me crazy :)
          Dan Miel

          I am assuming that you are using the IEDMFile5 change state. When I was working with the change state I asked my VAR and they confirmed that you are correct, there is not a way to select the transition with file5. You can select the transition using the IEDMBatchChangeState but then the change state dialog box pops up.

               In my case, I had two transitions going from one state to another, one bumped the revision the other did not and I never knew which one was going to be used. I ended up creating a new state with one transition going to the new state and an automatic transition going to the final state.

               In your case, would it be possible to create three different users and depending on the category of the file, log in as the appropriate user just before you change the state? My solution of adding a new state just to make a program run works but it always adds more file versions.

               It seems silly to do these workarounds instead of just being able to select a transition by name.


          Dan Miel

          SW and EPDM 2014 SP04.