The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 9, 2016
Company: CTC

Hi,

how can I manage the visibility of commands or input fields in a form from the code . For example, lets say I have a Sales order that has an input field Customer. And lets assume I have a command button called "Process Order". I want when I click on the command button "Process Order" to make the Customer input field disabled or invisible or any other property from the command code.

with regards,
Mubarak

 
#2
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 9, 2016
Company: CTC

my version is: 1C:Enterprise 8.3 (8.3.8.1479)

 
#3
People who like this: 1 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

You can change properties "ReadOnly" or "Enabled in the "ProcessOrder" command. You need only one of them.

Code
Items.Customer.ReadOnly = True;
Items.Customer.Enabled = False;


But when you reopen a form, "Customer" field would be enabled again. So, to solve this problem you need to add a new attribute, for example OrderProcessingStarted, fill this attribute in the "ProcessOrder" command and modify procedure "OnCreateAtServer".

Something like this:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
 Items.Customer.Enabled = Not Object.OrderProcessingStarted;
EndProcedure

&AtClient
Procedure Start(Command)
 Object.OrderProcessingStarted = True;
 Items.Customer.Enabled = False;
EndProcedure

 
#4
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 9, 2016
Company: CTC

Hello Alexei,

thank you very much. "Items." is what I was looking for. I tried to use "Form." or "Object." trying to know how can I get to fields in the form. "Items." is the container.

appreciate your quick answer.

 
Subscribe
Users browsing this topic (guests: 2, registered: 0, hidden: 0)