This topic is locked
[SOLVED]

 How do we Insert values from one Query into a different table?

4/14/2014 7:38:05 AM
PHPRunner General questions
A
Anapolis author

A week ago I had created a Button on a list page for a table with 4 fields. According to your sugestion, Sergey, I wanted to store the to, subject, and body of emails and then mail them later.
I created something with the Custom Buttons function that worked. If there were 7 records whose date fields matched the query it would retrieve the rows and insert text into 3 fields in another table. The fields stored my "false email" before it was to be sent.
Since that one day where it worked flawlessly time after time I cannot reproduce that success. One day it worked. The next day it did not.
I tried changing the code and on an on. Still no success.
And one of the things that confuses me is that you give an example of NOT having any code in the Before Tab -- my former working example used the standard default code in the Before Tab .... since then I have tried this with or without code in the Before tab.
When is code used in the Before Tab for a Button and when is it not?



To update multiple records on the List page at the same time you can create new button Update selected, then choose records on the List page and click the Update selected button.
yellowbulbNote: Change the values listed in red to match your specific needs.

  1. Proceed to the Visual Editor page.
  2. Create the custom button Update selected and add the following code
    to the Server tab:
    global $dal;
    while ( $data = $button->getNextSelectedRecord() ) {
    // set ReportsTo field to 'Bob Smith'
    $sql = "Update employees set ReportsTo='Bob Smith' where KeyField=".$data["KeyField"];
    CustomQuery($sql);
    }
    $result["txt"] = "Records were updated.";
    and to the Client After tab:
    var message = result["txt"];
    ctrl.setMessage(message);
    The Client Before tab should be blank (delete sample code there if any).

Sergey Kornilov admin 4/14/2014

Before tab contains Javascript code to be executed before the server part. This part code is optional. In fact all three tabs are optional, you can have a button on the page that doesn't have any code specified and doesn't do anything.

A
Anapolis author 4/15/2014



Before tab contains Javascript code to be executed before the server part. This part code is optional. In fact all three tabs are optional, you can have a button on the page that doesn't have any code specified and doesn't do anything.


And apparently I have been quite successful: I have got a button that specifies code but doesn't do anything either. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=74563&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
I will take another shot at this today. Besides the events php and the buttonhandler php is there a critical js file or files that are rewritten, modified, and must upload or re-upload when a button is created or modified in the Before, Server, or after tab?
In other words, are there dependencies on other files outside of the buttonhandler and specific page Events.php that might activate or deactivate and should be uploading to the server as Button code is changed from one build to the next?
Thank you!

A
Anapolis author 4/16/2014

I have been making Javascript action buttons since PHPRunner 5.2. Not a problem.

Something has changed since PHPRunner 7.1 for me.
In my case some buttons I just made worked for one day. Kicking off some PHP functions in the Events code.

After uploading another build at the end of the day they stopped working and I cannot get them or any other button I create to fire the Events code properly. The buttons give their "Before" messages but now do not finish the "job". They reference the name of the function correctly.
The same code when put into other parts of the Events file for that view work just fine.
The same code when put into an "external" script in the Output folder and linked to by "a href" also works perfectly.
But the typical Javascript button method created with the Visual editor will not initiate that same code wrapped in a button function.
This is why I have asked about the dependencies, all the js scripts needed to be refreshed or newly uploaded to make a Javascript button work as I am used to.
[size="4"]In the meantime I am also going to investigate if the Ad Block Plus installed on my Firefox browser is "secretly" blocking the kind of Javascript actions that PHPRunner is generating.[/size]

Sergey Kornilov admin 4/16/2014
A
Anapolis author 4/16/2014



Check for Javascript or PHP errors in your code:

http://xlinesoft.com/blog/2012/05/16/troubleshooting-custom-buttons-in-phprunner-and-asprunnerpro-applications/


Sergey, thank you VERY much! The Print SQL queries tip I will be using all the time now!