cancel
Showing results for 
Search instead for 
Did you mean: 

Add current date automatically on field in crm webui

Former Member
0 Kudos

Hi Experts,

I am new in crm ui and I was wondering how can I fill automatically with the current date a field when load for the first time the page?

I already create the field and I use a data element type Dats, so I have the standar search help in the field, but I have the following doubts:

1) if  the user can select another date and I need to compare if the date selected is the current date and if it is the current date disable the field

.

I was wondering in what method the validation should be: in get_p, get_m, get_, set_ I would be thankful you could give an example in source code.

I appreciate your help

thanks in advance John

Accepted Solutions (0)

Answers (1)

Answers (1)

BGarcia
Active Contributor
0 Kudos

Hi John,

I would try to use methods DO_INIT_CONTEXT or DO_PREPARE_OUTPUT (check parameter iv_first_time) of your view controller class to automatically fill the initial date.

For disabling/enabling the field, you can add your logic in GET _I method.

Hope that helps you a little more.

Kind regards,

Garcia

Former Member
0 Kudos

Hi Garcia,

Thanks for your help, could you please give an example using an attribute and filling the field in crm webui with the current date

Thanks John

BGarcia
Active Contributor
0 Kudos

Hi John,

If you generate GETTER and SETTER method for that field, you can call them directly.

Something like: typed_context->your_context_node->set_date( attribute_path = '' value = sy-datum ).

If not, you can instantiate an entity for your context node and change there directly.

Something like:

DATA        lr_entity  TYPE REF TO cl_crm_bol_entity.

lr_entity = typed_context->your_context_node->collection_wrapper->get_current( ).

lr_entity->set_property_as_string( iv_attr_name = 'DATE' iv_value = sy-datum ).

There is a lot of information regarding BOL programming in these CRM foruns there can help you a little more and do some more complex stuff

Kind regards,

Garcia