2 Replies Latest reply on May 8, 2017 11:18 AM by philmodjunk

    Parsing filename from insert and setting corresponding fields

    talkersw

      Hi all. This is pretty simple to understand. I have a filename to insert into the container that will have a naming convention such as:

       

      "name1_type_date" ...each value between the underscores has a corresponding text field on the layout

       

      When I insert the file into the container, I would like to parse out each of the values separated by "_" and set them in the 3 corresponding fields on the layout.

       

      For example:

       

      Uploaded filename is: sam_contract_9_22_2017

      Set name1: Sam

      Set type: contract

      Set date: 9/22/2017

       

      I already have it modifying the filename on the insert to build the name from these fields when populated, but I also want it to work the reverse way so that someone can quickly get everything entered just from uploading the files.

        • 1. Re: Parsing filename from insert and setting corresponding fields
          siplus

          Set a $Var to

           

          Let (

          elements = Substitute(Filename; "_"; ¶);

          List(  GetValue(Elements; 1); GetValue(elements; 2); Date(GetValue(Elements; 3); GetValue(Elements; 4); GetValue(Elements; 5)  )

           

          )

           

          and assign your 3 fields to GetValue($Var; 1) , GetValue($Var; 2) and GetAsDate(GetValue($Var; 3))

          • 2. Re: Parsing filename from insert and setting corresponding fields
            philmodjunk

            Set Variable [ $NameData ; value: Substitute ( GetContainerAttribute  ( YourTable::Container ; "FileName" ) ; "_" ; ¶ ) ]

             

            Set Field [ YourTable::Name ; GetValue ( $NameData ; 1 ) ]

            Set Field [ YourTable::Type ; GetValue ( $NameData ; 2 ) ]

            Set Field [ YourTable::Date ; Date ( GetValue ( $NameData ; 3 ; ) ;

                                                          GetValue ( $NameData ; 4 ) ;

                                                         GetValue ( $NameData ; 5 ) ) ]