How to set values at opening time of screen ?

I want to set values at the time of opening of screen. for example, I want to set current user name to entry user column in a screen.
Or I want to set Branch Name based on the login user in a sales screen at the time of opening time. It is to track from which branch the sales is entered. What is the solution ?

1 Like

You can override the following methods in your screen controller:

  • init() is called by the framework after creating components tree described by an XML-descriptor, but before a screen is displayed.
  • ready() is invoked when the screen is fully initialized and opened.
  • postInit() is invoked for an editor screen immediately after the edited entity instance is set to the main datasource.
    See subsections of the Screen Controller section for details.

Ok, Thank you.
Can you give an example to show how to set value of a field in init() function ?

Hi Manoj,

You can see an example here.

Regards,
Aleksey

Thank you for the support.
I want some more clarification. My problem is that , I want to show login user name in a sales screen at the time of creating new sales. I extended the user entity to add branch name for each user. So I want to show the Branch name also in the sales screen. How it is possible in init() function. Please give the script example.
Entities -> sales and userExt .

Can you please provide a picture of your sales screen and where you want to add info about Brunch and User?

1 Like

Thank you for support.
I am attaching 2 screen shots of User extended screen and a voucher entry screen.
In user extended screen I added Branch Name option. It is working properly.
In Voucher entry screen the login user name and related branch should come as default.
How to do it. ? Please help… I am not an expert in Cuba studio. I am a newbie…

Scrn1_user

Scrn2_voucher

Thank you for the explanation. We prepared an example of how you can implement your task. The source code of the example can be found here. Also you can find the sample project in the attachment.

Regards,
Aleksey

ext-user.zip (40.3K)

I changed my script according to your suggestion , but I am getting some errors. Pls find attached images.
My entities are Voucher and ExtUser. I changed VoucherEdit.java as in the attached image, what is the problem.
ExtUser entity -> Branch field.
Voucher entity -> Branch and ucode ( for user name ) are the fields. How I can correct it. ? Pls help.

Scrn3_error

Scrn4_voucheredit

Ok, I solved the problem. Some spelling mistakes. Thank you for excellent support.