sachinbaan
6th February 2014, 13:13
hi,

I want to display passport size photograph on my session form,

can any one help me.


thanks & regards,
Sachin

bhushanchanda
6th February 2014, 15:47
Hi,

Never tried it but people have done it in Baan4 I guess you can get some ideas. Though, object creation and deletion functions are now depreciated.

Similar thread for Baan 4 (http://www.baanboard.com/baanboard/showthread.php?t=12892)

Also, from the latest Prog Guide:-

On an ERP Enterprise form an image field can be defined which can be bound to a maintable record of a session. This mechanism can be used to show an image which is linked to a specific maintable record. The linked images are stored in a file system based image repository.

Functional Characteristics
Below some functional characteristics of images on forms are described.

On an ERP Enterprise 4GL-form one or more images can be displayed in an area of a fixed size.
The supported image formats are: JPEG, PNG and GIF (no animated GIF).
Image files are stored in a central repository on the application server file system. System administration tools are available to manage this repository (e.g. move to another location).
When multiple application servers are used, the image directory must be located on the master application server. The repository functions will make sure this is transparent for the application.
An image can be dragged from a Web browser window or Windows Explorer window and dropped onto an ERP Enterprise form (when the application has enabled the image control for drop actions).
Images on forms is only supported by the Web UI and not for the Worktop
Authorization
A user can view an image on a form when all of the following conditions are true:

The user must have read permission for the image repository table: ttaad710
The user must have read permission, on the OS level, for the image repository directory which is defined in session "Image parameters (ttaad7100m000)".
A user can change an image on a form (through drag and drop) when all of the following conditions are true:

In the Dynamic Form Editor (DFE), the drag/drop option for the image field must be checked.
In the UI script the function: bind.image() must be called to bind the image to a maintable field.
The current maintable record shown in the session must be editable.
The user must have write permission for the image repository table: ttaad710
The user must have write permission, on the OS level, for the image repository directory which is defined in session "Image parameters (ttaad7100m000)".
Application data model
Images are linked to records in application tables. This link is represented by a GUID and stored in a table field with the domain tcguid. This GUID uniquely identifies an image set. The GUID must be generated by the application and stored in the application table field. A proper place to fill this table field, when it is not yet filled, is in the dal method: before.save.object(). When no DAL is present it should be done from the UI script sections: before.write and before.rewrite.

Image set
An image set is a group of one or more images which belong together. An image set is identified by a GUID. These sets are stored in the image repository. Currently only one image per set can be stored. For future development the image repository is prepared for having more images in an image set

Form design
An image can be added to a form through the DFE. In the DFE choose the menu option: Insert  Image.

4GL UI script
In the UI script the image field, which is defined in the DFE, must be declared as an external field of domain: ttdyf.picture. In order to bind the image field to a maintable record, the function bind.image() must be used.






Sample Code:-Below a part of a 4GL-UI script is shown to illustrate the usage of the image functions. In this example the image is bound to the maintable of the session through the table field bpmdm001.guid. The image is shown in the view area of a multi-occ session. The function enable.save.on.occ.change() must be called to make sure that a possible dropped image is saved before selecting another occurrence in the grid.

table tbpmdm001 |* Employee
extern domain ttdyf.picture image.field |* image form field

after.form.read:
bind.image("image.field", "bpmdm001.guid")
enable.save.on.occ.change()

after.update.db.commit:
if is.image.changed("image.field") then
if check.image.present(bpmd001.guid) then
|Optionally ask user if we should override the current image.
endif
save.image.field("image.field")
endif


choice.recover.set:
after.choice:
discard.changed.image("image.field")

bhushanchanda
7th February 2014, 10:58
Hi,

Tried it and works just fine.

Steps:-

1. Add a field in your table e.g. tcbed002 one field with name e.g tcbed002.guid with domain ttgyf.picture.
2. Make sure you have a folder named $BSE\images on your server with full write permission to all the everyone.
3. Create a simple maintain session with some window type e.g. List Window.
4. In your Dynamic Form Editor under session properties, uncheck Overview Session and just tick details session.
5. In you Dynamic Form Editor, add whatever fields you want to display on your session except tcbed002.guid.
6. Go to specific and add select insert image and give some name to it e.g test.img. Give some width and height based on requirements.
e.g Width = 45 and Height = 6.
7. Save you form and compile the session.

Now, in your session 4GL script, write these lines:-


declaration table ttcbed002 |* My Table
extern domain ttdyf.picture test.img |* image form field

after.form.read:
bind.image("test.img", "tcbed002.guid")
enable.save.on.occ.change()

after.update.db.commit:
if is.image.changed("test.img) then

save.image.field("test.img)
endif


choice.recover.set:
after.choice:
discard.changed.image("test.img")

Now, start your session and you are done.

It will only work for WebUI and not on Worktop.

Check the snapshot.

All the best!

metropoj
12th February 2015, 18:38
I've been through this example several times and not having any luck.

The goal is to move our image data out of the Items-General table into our own

1. I have created a new table / session as described.
2. I am able to drag and drop into WEBUI my picture. I click on the save button and it is not saving the image, nor when I scroll to and from the record does the image change ( obviously ).

I am not very good with in depth coding.

I thought this code would function as is with a few changes but I'm missing something. Can anyone shed some light ?

my .imag field is a tc.guid domain type, I have a guid there, I drag and drop a picture into the session, it doesn't save.


I have full access to the images folder. Currently our images store themselves in this folder with my id from Items-General.

We have Development licences.


declaration:

table tcxitm101 | Development Table

extern domain ttdyf.picture image.field |* image form field

after.form.read:
bind.image("image.field", "tcxitm101.imag")
message("after form read")
enable.save.on.occ.change()

after.update.db.commit:
if is.image.changed("image.field") then
save.image.field("image.field")
message("after update commit")
endif

choice.recover.set:
after.choice:
discard.changed.image("image.field")


|****************************** Group Section ************************************


|****************************** Function section **********************************

bhushanchanda
12th February 2015, 18:49
Hi,

Have you added a form field on the session?

In your case -

field name = image.field
domain = ttdyf.picture

Once you save, does the rest of the data get saved?

metropoj
12th February 2015, 18:58
Hi, yes. I did the <Insert> <image> onto my form and sized it / named it accordingly.

My understanding was that I only needed a guid type field in my table and the script would assign image.field to type ttdyf.picture

When I click off the record, all my other changes I've made saved to their fields.

The picture I dragged and dropped stays on the screen until I exit. because it never saves it just hangs around :) ...

bhushanchanda
12th February 2015, 19:10
That is interesting. What about the guid? Does that gets any value?

Also, did you take care of these 2 points as well?

4. In your Dynamic Form Editor under session properties, uncheck Overview Session and just tick details session.
5. In you Dynamic Form Editor, add whatever fields you want to display on your session except tcbed002.guid.

metropoj
12th February 2015, 19:22
In DFE, if I rt click on the session name, properties, I made sure "Details" was the only one checked.

I also made sure I didn't have the guid showing on the form.

I found out I needed to create a GUID via script to populate the value, the fields do have a value by using this code :


|****************************** Function section **********************************

functions:


function guid()
{

select cxitm101.guid
from cxitm101 for update
where cxitm101.guid < "1"
selectdo
cxitm101.guid = uuid.generate$()
db.update(tcxitm101,db.retry)
commit.transaction()
endselect

message("GUID updated")

}

bhushanchanda
12th February 2015, 19:32
You do not need a different function to generate guid.

One more question.. Is there a DAL for that table?

metropoj
12th February 2015, 19:40
That is interesting you say that I didn't need code for generating as my values were all empty and we thought maybe that was part of the problem.

I don't have a DAL for the table.

I figured Items-General does a lot of things in the background and why I had no guid being assigned.

bhushanchanda
12th February 2015, 20:09
Yes. LN takes care of generating GUID's.

Some more things to try-

Use this

if bind.image("image.field", "bpmdm001.guid") then
enable.save.on.occ.change()
else
message("Cant bind image")
endif

And this-

if save.image.field("image.field") then
else
message("Unable to save image")
endif

Now, debug your program to see which one is failing.

metropoj
12th February 2015, 20:40
OK, added the 2 pieces of code.

When I run my session, the first message that pops up is "After Form Read" and then message "Can't Bind Image"

I do have a UID present, the Scripting points to it. The second code option never pops up.

bhushanchanda
12th February 2015, 21:06
That means, the image is not binded at first place itself. I am not sure which image file I used at that time. I do not have access to that system currently so cannot try. Might check may be sometime later. Did you try attaching the same file to Item General session?

Your bind.image is returning false so something is wrong with the image file then. Though I am not sure. Or may be your environment is missing some tools solution.

metropoj
13th February 2015, 14:42
I am going to get some help with my code in general here as it triggers immediately when opening the session.

I suspect it should trigger only when I make a change to that field, yes ?

Again I don't do a lot of this, mostly UEDLLs :) ... I will report back for curiosity sake after a review of what I've done so far.

bhushanchanda
13th February 2015, 14:48
Yes, it will get triggered on form load itself. Try with the same image if you are able to use it in Item General. If yes, then you can report open an incident with Infor.

Also, I am assuming you are not using MMT Session.

metropoj
13th February 2015, 14:57
Yeah, I have been reusing images from our library that are attached to items general. I just made a simple session to start to make it all work first before anything fancy.

I'll report back how I make out.

After I select the image and attach it on screen then save/exit the session, I GTM my table for that item. The GUID is still blank. It doesn't create one when I start the session nor write one, that was why I used some code to generate at first.

metropoj
13th February 2015, 18:37
I had placed a call with Infor just to confirm the whole GUID thing.

They say there is a need for code to generate the UUID.

I used the following to do so just as an fyi to other that may have a similar issue:

** This however did not solve my image assignment problem :) I have asked them for assistance to troubleshoot that one. **


functions:

function guid()
{

select cxitm101.uid2
from cxitm101 for update
where cxitm101.uid2=""
selectdo
cxitm101.uid2 = uuid.generate$()
db.update(tcxitm101,db.retry)
commit.transaction()
endselect

message("GUID updated")

}

metropoj
26th February 2015, 14:39
Once in a while you run into one of those things that doesn't work, then all of a sudden starts working for you through some change you make along the way.

This was one of those cases :) ...

