Try our conversational search powered by Generative AI!

How to make readonly and hide - Commerce Extended Properties under (MetaClass PurchaseOrder) in Edit mode (Commerce version 14.12)



I have two related questions regarding Commerce Extended Properties.

1 - First question - I have fields in Commerce Extended Properties that go under MetaClass PurchaseOrder and want to make it readonly and hide it in edit mode. Is there any example code or settings?

There are a couple of examples related to Block or Page properties to hide in the edit mode in CMS using EditorDescriptor and few other ways but did not see anything for Commerce Extended Properties.

Properties appear in Order Details - Summary at the bottom section and are marked the properties in red.

Order Management

Order Details - Summary

2 - Second question - Similarly, I would like to hide properties under MetaClass OtherPayment and want to make it hide and readonly in edit mode. Is there any example code or settings?

Properties appear in Order Details - Form Details - and click on the Add Payment button under the Transactions section and a popup modal appears as shown in the figure below.

Order Details - Form Details - Add Payment

Sep 24, 2023 12:28

In terms of your first question, though the UI you cannot set fields you create to read only, but if you create them via code you can, by setting it to read only when you create the metafield, for example:

        var metaField = new MetaField(fieldName, friendlyName)
            Owner = MetaClassManagerEditScope.Current.Owner,
            AccessLevel = MetaClassManagerEditScope.Current.AccessLevel,
            TypeName = fieldType,
            IsNullable = allowNulls,
            ReadOnly = true

You could create a startup method that checks if metafields exist, if they don't create them and make sure they're readonly

Jan 16, 2024 18:09
Mansoor - Jan 18, 2024 19:09
Hi JSpencer
Thank you for your response. I would like to display the information on the UI in read-only mode, so the users won't be able to input any data.
The ReadOnly property enables input from the UI, but clicking the save button won't trigger any actions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.