Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • aburningflame
    replied
    Re: Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    Originally posted by TheSmitchell View Post
    The SQL method works - I've done this a few times. But doing it in the query means your server is doing all the work calculating the outcome instead of the client's web browser.
    The calculation performed on the server side is a very negligible server hit. The MySQL/SQL Server engines are perfectly capable of doing this calculation for thousands of records in milliseconds - not a big deal.

    Of course, maybe this is a calculation that is best left to be done server-side altogether, since you reeeeeally want to prevent people from editing records older than a certain date. If that's the case, server-side validation may be in order to prevent the user from editing the fields & submitting them through other means - eg, FireBug.
    +1 - If its an internal app I wouldnt worry about it too much. If you are concerned some employee might be using Firebug to edit stuff they are not allowed to then override the CanUpdateRecord method - just to be safe I recommend adding the code into CanUpdateRecord anyways to prevent unauthorized edits.

    Code:
    'Set to cancel right away - This will REJECT all updates UNLESS the condition is met 
    'Example: (If you cant properly load whether or not it is editable - you should error out and not let them edit it)
    
    Result.Cancel=.t.
    Result.ErrorHTML="You cannot edit this record - it has been 7 days since the records creation"
    
    'code to calculate editable
    
    IF editable THEN
      Result.Cancel=.f.
      Result.ErrorHTML=""
    END IF

    Leave a comment:


  • TheSmitchell
    replied
    Re: Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    The SQL method works - I've done this a few times. But doing it in the query means your server is doing all the work calculating the outcome instead of the client's web browser. Of course, maybe this is a calculation that is best left to be done server-side altogether, since you reeeeeally want to prevent people from editing records older than a certain date. If that's the case, server-side validation may be in order to prevent the user from editing the fields & submitting them through other means - eg, FireBug.

    Leave a comment:


  • aburningflame
    replied
    Re: Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    +1 for chris's answer - We use this exact same method. I believe Chris's looks like SQL server.
    We dont use an IF to return 'yes','no', just let MySQL/SQL return a boolean - In chris's example take away the IF and the YES,NO.
    Below will return 1 if it is editable and 0 if it is not (logical values).

    Put the editable column in your grid and hide it.
    Enable Expression: editable=1

    In MYSQL it would look something like: SELECT tablename.*, DATEDIFF(CURDATE(),created_on)<7 as editable FROM tablename
    Are they allowed to edit it on the 7th day? If yes, change the above to <=7

    Leave a comment:


  • christappan
    replied
    Re: Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    Sarah's solution will work, but as another option, I've started putting things like this in the query itself sometimes. In your SELECT statement, include a column something like this:

    SELECT *, IF(DATECREATED > AddDaysToDate(CurrentDATE(), -7),'Yes','No') AS Editable
    FROM ...

    Then put the "Editable" column in your grid/detail view/whatever, hide it, and the enable expression in the key fields to Editable="Yes"

    Leave a comment:


  • TheSmitchell
    replied
    Re: Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    You want to compare dates, so you'll need to do javascript date math
    http://stackoverflow.com/questions/3...to-todays-date
    Code:
    var sevenDaysAgo = function ()
    {
        var d = new Date();
        // getDate: gets the date in days
        // setDate: sets the date in days (so you can add or sub any number of days here)
        d.setDate(d.getDate() - 7)
    
        return d;
    }
    You'll probably also need to parse your "DATECREATED" value - I think Alpha gives you a string when you call {grid.object}.getValue('G',rowNum,'DATECREATED')
    Code:
    var getDateCreated = function (rowNum)
    {
        var c = {grid.object}.getValue('G',rowNum,'DATECREATED');
    
        // If your DATECREATED is in the format MM/dd/YYYY...
        // split: changes c from "MM/dd/YYYY" into an array ["MM","dd","YYYY"]
        // EG: "01/12/1985" becomes ["01","12","1985"]
        c = c.split("/"); 
    
        // Months in javascript are zero indexed. EG, January = 0, Feburary = 1, and so on and so fourth
        // The Date constructor: Date(Year,Month,Day)
        var asD = new Date(c[2],c[0]-1,c[1]);
    
        return asD;
    }
    Putting it all together
    Code:
    var canEdit = function (rowNum)
    {
        var created = getDateCreated(rowNum);
        var cutOff = sevenDaysAgo();
    
        return created >= cutoff;
    }
    ---
    Sarah

    Leave a comment:


  • Need to limit entry in field ONLY IF original entry is not older than 7 days. Help Please!

    I have several fields (character) that should only be modified within seven days of their original creation (ie. new record).

    I want to create an ENABLE/DISABLE client side condition based on the date of another date field (ie. datecreated).

    Puesdo code would be as:

    if datecreated is within the last week, allow (ie. enable) editing to the LASTNAME field.

    I've had some success with code similar to:

    DATECREATED < DATE() - but this is always true.

    This is what I am trying to do:

    DATECREATED > ( DATE() -7 )

    This never evaluates to true. The -7 is the killer. Seems logical but Javascript doesn't like it.

    If you can help with some tested code, it would really be appreciated.
Working...
X