I too am new to Servoy. I am developing a database in which I need to import a bulk amount of images. The filename for the image relates to an employee. (e.g. employee has an id of 001 and the image file which relates to the employee is 001_employee.tif)
So I need a script which does the bulk import but checks the filename against the employee_id field and relates them accordingly.
You can get the string position of the underline character to splice out the key and place it into your servoy column.
//Returns the position of the string to seach for from a certain start position and occurrence
var pos = utils.stringPosition('This is a test','s',1,1)//returns 4 for the sample
//Returns the number of characters, starting from the left
utils.stringLeft('this is a test',6);//returns 'this i'
Thank you for the quick response. One more question. I have been searching the forums for tif support. Does Servoy offer tif support or will I need to convert the images to a different format before I upload them? Thanks again.
The import script works fine. I am having trouble modifying it to suit my needs.
For simplicity i made the image file relate to a specific empid. (e.g. image file 123 relates directly to empid 123)
What I need the import script to do is check the image file name against empid and put it into the appropriate signature field. The signature field is in the same table as empid
mparsons:
The import script works fine. I am having trouble modifying it to suit my needs.
For simplicity i made the image file relate to a specific empid. (e.g. image file 123 relates directly to empid 123)
What I need the import script to do is check the image file name against empid and put it into the appropriate signature field. The signature field is in the same table as empid
Thanks again. I appreciate all the help.
I am not sure if I understand your question. From near the end of the method described at the above link you have:
file_name = theFile.getName();
You should then be able to split the name, placing the key in the appropriate column and the rest of the name in the appropriate column. I am not sure what you are trying to compare the image file name against.
Just wanted to update this thread to let you know I got the images imported successfully.
I used the sample code and tweaked it a bit to fit my needs.
Thank you again Rich for the sample code.
First I created a new table in sql, core_hierarchy_tsig, which would hold the images. With the columns id, signature, sig_name. The sig_name column matches the emplid from the table I need to import into, core_hierarchy_sig.
After running the method to import images I went into sql and executed the following query:
UPDATE core_hierarchy_sig
SET core_hierarchy_sig.signature = core_hierarchy_tsig.signature
FROM core_hierarchy_tsig
WHERE core_hierarchy_sig.emplid = core_hierarchy_tsig.sig_name