Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By SteveStifler
#815550
Hi guys and girls

How do I simply record an entry using a Dynaform I have created? Do I have to use code to tell it what to do with the fields when the submit button is pressed or can I draw a process for it? or is there a way it just knows to record an entry in PM tables? Nothing fancy, just record an entry.
User avatar
By amosbatto
#815582
If you want to write to a PM Table, you need need to use the executeQuery("INSERT ...") function in a trigger, which is executed after the Dynaform. You PM Table needs to have unique field to identify each record (which is normally called something like "ID"). If you don't want to generate the ID, then set the field to autoincrement when defining the PM Table and you won't have to include the ID field in your INSERT statement. See:
https://wiki.processmaker.com/3.0/PM_Ta ... m_Triggers

If your PM Table is named PMT_PRODUCTS has the fields ID, PRODUCT_NAME, DESCRIPTION, PRICE and AMOUNT, where ID is autoincrement, then you don't have to include ID in your INSERT statement.

Your trigger code would be:
Code: Select all
if (@@productName) {
    //use mysql_real_escape_string() to prevent SQL code injection attacks
    $name = mysql_real_escape_string(@@productName);
    $desc = mysql_real_escape_string(@@description);
    $price = @#price; //convert to float
    $amount = @%amount; //convert to integer
    //char and datetime values need to be enclosed in single quotation marks, but numbers do not:
    $sql = "INSERT INTO PMT_PRODUCTS (PRODUCT_NAME, DESCRIPTION, PRICE, AMOUNT)
        VALUES ('$name', '$desc', $price, $amount)";
    executeQuery($sql);
}
Set this trigger to execute after the Dynaform which contains fields associated with the "productName", "description", "price" and "amount" variables.

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]