1 Reply Latest reply on Mar 24, 2011 8:32 AM by KirinIchiban

    Script Go To Related Record with OR operator?

    KirinIchiban

      Title

      Script Go To Related Record with OR operator?

      Post

      Hello, I am pretty much a newbie to FMP, using FMP 11
      I kind of figured out the go to related record script...
      however, my situation is : I have 3 fields that contain account name in my CustomersTable; CreatedBy (autoenter), CurrentSalesRep (which I assign an account name to a customer), and CurrentUser (a calc field with Get (accountname)).
      Right now I have a self join on the relationships graph where CurrentUser in CustomerTable is related to CurrentSalesRep in CustomersTable2 (same table but self joined). When I run the go to related record script, it works fine, and shows shows me all customers assigned with the currently logged in user.
      However, when I have my SalesReps accounts create new customers, they are not assigned to an actual account name yet, so CurrentSalesRep is empty, what I really want the go to related record script to do for me is to use both CreatedBy and CurrentSalesRep fields to see if either contain Get (AccountName) as true, and then go to all records that have either CreatedBy as the current account name, or CurrentSalesRep has current account name.
      I tried another way with using enter find mode, and set field, but again, I can't seem to add an OR operator to include both fields, or when I try to do the expand found set step in the script, I can't seem to figure it out...

      Basically, I have privilege sets for SalesRep accounts and when they log in, I want them to be working from a found set that is related to by either CreatedBy or CurrentSalesRep only, I don't want them to see other SalesReps customers, and I don't want them to have to search through a whole bunch of "no access" records.

      Please help. If you can show me a better logic for me to accomplish what I'm asking for then please tell me also.

      Thank you

        • 1. Re: Script Go To Related Record with OR operator?
          KirinIchiban

          I finally found another post that is directly related, and I thank you PhilModJunk. http://forums.filemaker.com/posts/a57a47704b 

          Since I am practically a total newbie, I still had a problem with writing the calculation for Set Field, basically, had to pick the field from "specify" then ok, then click on calculation to write the calculation. Also it helped to show all script steps by name instead of category. Anywhere here is the final result which I am quite satisfied with for now.

          Enter Find Mode []

          Set Field [CustomerTable::CreatedBy ; Get ( AccountName ) ]

          New Record/RequestSet Field [CustomerTable::CurrentSalesRep ; Get ( AccountName ) ]

          Set Error Capture [on]

          Perform Find []