Thanks!

On Thursday, June 20, 2013 4:34:23 PM UTC-7, Anthony wrote:
>
> The record ID isn't known until after the insert, so I don't think it can 
> be used in a computed field. Perhaps you could use .after_insert and 
> .after_update callbacks to do this.
>
> Anthony
>
> On Thursday, June 20, 2013 4:55:24 PM UTC-4, greenpoise wrote:
>>
>> db.define_table('series',
>>    Field('seriesnumber',compute=lambda r: '%s%s' (r['id'],r['seriesname'
>> ][0:3]))
>>    Field('seriesname'),
>>    Field('seriesdescription'),
>>    Field('layertype','reference layertype'),
>>    Field('created_by',db.auth_user,default=me,writable=False,readable=
>> False),
>>    Field('created_on','datetime',default=request.now,writable=False,
>> readable=False),
>>    Field('suppliercode','reference supplier'))
>> db.series.seriesnumber.requires = IS_NOT_IN_DB(db,db.series.seriesnumber)
>> db.series.seriesname.requires = IS_NOT_IN_DB(db,db.series.seriesname)
>> db.series.layertype.requires = IS_IN_DB(db,db.layertype.id,
>> '%(layername)s')
>> db.series.suppliercode.requires = IS_IN_DB(db,db.supplier.id,
>> '%(suppliercode)s')
>>
>> Hi there! the code is above. Nothing fancy, I am testing it through the 
>> database administration tool provided by web2py. The record goes in but I 
>> get no value for seriesnumber. 
>>
>> Thanks!
>>
>> Dan
>>
>> On Wednesday, June 19, 2013 11:27:40 AM UTC-7, greenpoise wrote:
>>>
>>> how come this returns null:
>>>
>>>  Field('seriesnumber',compute=lambda r: '%s%s'% 
>>> (r['id'],r['seriesname'][0:3]))
>>>
>>

-- 

--- 
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/groups/opt_out.


Reply via email to