7 Replies Latest reply on Jan 27, 2011 10:54 AM by Jim1

    Exporting fields based on conditional?

    Jim1

      Title

      Exporting fields based on conditional?

      Post

      I'm not sure if this can be done, but is is possible to write a script that will export fields only if other fields are selected? 

      Example: Medical: checked "Yes"

      Export Med Benefits

      I know it can be done if I write if statements and change the export for each statement, but I'm hoping to write it all in one (if field = "yes", export field)

      I'm not sure if I'm making sense, but thanks for any help you can provide!

      Jim

        • 1. Re: Exporting fields based on conditional?
          philmodjunk

          I think you need to provide a more detailed example of what you are trying to do here. Exporting from a single field from a single record? Multiple records? Multiple fields?

          • 2. Re: Exporting fields based on conditional?
            Jim1

            I'm sorry I'm not making sense.  Basically, I created a script that will run a search and export records with specified fields (without dialog).  I have a database I use as a template to create other databases.  Some databases I create won't use all the fields in the template and I have fields that I check as yes or no which dictates the fields being used.  When I run the script, I'd like to be able to look at the yes/no fields and if the fields are set to no, they aren't included in the export.

            Example:

            LifeInsurance = Yes

            Export Records (fields: name, date of birth, Life insurance amount taken)

            LifeInsurance = No

            Export Records (fields: name, date of birth)

            Right now, I have a bunch of "else if" statements and each "export records" statement separately.  Currently:

            If (LifeInsurannce = "Yes"

            Export records (various fields including life)

            Else if (Life Insurance = "No"

            Export records (various fields without life)

            and this repeats for many different fields.

            I'd like to write something similar to this:

            If (LifeInsurance = "Yes"; export records field: Life insurance amount taken; "") 

            Hopefully this would keep it all on one export line.

            I'm probably still not making sense, but maybe this helps a little.

            • 3. Re: Exporting fields based on conditional?
              philmodjunk

              I can't think of a better alternative, but do wonder as to why you need to create so many separate databases. That seems an unusual way of doing things here.

              • 4. Re: Exporting fields based on conditional?
                Jim1

                Thanks Phil.  I'm sure there is a better, more streamlined way to do this without so many databases, but I'm still pretty new at all of it and just don't know how.  Unfortunately, I don't have the time that's needed to really research it and do it right.  Thanks again.

                • 5. Re: Exporting fields based on conditional?
                  Sorbsbuster

                  Why not use the same template over and over, but just ignore the fields that aren't applicable (the ones you wouldn't choose to export) in the new copy?

                  Why not add one more field that defines the difference between each of the versions you are creating, and save all the records for every version in the same file, but tag each one with their 'Type' (ie the type of the database you would have stored them in, if you'd exported, etc)?

                  • 6. Re: Exporting fields based on conditional?
                    philmodjunk

                    Unfortunately, I don't have the time that's needed to really research it and do it right.

                    Careful, not taking the time to "do it right" may cost you far more time in the long run.

                    • 7. Re: Exporting fields based on conditional?
                      Jim1

                      I'll work on this.  Thank you both for your help.