4 Replies Latest reply on Oct 4, 2014 7:42 AM by mnelsons

    Script calculation must be text - I need it to be number?

    mnelsons

      Title

      Script calculation must be text - I need it to be number?

      Post

      I've done this in a previous release where I wanted to take a company_ID # and set a variable and then insert into a new record on a different layout.   Regardless how hard I try I can't seem to make my calculation in this script to return a number so it's not working at all.

      I know this is rookie mistake but hey I am a rookie.

      Any advice would be appreciated.

      Thanks,

      Mark

        • 1. Re: Script calculation must be text - I need it to be number?
          philmodjunk

          Variable data typing is determined by the type of calculation you define not by any option you select in the specify calculation dialog. So if your are referring to the "text" designation at the bottom of the specify calculation dialog, you can ignore it.

          Even if your calculation produces a text result (say you use the & operator), it will still be treated as a number if you then assign the value to a number field.

          • 2. Re: Script calculation must be text - I need it to be number?
            mnelsons

            Thanks that's comforting that I can ignore the information on the bottom.  However I'm using the same script that I've created in version 12 demo and I've purchase the new 13 adv and it's not working.  So maybe it's the technique that I'm applying is not correct in version 13.

            Basically the idea was I'm in a company profile layout and the company_id is number, unique and auto created.  I have a portal view of notes but when I want to create a new note I create a script to say go to layout NOTES - create new record and take the company id from the company layout and insert into the new note.  But it's always blank in version 13.  It worked fine in version 12.

            Any best suggestions?

            Thanks

            • 3. Re: Script calculation must be text - I need it to be number?
              philmodjunk

              There's been no change in this part of Filemaker between 12 and 13.

              Presumably, you are using this type of script:

              Set Variable [$CompanyID ; value: Companies::__pkCompanyID ]
              Go to Layout ["Notes" (Notes)]
              New Record/Request
              Set Field [Notes::_fkCompanyID ; $CompanyID ]
              Go to Layout [ original layout ]

              should work the same in v12 and 13. Should work the same in any version of FileMaker new enough to support variables. (Before variables this still worked if you used a global field.)

              Note: the changes in layout can trip a large number of script triggers on either of the two layouts in use here. You may need to check to see if a trigger controlled script is interfering with the correct execution of your script. (and sometimes I use a different approach that creates a new portal record without changing layouts.)

              • 4. Re: Script calculation must be text - I need it to be number?
                mnelsons

                Thanks - that script was almost what I had except that I had Set Field by Name instead which didn't work.  I knew it was a simple solution but I'm just learning the ropes.