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

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.


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;
    }
}

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 :frowning:

[QUOTE=itsme3;22269]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 :([/QUOTE]

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

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

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.

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

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 :slight_smile:

thanks in advanced

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.

seems logic and perfect, will try that, hopefully will success

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