after update hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bescott53

after update hook

Post by bescott53 » 2017-06-13 00:53

I have tried unsuccessfully with this, any help would be appreciated.

I have a table called wdcd_WDCD, in this table the primary key is SFRefNum. what I am needing to do is when someone updates a record that a check is made against the table, if there are other records with the same OpID then the update that was made is also copied over to those other records. I need the following fields updated, WDCD, ICV, WDCDVALUE, NOTES, LASTEDITEDBY, LASTEDITEDON, CLOSEDATE, SPECFORECASED, SLT, SEB, APPROVAL, SECSPEC, SECSOL.

Hope this makes sense,

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: after update hook

Post by AhmedBR » 2017-06-13 22:08

I usually use something like this:

Code: Select all

sql("update `wdcd_WDCD` set WDCD= {$data['WDCD']}, ICV= {$data['WDCD']} etc.....

        where `OpID ` = {$data['OpID ']}", $eo);
Might not be the most elegant way, but works fine for me. ;)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

bescott53

Re: after update hook

Post by bescott53 » 2017-06-15 07:05

Thanks AhmedBR, I have tried this but when I save a record I get a blank screen, not sure if its connected. It was fine before. I removed and issue still there, any ideas?

bescott53

Re: after update hook

Post by bescott53 » 2017-06-16 14:16

ok, the blank screen is definitely down to adding in the sql to the hook. I moved it to appear after the return TRUE; and all ok, with one exception, it doesnt do what I need, it is not updating the other records? any help on this would really be appreciated

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: after update hook

Post by AhmedBR » 2017-06-17 19:29

When you get a blank screen, use the mouse and select "View Page Source" this will show you what is causing this blank page.
Usually an error in your MYSQL statement.

You did not copy the code as is from here, right?
(the code is just an example to what you should do, you need to complete it, that is remove etc.... and right the other fields and double check the column names as in your database)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

bescott53

Re: after update hook

Post by bescott53 » 2017-06-19 09:26

Thanks for helping Ahmed, I really appreciate it.

here is the error:

<script>
$j(function(){
show_notification({"message":"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' WDCDValue= , Notes= test, LastEditedBy= bescott53, LastEditedOn= 2017-06-16 13:' at line 1<pre>Query:\nUpdate `wdcd.wdcd_WDCD` set WDCD= , WDCDValue= , Notes= test, LastEditedBy= bescott53, LastEditedOn= 2017-06-16 13:38:41, SLTSponsor= Luke Beeson, SEBadged= , , CloseDate_SpecialistForecasted= , ApprovalType= , SecuritySpecialist= , , SecuritySolution= where `OpportunityID ` = <\/pre><i class=\"text-right\">The above info is displayed because you are currently signed in as the super admin. Other users won't see this.<\/i>","class":"danger","dismiss_seconds":7200,"dismiss_days":0,"id":0});
})
</script>



and the actual line is this:

sql("Update `wdcd.wdcd_WDCD` set WDCD= {$data['WDCD']}, WDCDValue= {$data['WDCDValue']}, Notes= {$data['Notes']}, LastEditedBy= {$data['LastEditedBy']}, LastEditedOn= {$data['LastEditedOn']}, SLTSponsor= {$data['SLTSponsor']}, SEBadged= {$data['SEBadged']}, CloseDate_SpecialistForecasted= {$data['CloseDate_SpecialistForecasted']}, ApprovalType= {$data['ApprovalType']}, SecuritySpecialist= {$data['SecuritySpecialist']}, SecuritySolution= {$data['SecuritySolution']} where `OpportunityID ` = {$data['OpportunityID ']}", $eo);

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: after update hook

Post by AhmedBR » 2017-06-19 12:56

I believe the error is in The table name: `wdcd.wdcd_WDCD` should be `wdcd_WDCD` or the correct name of your table. check it out and see if this solves the problem. ;)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

bescott53

Re: after update hook

Post by bescott53 » 2017-06-19 13:15

OK table names is right now (wdcd_WDCD) but still getting error?

<script>
$j(function(){
show_notification({"message":"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' WDCDValue= , Notes= test, LastEditedBy= bescott53, LastEditedOn= 2017-06-15 09:' at line 1<pre>Query:\nUpdate `wdcd_WDCD` set WDCD= , WDCDValue= , Notes= test, LastEditedBy= bescott53, LastEditedOn= 2017-06-15 09:30:09, SLTSponsor= , SEBadged= , , CloseDate_SpecialistForecasted= , ApprovalType= , SecuritySpecialist= , , SecuritySolution= where 'OpportunityID' = OIJ-0876123<\/pre><i class=\"text-right\">The above info is displayed because you are currently signed in as the super admin. Other users won't see this.<\/i>","class":"danger","dismiss_seconds":7200,"dismiss_days":0,"id":0});
})
</script>

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: after update hook

Post by AhmedBR » 2017-06-19 22:12

I can see two possible problems: too many null values, and some results with nothing between comas!

Let´s narrow things down (this is my simple way of solving these kind of problems):

Use JUST the following in your hook (do not forget to double check table and field names in my formula):

Code: Select all

sql("Update `wdcd_WDCD` set  LastEditedOn= {$data['LastEditedOn']} where `OpportunityID` = {$data['OpportunityID']}", $eo);
Does it update correctly?
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

Post Reply