Page 1 of 1

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

Posted: Thu Dec 01, 2022 6:53 pm
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;
}

Re: Multi-Update return false but green success message

Posted: Thu Dec 01, 2022 9:13 pm
by mobhar

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


Re: Multi-Update return false but green success message

Posted: Thu Dec 01, 2022 10:39 pm
by konfuzion

Looks like ExecuteStatement is more appropriate here


Re: Multi-Update return false but green success message

Posted: Thu Dec 01, 2022 10:42 pm
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


Re: Multi-Update return false but green success message

Posted: Fri Dec 02, 2022 8:04 am
by mobhar

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


Re: Multi-Update return false but green success message

Posted: Fri Dec 02, 2022 8:47 am
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.


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

Posted: Fri Dec 02, 2022 9:44 am
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.


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

Posted: Fri Dec 02, 2022 11:07 am
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.