25 Replies Latest reply on Jul 30, 2008 7:35 PM by Joy Garon

    File name in an edit box

    Jeff Sweeney
      I would like to have an edit box's default value in a datacard be the file name. If I choose "Special Value - File name" for the default, I get the file name with the file's extension. This is what I want; minus the extension.

      Seems this would be a rather common request when the file name is the same as the part number. Anyone figured out how to do it?

      Thanks in advance
        • File name in an edit box
          I messed around with this and no, I didn't find an easy way to do it. You might try SW-File Name. (Copy to var, copy back.) Enhancement request time?
            • File name in an edit box
              Spencer Smith
              Our 'partno' variable in PDMWE is populated from the SW file props. There, the 'partno' variable's default value is $PRP:"SW-File Name"

              This way, the PDMWE variable is populated with the filename (without extension) at Check-In.

              It's basically what Lee stated above. Personally, I'm not crazy about filenames being our database identifiers, since it causes confusion when there are duplicate filenames in the vault, but it works for us since we have a separate folder for released (approved) files, and a relatively small installation of PDMWE.

              Spencer
                • File name in an edit box
                  Jeremy Schmidt
                  Where exactly did you set the default value?
                    • File name in an edit box
                      Spencer Smith
                      The default value is set in the templates for our parts and assemblies. That way we can't forget it

                      Spencer
                        • File name in an edit box
                          Jeremy Schmidt
                          Is there any way to do it in the card default value area as the attached image shows? We are not currently using templates.
                            • File name in an edit box
                              Spencer Smith
                              I don't see why not - it would be easy to test.
                                • File name in an edit box
                                  Jeremy Schmidt
                                  Well then I'm going to ask you how, because I did some testing and was not able to figure it out. It seems to just copy whatever I put in that field instead of pulling the SW property.
                                    • File name in an edit box
                                      Spencer Smith
                                      I tried inputting several variables in the default value field (text format), and no luck. As you said, it just puts in what you have in the field verbatim.

                                      However, if you use the section below called 'Input Formula', and select the FileName variable from the list that the arrow brings up, it brought in the filename without extension for me.

                                      It will only work for files created beginning when you make the change, though, since it acts as an input mask.
                                        • File name in an edit box
                                          Jeremy Schmidt
                                          Spencer,

                                          You must have a variable setup then for FileName. How do you have this variable configured (attributes, variable type, etc.) I am not able to reproduce this.

                                          I have now created a variable, "FileName", and placed it in the input formula for another variable (in my case, "Number") as you have shown.

                                          Any ideas?
                                            • File name in an edit box
                                              Spencer Smith
                                              Sorry - this variable was in place when I got here and assumed that it was out-of-the-box. Here's the setup dialog for my 'FileName' variable...

                                                • File name in an edit box
                                                  Mike Sveda
                                                  I tried this as I would like to use this function but could not get it to work either.
                                                    • File name in an edit box
                                                      Jeremy Schmidt
                                                      Mike,

                                                      After some more testing, I was able to get this to work. I setup the variable to have a block name of $PRP with an attribute name of SW-File Name. I did not have to put anything in the default value or input formula fields for the card.

                                                      Also, I was interested in doing something similar with weight, density, and surface area. With these, I had to put in a default vaule in the card. For example, I used "SW-Mass@Part1.sldprt" for the mass of a part. If anyone has a better way of doing this, please let me know, because this seems to require at least two check-ins until the data is populated on the card.

                                                      See the screenshots below for more detail. Thanks to everyone for there input.
                                                        • File name in an edit box
                                                          Mike Sveda
                                                          Thanks. I think I have it working, this will help for files created without templates that are dropped into the vault.
                                                            • File name in an edit box
                                                              Jeremy Schmidt
                                                              I am now attempting to setup something similar for non-sw files. For example, when creating a new .doc document, I want the "number" variable to be the filename minus the extension. So if the file name is 1234567.doc, I want the number field to be 1234567. I was able to use the string functions in dispatch to define a variable in dispatch with the correct value. However, I cannot determine how to apply this variable to an actual variable in PDMWE. Is there any way to do this without the API?
                                                                • File name in an edit box
                                                                  Joy Garon
                                                                  Hi Jeremy -

                                                                  Just checking...

                                                                  why can't you create document templates for this? That should take care of the naming and variable writing...

                                                                  Joy
                                                                    • File name in an edit box
                                                                      Jeremy Schmidt
                                                                      Joy,

                                                                      Can a template be utilized during a drag and drop? If so, how is this setup, because then we could definitely use the templates.
                                                                        • File name in an edit box
                                                                          Joy Garon
                                                                          Hi Jeremy -

                                                                          No it cannot. You said in your earlier post that it was for new files, so, I assumed you were creating brand new files.

                                                                          For non-CAD files (or better stated - files without references), you can use Dispatch to do the rename after adding the file to the vault. (see attached Dispatch example - you need to load the Dispatch.dll first - it can be found on the CD in the Support\Dispatch directory).
                                                                          Since it uses Windows rename, this method should not be used on SW files as it does not fix references.

                                                                          Joy

                                                                            • File name in an edit box
                                                                              Jeremy Schmidt
                                                                              Joy,

                                                                              Sorry to keep bugging you, but I'm not sure I totally understand this. From what I gather, this dispatch routine will take the "Document Number" value from the document's card and rename the file to that Document Number when adding the file to the vault. However, a file does not have a data card before it is added to the vault.

                                                                              What I need is basically the opposite. I have a file with the correct file name already and want the "Document Number" value populated from that file name upon adding the file.

                                                                              The problem I see is that it doesn't appear that dispatch can be used to populate a variable. Hopefully I'm wrong, because this seems like it should be possible.
                                                                                • File name in an edit box
                                                                                  Joy Garon
                                                                                  Hi Jeremy -

                                                                                  Actually, it does it 'after' the file has been added. (see attached image)

                                                                                  Joy
                                                                                    • File name in an edit box
                                                                                      Jeremy Schmidt
                                                                                      Right, but I'm still not understanding how it is going to pull the "Document Number" variable from the card, if a document card does not exist. When I drag and drop in the file, it is rename to ".doc". Or in other words, nothing existed for the "Document Number" variable so it is blank.doc. Do you see what I am getting at. What am I missing here?
                                                                                        • File name in an edit box
                                                                                          Joy Garon
                                                                                          Jeremy -

                                                                                          I'm not sure I understand what you are saying.

                                                                                          If I drag and drop a word document into the vault (actually to the users local cache), it gets 'added' to the to the vault. (The meta data is created by extracting custom properties values or via serial number generation - such as document number). So, the data card now exists at this point. The Dispatch routine then reads the value of the variable Document Number (which was created via automatic serial number generator) and uses this value to rename the file.

                                                                                          Joy
                                                                                            • File name in an edit box
                                                                                              Jeremy Schmidt
                                                                                              Joy,

                                                                                              I've got it now. I didn't realize there was a serial number generating populating the Document Number variable. Sorry for the confusion and thanks for the help. I've got it working with a serial number now. However, I am still seeing the issue that the index.xml file on the server still refers to the file name before the rename.

                                                                                              And if you or anyone else knows, I'd like to know if it is possible to populate a data card variable with dispatch. This could solve a couple similar issues I have with renaming files and updating that Document Number variable.

                                                                                              Thanks again Joy for all the help. You've got me part of the way there.