Announcement

Collapse
No announcement yet.

Reference number for an application records

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

  • Reference number for an application records

    hello guys,

    anybody passed with an application that he needs to add a reference number to the form entry? so later on can be searched with? i want it to be randomized, better if for example like EXD-(A_Number_here)...

    Also I'm trying to change this default message "Required field" which shows for validation of fields to something else but i couldn't find it where to do that

    anybody had these?

    Mike

  • #2
    I don't quite understand what you want, but I assume that you need a field that numbers itself. Then you can use a sequence for that. If the key needs to be randomized you could try a guid as a value. See code snippet. The errormessage can be changed in application -> messages.

    Code:
    function guid(){
        if (function_exists('com_create_guid')){
            return com_create_guid();
        }else{
            mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
            $charid = strtoupper(md5(uniqid(rand(), true)));
            $hyphen = chr(45);// "-"
            $uuid = chr(123)// "{"
                    .substr($charid, 0, 8).$hyphen
                    .substr($charid, 8, 4).$hyphen
                    .substr($charid,12, 4).$hyphen
                    .substr($charid,16, 4).$hyphen
                    .substr($charid,20,12)
                    .chr(125);// "}"
            return $uuid;
        }
    }
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      oh, i will try that, it is a good idea,

      i just want a user to fill in a form and when submitting it, he gets a reference number to check his request status later...

      it can be sequential, no problem, but most important i want to form (when submitted ) to send the data to the database, and displays the reference number, so i am still trying to get this point done

      Comment


      • #4
        Originally posted by itsme3 View Post
        oh, i will try that, it is a good idea,

        i just want a user to fill in a form and when submitting it, he gets a reference number to check his request status later...

        it can be sequential, no problem, but most important i want to form (when submitted ) to send the data to the database, and displays the reference number, so i am still trying to get this point done
        That's not a real problem. If you have generated the key you can use that one to display. If you use a autosequence you can use insert_id() mysql function:

        http://be2.php.net/mysql_insert_id
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          hi again Albert,
          since a while i am trying to get this done but couldn't know what you mean by sequence or/and autosequence
          can you give me some hints like, create new field as INT in sc and choose this and that
          this looks complicated for me, still

          Comment


          • #6
            YOu can generate a unique key when you insert a record. On database level your key needs to be of type integer and you have to specify that you are using it as a sequence. Then Mysql will generate a next sequence number on every insert.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              Yes albert, I did that, created new field as INT and added it to the form in SC under label: Reference, it is AI (AutoIncrement) but, how i can make it appear after the form is submitted? not into the form itself as a field...??

              for example, user fills the data in this form, then a page or message that says: thank you for your submission, your reference is: XXX

              Comment


              • #8
                hi again here Albert,

                I'm still not able to get this done

                so i want after the form is submitted, a form of the field itself (the auto increment one: reference) to be shown to the user, and possibly if sent to his email that would be great... but when submitting the form how to make it show? is it on some event? put code?

                sorry for my silly questions, i am really new to this and trying to get some useful applications


                thanks in advanced

                Comment


                • #9
                  In the onafterinsert you can retrieve the id as stated above. Then you can send an email using this reference. If you want to show the value on the screen for your user then create a control form and put one field on it. Set it default by a global value, i.e. [glob_lastinsertid]. In the onafterinsert you start with a call to sc_commit. then retrieve the last insert id, send email, fill the global variable with the lastinsertid and do a sc_redir to your control application.
                  Albert Drent
                  aducom software netherlands
                  scriptcase partner, reseller, support and (turn-key) development
                  www.scriptcase.eu / www.scriptcase.nl

                  Comment


                  • #10
                    seems logic and perfect, will try that, hopefully will success

                    thanks a lot as always dear, appreciated your continuous support and help

                    Comment

                    Working...
                    X