BP_CONT: not getting the contact person email value from custom controller
not able to find the email address in any of the context node, actually my requirement is while creating the BP contact , get the email address BP_ADDR/StandardAddress STRUCT.E_MAILSMT . take this email id and check whether this email id exists in system if exists throw the error while saving . for this I did the codin in BP_CONT component on save method but while saving some times my custom controller is getting initiated some times it was not containing any value , kindly let me know how can I get the email value of contact person in BP_CONT component in view BPCONTOverview .
here is my code on method eh_onsave
lr_curo_bpcont_custcntrlr ?= me->get_custom_controller( controller_id = 'BP_CONT/BPCont' ).
IF lr_curo_bpcont_custcntrlr IS BOUND.
lr_entity_privstdaddr ?= lr_curo_bpcont_custcntrlr->typed_context->privstdaddr->collection_wrapper->get_current( ).
lv_privstdaddr_e_mailsmt = lr_entity_privstdaddr->get_property_as_string('E_MAILSMT'). " Get runtime email value of contact person
lr_entity_bpcategory ?= lr_curo_bpcont_custcntrlr->typed_context->builheader->collection_wrapper->get_current( ).
lv_partner_category = lr_entity_bpcategory->get_property_as_string('BP_CATEGORY'). " Get Partner Category value
CATCH cx_sy_ref_is_initial cx_sy_move_cast_error cx_crm_genil_model_error.
here the problem is some times I'm getting the value and some times I'm not getting value the related objects also through get related entities contact person emial is not getting populated any where
kindly help what is going wrong
Thanks & Regards