2 Replies Latest reply on Feb 5, 2016 6:30 AM by bunoire14

    Script to Modify a Record Entry




      Im brand new to FM and am working on a basic Image Library for my Department at work so that we can keep track of our Resources, search for them and email them to distributors easily.


      I have setup a basic form layout which has three buttons, 1. Authorise Image, 2. Download, 3. Email.


      The download button is fine it triggers a simple script that grabs the contents of the container this will be used by myself and my colleagues to grab images we need for projects.


      However Im struggling getting my head round the syntax to create a script that updates a field on a record and commit it back to the DB. The image has a Image_Athorised field which is a number limited to 1. The idea is its a boolean "True/False" or "1/0" in my case (I couldn't figure out how to setup a boolean on the DB) This will be used to ensure the images we have in the DB have been authorised for use by the manufacturers of our products and have been checked by a manager in terms of Licence arrangements. So clicking "Authorise" will set the Image_Authorised Field to 1 and store that back to the DB and refresh the current record (I have some conditional formatting based on if a image is authorised or not).


      My background is in PHP and if I were writing it in that I would check the value with a conditional and if the conditional confirmed the presence of a 0 it would update to 1 push back to the DB and refresh the users view.


      Any pointers on achieving this on FM would be great.... or pointers if im taking a totally incorrect approach ot this.



        • 1. Re: Script to Modify a Record Entry

          Hi.  You could have it even more simple if you want:  Simply have the field formatted as a checkbox set with a value list with custom value 1:  see screenshots.  Then your users simply click the checkbox to authorise it or unclick it to de-authorise it.  Regarding committing the record - all the user needs to do is click outside the field and it will commit it.

          Screen Shot 2016-02-05 at 9.50.17 PM.png

          Screen Shot 2016-02-05 at 9.52.42 PM.png

          Alternately, if you want it to be scripted it could be like this.

          Screen Shot 2016-02-05 at 9.56.14 PM.png

          HTH - Chris

          • 2. Re: Script to Modify a Record Entry



            exactly what I was after, I hadn't figured out I could just type "1" into the calculation box to get it to just set 1!


            Thanks for the assist, its now working as I need it,