I re entered all code from scratch.

I had to use code to assign the GUID upon entry of my session, not sure why if it is not needed by others, but I do need it.

The GUID assigned properly. I still wasn't getting a picture.

I resized my image to match the example above and BAM, it started showing my image.

I resized my image to be that of the size we use in our items-General session, and now it works :mad:

So, what was the solution ? Keeping at it and blindly trying some stuff out.

Thanks for all the assistance in helping me understand this better and coding examples.

This was what i used to get things to populate for me in custom session.


scripting:


declaration:
table tcxitm101

extern domain ttdyf.picture test.img

after.form.read:

select cxitm101.imag
from cxitm101 for update
where cxitm101.imag < "1"
selectdo
cxitm101.imag = uuid.generate$()
db.update(tcxitm101,db.retry)
commit.transaction()
|message ("guid assigned")
endselect

bind.image ("test.img", "cxitm101.imag")
enable.save.on.occ.change()

after.update.db.commit:

select cxitm101.imag
from cxitm101 for update
where cxitm101.imag < "1"
selectdo
cxitm101.imag = uuid.generate$()
db.update(tcxitm101,db.retry)
commit.transaction()
|message ("guid assigned")
endselect

if is.image.changed("test.img") then
save.image.field("test.img")
endif

choice.recover.set:
after.choice:
discard.changed.image("test.img")

