2 Replies Latest reply on May 17, 2017 5:31 PM by lowergroovemusic

    Reset field contents based on newer file

    lowergroovemusic

      Hi,

       

      I am new to FM Pro, watching You Tube videos etc, but am getting confused re. scripting etc and was hoping someone could help with something that I am going in circles with. All help very much appreciated.

       

      For background. I have two tables -  one called Tracks the other called Audio. Within a Tracks layout I have a portal that shows the Audio table based on a Track ID (Primary key: Tracks) to Track ID (Foreign key: Audio). Therefore, a track can have many audio files associated with it.

       

      One of the Audio table fields is called Latest Version, the contents of which are driven by a value list with the options Yes/No. For each track, only one of the related, audio file, Latest Version fields should be set to "Yes". Please also note that the audio file I might want to upload at any time may not be the most-up-to date version of the track - but a legacy copy that I wish to store.

       

      The following is the envisaged User Experience I am battling with...

       

      • From the layout, showing the portal, I click on a button - within a portal record - to upload a new audio file;
      • This results in a pop up window which asks me if this is the most recent version of the track;
      • If I select "No" then the Latest Version field is set to no and the track upload proceeds and returns to the original portal view - that displays the new record;
      • If I select "Yes" then the script checks to ensure no other Latest Version fields are set to "Yes". If not the upload continues and returns to the original portal view - that displays the new record;

       

      However...

       

      If I select "Yes", and the script checks and there is already a Latest Version field set to "Yes", I want a dialogue box message to appear that informs me of such, i.e. "A track is already set as being the latest version", and gives me the option to view the older record within the portal view or over ride the fact it is set to "Yes" and make my new upload the latest version - both achievable by clicking buttons. Therefore -

       

      1). Choose over-ride - if I select the over ride option I would like the script to change the older Latest Version field content from "Yes" to "No" and create a new record, for the new file where the Latest Version filed content is set to "Yes".

       

      or

       

      2). Choose view - if I select view I would somehow like to view the older record and it's metadata - created date etc and filename - to ensure I wasn't uploading a duplicate audio file. If not then the next action would be as 1). above.

       

      I hope this makes sense and is not too much of an ask. Again, all help appreciate.

       

      Thanks in advance.

       

      Gary

        • 1. Re: Reset field contents based on newer file
          erolst

          If a track record can have one - and only one - latest audio record, IMO it is better to make that an attribute of the one Track record than of any Audio record.

           

          More to point: replace the yes/no field in the Audio table with a foreign key in the Track table that will hold the primary key of a selected Audio file - eg selected by clicking on a portal row and setting that related record's key into the field - or of an uploaded Audio file after you've selected the Yes option as described above.

           

          This makes the entire handling much easier because now you only need to set or update a field on a single record (the parent Track record), instead of in all the child (Audio) records.

           

          Without going into details, revisit your desired UI from above and think how that can be handled from this new perspective.

           

          Some other notes:

           

          To highlight/indicate that record in the portal, you can use Conditional Formatting, and/or you can create a new relationship like

           

          Track::id_audioFileOldest = AudioFile_Oldest::id

          (where Track is your layout table occurrence and AudioFile_Oldest a newly created TO of AudioFile)

           

          to display any data from that one record.

          • 2. Re: Reset field contents based on newer file
            lowergroovemusic

            Great Thanks. I will re-visit. Very much appreciated.