cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a default value in a checkbox

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

praveen_kumar194
Active Contributor
0 Kudos

you can place the logic inside the do prepare out method. you need to check whether image is field is blank or filled as a condition to fill the check boxes accordingly.

durga_prasad25
Participant
0 Kudos

Hi Kristian,

You can do same thing in setter method as well redefined it and set checkbox's value based on the image field .

it will work.

Best Regards,

Durga Prasad

Former Member
0 Kudos

We tried using this method, and it seems to be working. Thank you very much for your feedback!

Former Member
0 Kudos

Hi Durga. Thank you for your input. Very nice to know that the SETTER method also could be a solution.

Former Member
0 Kudos

Hello Kristian , 

   Yes i have done the same thing . The two attributes whic you mentioned - Your get_p_xxxx method looks some thing like this.

METHOD get_p_xxxx.
 
CASE iv_property.
   
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value
= cl_bsp_dlc_view_descriptor=>field_type_checkbox.
   
WHEN if_bsp_wd_model_setter_getter=>fp_server_event.
      rv_value
= 'DEFAULT_CHECKBOX_VALUE'.

 
ENDCASE.ENDMETHOD.

Define a server event and exatly with the same name (case sensitive) create an event handler.

In the event handler,check if the image is filled or not by checking in the current reference and set the property of this check box as 'X' (Checked).

Hope it helped.

Thanks and Regards,

Nikhil Kulkarni

Answers (0)