Multi-Update - How to return false but green success message?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
konfuzion
User
Posts: 378

Multi-Update - How to return false but green success message?

Post by konfuzion »

I want to use Multi-Update to execute my custom sql statement
but I don't want to use the multi-update function itself, so I cancel it before it executes the multi-update.

Currently I have it to return false but I still want a green toast message showing that my sql statement was successfully executed.
How can I modify it?

// Row Updating event
function Row_Updating($rsold, &$rsnew)
{
    // Enter your code here

    if ($this->CurrentAction == "update") {
        // ...
        $sql = "INSERT INTO other_Table (field1, field2, field3) VALUES ('...', '...', '...');"
	ExecuteScalar($sql);

        return false;
    }


    // To cancel, set return value to false
    return true;
}

mobhar
User
Posts: 11660

Post by mobhar »

Are you sure you want to use ExecuteScalar instead of ExecuteStatement?


konfuzion
User
Posts: 378

Post by konfuzion »

Looks like ExecuteStatement is more appropriate here


konfuzion
User
Posts: 378

Post by konfuzion »

I got it to show green message with:

$this->setSuccessMessage("Success!");

but the page is just stuck in multi-page (internally it still thinks it failed) and doesn't exit back to previous list page


mobhar
User
Posts: 11660

Post by mobhar »

What will be happened if you use the built-in Multi-Update functionality?


konfuzion
User
Posts: 378

Post by konfuzion »

I have fields that are checkmarked but I don't want to save the changes.

I will try using "unset(rsnew*)" to see if I can return true and not save the changes

I'm using Multi-Update to trigger some actions, a for..loop through key-m to insert the selected records to another table.


mobhar
User
Posts: 11660

Post by mobhar »

konfuzion wrote:

I have fields that are checkmarked but I don't want to save the changes.

It doesn't matter actually if you don't want to save the changes. You may then re-update again in Row_Updated server event from new values to the old values, so that the Multi-Update as if it had not happened.


konfuzion
User
Posts: 378

Post by konfuzion »

unset(rsnew*) seems to work, it's not affecting the db fields after successful multi-update and exits back to list. I will use this for now.


Post Reply