Sigh I just realised that I am not specifying a record to update in that 
code... of course that won't work...

On Tuesday, 9 September 2014 23:30:46 UTC+10, Anthony wrote:
>
> You've got a redirect right before the update code, so it will never get 
> to execute that code.
>
> Also, your two tables include a field with the same name 
> ("business_name"), so putting them both in SQLFORM.factory won't work 
> properly.
>
> Anthony
>
> On Tuesday, September 9, 2014 9:10:50 AM UTC-4, Greg Vaughan wrote:
>>
>> I am trying to do a combined update and insert using SQLFORM.factory with 
>> some redirects for good measure.
>>
>> Everything works fine except the update which fails to alter the record 
>> in question.
>>
>> @auth.requires_login()
>> def remote_check():
>>     j_id=request.args[0]
>>     for row in db(db.job_requests.id==j_id).select(db.job_requests.
>> business_name, db.job_requests.cta, db.job_requests.spoke_to, db.
>> job_requests.job_result, db.job_requests.job_note):
>>         bus = row.business_name
>>         contact = row.spoke_to
>>         cta = row.cta
>>         jn = row.job_note
>>         jr = row.job_result
>>         for row in db(db.clients.id==row.business_name).select(db.clients
>> .id, db.clients.phone):
>>             c_id=str(row.id)
>>             phone=row.phone
>>     address = get_client_address(c_id)
>>     db.job_requests.id.readable=False
>>     db.job_requests.business_name.default=c_id
>>     db.job_requests.business_name.writable=False
>>     db.job_requests.sr_number.writable=False
>>     db.job_requests.sr_number.readable=False
>>     db.job_requests.cta.default=cta
>>     db.job_requests.cta.writable=False
>>     db.job_requests.send_via.writable=False
>>     db.job_requests.send_via.readable=False
>>     db.job_requests.email_to.writable=False
>>     db.job_requests.email_to.readable=False
>>     db.job_requests.fax_to.writable=False
>>     db.job_requests.fax_to.readable=False
>>     db.job_requests.snd_other.writable=False
>>     db.job_requests.snd_other.readable=False
>>     db.job_requests.spoke_to.default=contact
>>     db.job_requests.spoke_to.writable=False
>>     db.job_requests.job_result.default=jr
>>     db.job_requests.job_note.default=jn
>>     db.job_requests.job_note.writable=False
>>     db.tech_notes.business_name.default=c_id
>>     db.tech_notes.business_name.writable=False
>>     form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name=
>> 'remote_check')
>>     if form.process().accepted:
>>         session.flash = 'Job Updated'
>>         db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
>>         redirect(URL('ops', 'tech_main_page'))
>>         if form.vars.job_result=='Completed':
>>             db.job_requests.update(**db.job_requests._filter_fields(form.
>> vars))
>>             redirect(URL('ops', 'tech_main_page'))
>>         else:
>>             redirect(URL('ops', 'maintenance_customer_service_request'))
>>     elif form.errors:
>>         response.flash = 'Form has errors'
>>     return dict(form=form,phone=phone,address=address,
>> left_sidebar_enabled=True,right_sidebar_enabled=True)
>>
>> Any hints please?
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to