Prevent Warning on READONLY

Questions about and code samples for custom order rules and validation within Select.
Post Reply
timothymeyer16
Posts: 37
Joined: Mon Jun 14, 2021 9:47 am

Prevent Warning on READONLY

Post by timothymeyer16 »

Code: Select all

def Task_Code_ReadOnly(args):
	
		# Allow changes if Blank
		if args.Context.Code == None or args.Context.Code == '':
			args.Value = False
			
		else:
			args.Value =



The idea in the above code is simple. If there is no Task Code, allow a user to input values. If a task code exists, make the field read only.


1.PNG
1.PNG (20.48 KiB) Viewed 2796 times


The functionality is working correctly. After a user inputs data into a blank Task Code, the new code will remain and the field will become ReadOnly.


2.PNG
2.PNG (35.63 KiB) Viewed 2796 times


The issue is an undesired "Can not access member" error pop-up. How do I prevent the error from showing?

Summary:
- Task Code is Blank and not ReadOnly
- Task Code is entered
- An undesired "Can not access member" error appears.
- The new task remains and the field is ReadOnly.


Notes:
- If the task is selected from a lookup table the error does not appear.
- I attempted to add the value with "Task_Code_Value(args), but could not configure it correctly."
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Prevent Warning on READONLY

Post by BobRichards »

I'm afraid there is nothing we can do about that. It is probably related to the way the Select application refreshes the screen when you are tabbing out of the field or some artifact of that.

The only thing I can think of is for you to enable the "Validate data entered in the key field" in the Task Code lookup table. Then at least the user cannot "fat finger" the field and change it to a value not in the table.
LUTable.png
LUTable.png (1.77 KiB) Viewed 2787 times
Additionally you can disable the permission "ProForm\Order\Order Tasks\Task-Edit" for the users. This will prevent the user from editing the text in the Task Description field so it will always be set by the Code in the lookup table.
Task.png
Task.png (8.12 KiB) Viewed 2787 times
Sorry but this is all you can do here.
Bob Richards, Senior Software Developer, SoftPro
timothymeyer16
Posts: 37
Joined: Mon Jun 14, 2021 9:47 am

Re: Prevent Warning on READONLY

Post by timothymeyer16 »

Thank you, this solves multiple issues for us!
normanc
Posts: 3
Joined: Wed Oct 05, 2022 4:02 pm

Re: Prevent Warning on READONLY

Post by normanc »

Hello,

I wanted to see if there was any update or possibly any additional workarounds found for this issue? Our organization is running into the same behavior when setting the Invoice.BillTo field to Read-Only when the user has selected a value:

Code: Select all

def Invoice_BillTo_ReadOnly(args):
	invoice = args.Context
	args.Value = (invoice.BillTo != None)
While the above code successfully sets the BillTo field to Read-Only upon user input, we also receive the Validation Error pop-up (Cannot access member). I have tried a number of different approaches to try to prevent the pop-up from occurring, including:
  • Creating and calling a separate function (Invoice_BillTo_IsPopulated(args)) that returns a boolean back to Invoice_BillTo_ReadOnly
  • Adding a sleep(n) command to Invoice_BillTo_ReadOnly (the pop-up will still occur after the execution sleep time has elapsed
  • Using a _Locked aspect instead of _ReadOnly
  • Unfortunately, we cannot use other order conditions nor use a formula or programmatic approach to populate this field (must be done via user)
Any insight would be greatly appreciated.
PaulMcCullough
Posts: 23
Joined: Wed Jul 12, 2023 11:29 am

Re: Prevent Warning on READONLY

Post by PaulMcCullough »

I checked around with a few people and unfortunately, this is a limitation in the way that Select works. If you try to set ReadOnly on a field from the ReadOnly aspect for the same field, you will see this error when you tab out or select another field.

The only other alternative I can suggest would be to use the value of another field to set ReadOnly = True on the BillTo field. Sorry, I don't have a better answer than that.
Post Reply