New call-to-action
Results 1 to 1 of 1

Thread: Script for end user to delete user created Queries.

  1. #1
    Real Name
    Paul Verboom
    Join Date
    Apr 2006
    Halifax, Nova Scotia, Canada

    Default Script for end user to delete user created Queries.

    From the Query by Form, Query Genie and Query by Expression dialogs the end user can save the queries they create. To delete these queries one must go to the Operations tab on the Control Panel. This is a issue if you are using the runtime or wish to restrict users access to the control panel.

    This is where the following script comes in. Run it from a button on a form or add it to the Script Favorites List on the Scripts menu option. It will give the end user an easy way to delete unneeded saved Queries that may be cluttering up the the list they see when they retrieve Queries.

    'Date Created: 03-Apr-2014 12:41:37 PM
    'Last Updated: 03-Apr-2014 03:10:05 PM
    'Created By  : Paul Verboom
    'Updated By  : Paul Verboom
    'Script to delete selected Queries defined for table of set 
    'current form or browse is defined for
    'xBasic commands used
    'A5_get_operations("Query","b-patients")                   ---> Returns a list of operations
    'object_operation("query","needs review","","delete")  ---> Deletes named Query
    'Object command came from following MsgBoard Post
    'Title for all messages 
    DIM DialogTtl as C = "Delete User Queries (zQueryDelete)"
    '// Verify Script is run from a form or browse --
    DIM RunFromFB as L = .F.
    IF is_object(topparent.this) THEN                            'is top parent valid, no if script run in editor
        IF topparent.Class() = "form" .or. topparent.class() = "browse" THEN
            RunFromFB = .T.
        END IF
    END IF
    IF .not. RunFromFB                                            'Not run from form or browse error out
        error_generate("Script Must be run from From or Browse")
    end if    
    '// Get the current table of set --
    DIM Ptr as P                                                'Only Queries for current form or browse can
    DIm FileName as C                                            ' be deleted
    Ptr = set.current()                                            'Find out what the name of that form or browse is
    FileName = Ptr.filename_get()
    If isnull(FileName)
        Ptr = topparent.Table_Get()
        FileName = Ptr.filename_get()
    end if
    If isnull(FileName)
        error_generate("Unable to determine current Set or Table")
    end if
    '// Put up Dialog to select Queries to delete --
    DIM QueryList as C                                            'Get list of Queries for this Table/Set
    QueryList = A5_get_operations("Query",FileName)                'List is used dirrectly by Dialog no arrays needed
    IF isnull(QueryList)
        error_generate("No User defined Queries for this Screen")
    end if
    DIM Result as C                                                'Result from Dialog must be Proceed to do delete
    DIM QuerySelected as C                                        'List of entries selected by user
    Dialog =<<%dlg%
    {wrap=40}Select the user defined Queries to delete.;
    <*15&Proceed!Proceed> <15&Cancel!CANCEL>
    Result = ui_dlg_box(DialogTtl,Dialog)                        'present Dialog
    if Result <>"Proceed" then                                    'do we proceed
    end if
    '// Delete the selected Queries --
    DIM Query
    for each Query in QuerySelected                                'Go through each query in list to delete
        '! for debugging
        '!ui_msg_box("About to delete",Query)
    Last edited by pboomwork; 04-04-2014 at 06:42 AM. Reason: Corrections to explanation text

Similar Threads

  1. Track user generated queries
    By Al Buchholz in forum Archived Wishlist
    Replies: 4
    Last Post: 05-09-2011, 03:53 PM
  2. Script to create a report turns into a delete script when a different user is logged
    By werder101010 in forum Alpha Five Version 10 - Desktop Applications
    Replies: 3
    Last Post: 10-27-2010, 01:58 PM
  3. Utilizing User Created Reports
    By MGrasso in forum QReportBuilder
    Replies: 1
    Last Post: 05-16-2009, 12:00 PM
  4. User-entered dates within Queries
    By Christine Fenson in forum Alpha Five Version 1
    Replies: 1
    Last Post: 04-26-2000, 11:57 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts