Working on xbasic script to conditionally update a date field based on another field in the table.
Currently getting an error with the ajax callback (but I'm sure there are other errors present) stating that "List not found:Contributions" though this is the code generated by Alpha and I have verified that the spelling and capitalization of the list name is correct.
I would highly appreciate another set of eyes to help me sort out my issues. I'm certain I've got something amiss, particularly in the realm of e.datasubmitted (still don't quite understand it). Xbasic newbie here (and great thanks to madtowng for getting me to my current knowledge level!).
Here's my Javascript function (got the code from a forum post I found here):
And my xbasic:
Currently getting an error with the ajax callback (but I'm sure there are other errors present) stating that "List not found:Contributions" though this is the code generated by Alpha and I have verified that the spelling and capitalization of the list name is correct.
I would highly appreciate another set of eyes to help me sort out my issues. I'm certain I've got something amiss, particularly in the realm of e.datasubmitted (still don't quite understand it). Xbasic newbie here (and great thanks to madtowng for getting me to my current knowledge level!).
Here's my Javascript function (got the code from a forum post I found here):
Code:
var id_number = {Dialog.object}.getValue('list::Contributions::id_number'); {dialog.object}.ajaxCallback('','','updatePledge','','_id_number='+id_number);
Code:
function updatePledge as c (e as p) debug(1) 'Dim the SQL connection variables dim cn as SQL::Connection dim ti as SQL::TableInfo dim sqlUpdate as c dim argsUpdate as SQL::Arguments dim itsOpen as L dim sqlCode as p dim itWorked as L dim donorArray[0] as p dim dothething as L 'Test for open connection itsOpen=cn.open("::name::donor sql") sqlCode.getData = <<%txt% SELECT gift_amount,date_posted,type_contr,depositno,id_number,frequency FROM pledgers WHERE date_posted = :DATE AND depositno = :DEPOSITNUMBER AND id_number = :id_number ORDER BY dateposted %txt% 'Dim the SQL query variables dim id_number as n id_number = e._id_number dim depositno as c depositno = e.datasubmitted.depositno dim date_posted as t date_posted = time("yyyy-MM-dd",convert_type(e.datasubmitted.date,"D")) itWorked = cn.ToPropertyArray(sqlCode.getData,argsUpdate,donorArray) for each donor in donorArray 'Set the arguments for the SQL update query argsUpdate.set("date_posted",time("yyyy-MM-dd",convert_type(e.datasubmitted.date,"D"))) argsUpdate.set("depositno",e.datasubmitted.depositno) argsUpdate.set("donorid",e._id_number) if *any(donor.type_contr,"Pledge") then dim frequencydays as n frequencydays = if(donor.frequency = "Monthly",31,if(donor.frequency= "Quarterly",91,if(donor.frequency = "Every 2 Mnt",61,if(donor.frequency = "Bi-annualy",183,if(donor.frequency="Annually",365,""))))) dim updatedpledgedate as t updatedpledgedate = *add_days(dateposted,frequencydays) 'Define the SQL UPDATE query sqlUpdate = "UPDATE pledgers SET NextPledgeDue = "+updatedpledgedate+" WHERE ID_number = :id_number" dothething = cn.Execute(sqlUpdate,argsUpdate) if .not. dothething then ui_msg_box("Error",cn.CallResult.text) else end if end if next cn.close(cn) updatePledge ="" end function
Comment