9 Replies Latest reply on May 24, 2012 3:48 PM by Daniel McRae

    Good way to set Year variable in EPDM

    Daniel McRae

      Hi,

       

      Does anyone know a good way to set a Year varible to the current year on a transition? I'm wanting to set the varible to the current year when a drawing gets changed to automatically populate the copyright information when the drawing is approved (as opposed to when it is updated in various ways), and this would make life easier. The only difficulty is that I can't see a way to set the variable to the year only - I can set it to the current date (which I seem to remember can be dependent on the computer date formatting), but not the year. I saw somewhere else in the forums someone suggesting using the year as part of a filename via a serial number, but I don't seem to be able to set a variable to a serial number, just the filename.

       

      Any suggestions?

       

      Thanks and regards,

      Daniel

        • Re: Good way to set Year variable in EPDM
          Jason Capriotti

          I don't believe you can through a transition action, it only allows Time and Date and doesn't really give you any formatting options.

          However, Dispatch can do this using the following syntax: CurrentTime(%%Y)

            • Re: Good way to set Year variable in EPDM
              Daniel McRae

              Best option I've come up with, thank you.

               

              I'm putting it in as a Dispatch task, running on transition to various states. The script I've come up with is as follows so far:

               

              For all documents: Block START

              Jump: IF CurrentTime(%%Y) = %TempYear% NO_CASE THEN GOTO Finish

              Check out file: %PathToSelectedFile%

              Set card variables: Variables (Set Year to CurrentTime(%%Y))

              Check in file: %PathToSelectedFile%

              Label: Finish

              End for all documents: Block End

               

              I've set the %TempYear% variable to the data card variable Year.

               

              As it is, the script always sets the data card variable Year to the current year. Can you tell me why my script doesn't see that the current year and the value of the year variable are the same thing when it is set correctly? This would mean that it doesn't set the Year variable each time, which would be nice (less history).

               

              I'll play around a bit more and see what I come up with tomorrow.

               

              Thanks for your help,

              Daniel

                • Re: Good way to set Year variable in EPDM
                  Tim Read

                  Hi Daniel,

                   

                  Try creating a variable "CurrentYear" as a string variable with the value CurrentTime(%%Y) and test it against the %TempYear% variable you already have in your Jump statement

                   

                  I have had many issues with Dispatch related to String operations outside of the Variable window so maybe the shortening of the CurrentTime(%%........) variable is also not behaving as expected.

                    • Re: Good way to set Year variable in EPDM
                      Daniel McRae

                      Got it. I looked at the contents of my variables using a message box and found the %TempYear% variable empty. The file variables aren't set unless the file is checked out (which seems a bit insane to me, but there you go). Otherwise they're empty. My script is as follows:

                       

                      For all documents: Block START
                      Check out file: %PathToSelectedFile%
                      Jump: IF CurrentTime(%%Y) = %TempYear% NO_CASE THEN GOTO Finish
                      Set card variables: Variables (Set Year to CurrentTime(%%Y))
                      Label: Finish
                      Check in file: %PathToSelectedFile%
                      End for all documents: Block End

                       

                      %TempYear% is set to the file datacard variable Year.

                        • Re: Good way to set Year variable in EPDM
                          Tim Read

                          Insane or not, the model EPDM uses is that to make any changes to variables on the datacard requires a new version: checkout - modify - save - checkin.

                           

                          It would be nice to have Administrative rights to make these changes without having to check out the file but that is simply not possible.

                            • Re: Good way to set Year variable in EPDM
                              Daniel McRae

                              No, I don't mind files having to be checked out to change variables - that's only safe (although I can see some situations where it would be useful to be able to raise the permissions to an administrator level in the tool). The bit I find odd is that unless the file is checked out, Dispatch can't see the datacard variables (at least for me) - the temporary variable I had set to equal the filecard variable was empty unless the file was checked out.

                               

                              Daniel

                                • Re: Good way to set Year variable in EPDM
                                  Tim Read

                                  That's not standard behaviour. I access datacard variables of files all the time that are not checked out. Maybe your issue is that you don't have a local copy of the file?  I have never checked that because I tend to always have local copies.  Try putting a "Get File" command in your Dispatch script.

                                    • Re: Good way to set Year variable in EPDM
                                      Daniel McRae

                                      No, that's one of the things I tried when I was playing around with it. And with this state transition, it's almost certain that whoever is doing it would have a local copy.

                                       

                                      ...

                                       

                                      Yup, just double checked - if I put a message box displaying the state of my linked variable before I've checked it out, even with a "Get File" command before that, the variable is empty. Once I've checked it out, the variable contains the correct information.

                                       

                                      We're currently on EPDM 2012, SP3. Perhaps it's a different version from you?

                                      • Re: Good way to set Year variable in EPDM
                                        Daniel McRae

                                        The Support people came back with the answer. I needed to set the configuration of the datacard variable correctly - I had it blank, so I needed to set it to "@" so that it would call up the variable from the overall drawing configuration.

                                         

                                        Thanks for all your help!