Skip to Content
0
Former Member
Oct 24, 2012 at 09:01 AM

How to set a default value in a checkbox

390 Views

Hi

Business has logged a request asking for making the product catalog maintainance easier by setting some default values in some checkboxes whenever they are adding product images to the materials that are assigned to a product catalog.

We are in component/view GS_CM/EditProp trying to set a default value for the following attributes: STRUCT.PCAT_IS_LANG_INDEPDT & STRUCT.PROD_IS_LANG_INDEPDT which both are checkboxes. By standard these fields are of cause blank, but we would like them to be set at marked by default.

By enhancing Implementation Class CL_GS_CM_EDITPROP_IMPL and adding the following logic to method DO_FINISH_INPUT:

Data: lr_prop type ref to if_bol_bo_property_access.

lr_prop ?= me->typed_context->DOCUMENT->collection_wrapper->get_current( ).

if lr_prop is bound.

lr_prop->set_property( iv_attr_name = 'PROD_IS_LANG_INDEPDT' iv_value = 'X' ).

lr_prop->set_property( iv_attr_name = 'PCAT_IS_LANG_INDEPDT' iv_value = 'X' ).

we managed to mark the checkboxes if the user did an action (chóosing the image file on the web ui), but we would rather that the checkboxes was automatically marked whenever an image is added to the product catalog.

We are not sure whether we are enhancing the right method, or whether the right way to go would be to generate a GETTER or SETTER method directly on the attribute?

If you have any experience with a similar case please share this information.

Thanks in advance

Kristian