cancel
Showing results for 
Search instead for 
Did you mean: 

Default value for field in CRM WEB UI

Former Member
0 Kudos

Hi all

I need to set default value for the field in crm web ui.

component AIC_CMCR_H (enhanced) , view AIC_CMCR_H/AICCMCRHeaderEF

Field BTPARTNERSET / EMP_RESP_NAME

I've tried to do like  http://scn.sap.com/thread/1098584

my impl. class is ZL_AIC_CMCR_AICCMCRHEADER_IMPL

method DO_INIT_CONTEXT

code:

CALL METHOD SUPER->DO_INIT_CONTEXT
     .
   data : lv_entity type ref to CL_CRM_BOL_ENTITY.

   lv_entity ?= me->typed_context->BTPARTNERSET->collection_wrapper->get_current( ).
   IF sy-subrc = 0.

    lv_entity->set_property( iv_attr_name = 'PARTNER_FCT'
                             iv_value     = 'SDCR0002' ).
    lv_entity->set_property( iv_attr_name = 'PARTNER_NO'
                             iv_value     = '0000000141' ).
   ENDIF.

---

also tried

    lv_entity->set_property( iv_attr_name = 'EMP_RESP_NAME '
                                       iv_value        = 'XNAME' ).

But i always getting dump with

Entry parameter  of method CL_CRM_BOL_ENTITY->SET_PROPERTY contains value

PARTNER_FCT / PARTNER_NO / EMP_RESP_NAME , which is not allowed

Regards Dan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dan,

The object BTPartnerSet don't have attributes you have mentioned above ,it only has one field CRM_GUID.

So to default the employee responsible you have to create a child entity for the object BTpartnerSet .

Try using the relation 'BTPartner_PFT_0008_MAIN' ( for employee responsible)  from BTpartnerSet object then you will get BTpartner as dependent object. Now you can set the values in entity of BTpartner.

Use the following code as an  example

   TRY.

            lo_partner_set = lo_header->get_related_entity( 'BTHeaderPartnerSet' ).
          CATCH cx_crm_genil_model_error.
        ENDTRY.

        IF lo_partner_set IS BOUND.
          lo_partner_empres = lo_partner_set->get_related_entity( 'BTPartner_PFT_0008_MAIN' ).
* If there is no Empl Resp --> Create Entity
          IF lo_partner_empres IS NOT BOUND.
            IF lo_partner_set->is_changeable( ) = abap_true.
              TRY.
                  lo_partner_empres = lo_partner_set->create_related_entity(
                                        iv_relation_name = 'BTPartner_PFT_0008_MAIN' ).
                CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel.
*               should never happen
              ENDTRY.
            ENDIF.
          ENDIF.

Regards,

Nithish

Former Member
0 Kudos

Hello Nithish and thanks.

How did u get lo_header?

im trying to :

lo_header ?= me->typed_context->BTPARTNERSET->collection_wrapper->get_current( ).

next your example but...

   TRY.

            lo_partner_set = lo_header->get_related_entity( 'BTHeaderPartnerSet' ).
          CATCH cx_crm_genil_model_error.
        ENDTRY.

lo_partner = si INITIAL

i gues i forgot smthng...didn't use abap for a long time ...

Thanks and Regards

Dan

Former Member
0 Kudos

Hi Dan,

Its just an example to fetch from header. In your case you can directly use lo_partner_set entity as you have BTPARTNERSET context node available

lo_partner_set = me->typed_context->BTPARTNERSET->collection_wrapper->get_current( ).

Regards,

Nithish

Former Member
0 Kudos

Worked Thank you very much

Regardly

Dan

Points are yours

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I have a similar requirement to assign a default value to the Employee responsible field while creating campaigns.

Can you please share the complete process required to be done for the same, as i have tried the above but not able to achieve the desired result.

Your help would  be much appreciated.

Regards,

YS