3 Replies Latest reply on Mar 15, 2011 10:46 AM by philmodjunk

    If Statement help

    bookalaka_1

      Title

      If Statement help

      Post

      This is my script I need help on the "If" portion at the end

      Set Variable[ItemCode:Value:Log_LineItems::Code_Calc_PK]

      Set Field[Log_Lineitems::Updated:" "]

      Select Window[Name:"PriceBook_Dev"]

      Enter Find Mode[]

      Set Error Capture [on]

      Perform Find

      if[ not Get(found count)]

      Show Custom Dialogue ["No record found would you like to create a new record?]

      End if

      Here is where I am lost..I would like option to create a new record and use  Value:Log_LineItems::Code_Calc_PK as the new code for

      PriceBook_Dev:Code_PB_sp. I don't understand how to assign scripts to the custom dialogue  buttons and finish the if or maybe should be case.

      Thank you

        • 1. Re: If Statement help
          KevinPfeiffer

          Check the Help section for custom dialogues. You need Get(LastMessageChoice).

          • 2. Re: If Statement help
            bookalaka_1

            It took me a quite bit of time to tweak it but thats the fun of Filemaker discovery. I would love to have  when the record isn't found and my script ask"would you like to create a new record" that a "Set field command could be used putting the code from my A table over to my B table where the record is being created. unfortunately however i have been unsuccessful.  I greatly appreciate the feedback. Here is my script in full. Thank you

            Set Variable[ItemCode:Value:Log_LineItems::Code_Calc_PK]
            Select Window[Name:"PriceBook_Dev"]
            Set Field[Log_Lineitems::Updated:" "]
            Enter Find Mode[]
            Set Field[Pricebook::Code_PB_sp;$itemcode]
            Set Error Capture [off]
            Perform Find
            if[ not Get(found count)]=0
            Show Custom Dialog["Create New Message"; "Would you like to create a new record?]
            if[Get(LastMessageChoice)=1
            PerformScript("PBdev_CreateNewRecord"]
            Set Variable[$itemcode;Value:Log_Lineitems::code_calc_pk] (This doesn't seem to work)
            set Field{PriceBook;;Code_PB_sp;$Itemcode] (This doesn't seem to work)
            Else
            Show all records
            Halt script
            End if
            End If
            • 3. Re: If Statement help
              philmodjunk

              With Filemaker scripts you have to keep track of what layout is current at each point of the script. The current layout, in turn identifies a specific table occurrence (Show Records From in layout setup...) and that, in turn, identifies the relationships currently in force.

              In your script, if you are going to use data from the current record on layout A to update a record in Layout B, you either need a relationship that correctly links the two records or you go to Layout A, put the value in a variable, then switch to Layout B where you can use Set Field to put that value into a field of the current record on that layout. (This all assumes that the two layouts refer to different table occurrences.)