bhushanchanda
26th February 2015, 14:47
Yeah, I have been reusing images from our library that are attached to items general.

May be this is the reason? Try reusing the image you have already attached. About the GUID thing. I missed to document that and didn't knew whether it's required or not until I tried it again. Lost memory. :)

Glad you got it working. Yes, you do need to knock your head to get things working :) Keep 't up!

metropoj
26th February 2015, 14:52
no worries, it was time well spent in the end after the solution :)

When I redid my second attempt, I pointed back to the existing GUID field and my session found / shows all the original images so we are glad that happened.

julierme.victor
28th January 2016, 12:54
Dears, good morning,

I need to create a session in ERP LN FP3, which want to save images, but following the example of you could not drag the image to the web UI, see attached what I did, you can help me?:confused:

Regards,
Julierme

metropoj
28th January 2016, 14:41
Your session options look a little different than mine in FP7.

I never saw what you session type is.

Mine is a maintain Session, syncronized dialog to a main session. Dynamic Session and integrated boxes checked on.

So all else works except the drag and drop or it doesn't save at all ?

Your code is different from my example so I am not 100% sure if that is where the issue is.

It was very finicky I remember getting the picture to show on the form based on the size of the window . My picture image properties are width 80 and height 23.

julierme.victor
28th January 2016, 17:37
My session is the type Hold.

Just when I drag the image and try to paste it does not allow.

As for the code did exactly as in your example.:confused:

See the attached image.

bhushanchanda
2nd February 2016, 09:35
Hi,

Can you post your code if any so that someone can figure out the exact issue?

julierme.victor
3rd February 2016, 15:37
Good day,

My code already attached. The file calls image.doc .

This solution does not work for the worktop ?

Regards,