Page 1 of 1

How to create _FILE and FORM fields in OBJE record

Posted: 17 Jan 2012 18:14
by TSG
If I create a new OBJE record from within a plugin I either get duplicate FORM and _FILE fields or blanks.

e.g. If I do:

local objFILE=fhCreateItem('TITL',objOBJE) fhSetValueAsText(objFILE, 'mytestfile.jpg')

... the record is created with 2 FILEs - one blank and one with the test file in it.

I thought it might be because the FILE and FORM were mandatory and so pre-set so tried this instead:

local objFILE=fhGetItemPtr(objOBJE,'_FILE')
fhSetValueAsText(objFILE, 'mytestfile.jpg')

That gets rid of the duplicate FILE but doesn't set the test file at all.

I even tried deleting it and re-creating or re-setting it in the code but no joy.

Is this a bug or am I doing something wrong?

ID:5822

How to create _FILE and FORM fields in OBJE record

Posted: 17 Jan 2012 18:48
by Jane
You need the 'navigation' data reference for the get eg:

local objFILE=fhGetItemPtr(objOBJE,'~._FILE')

I would also check if objFile is nil and if it is then create it.

Also make sure you have Beta 5.0.4 and not an earlier one, as I thought the latest version did not add title and filem but I have not double checked it.

How to create _FILE and FORM fields in OBJE record

Posted: 17 Jan 2012 19:20
by TSG
The ~ solved it - many thanks :)