cancel
Showing results for 
Search instead for 
Did you mean: 

Date field has to be mandatory only when end date entered?

Former Member
0 Kudos

Hi Gurus,

I have requirement where in which there is a field called return interview date .

This field has to be mandatory only when end date in enterted?

Return Interview Date' should ONLY be mandatory when a sickness end date is entered. That is, when the employee returns to work and the manager enters an end date. In this scenario, the manager should enter the return (end) date of the sickness and MUST also enter a return to work interview date.

Note that when the manager enters the sickness to start with, entering a start date but no end date (and the end date is automatically generated as 1 year in the future), that in this scenario the 'Return Interview' date is NOT mandatory. The field is only mandatory when the sickness end date is entered by the manager.

Please provide the code for the above scenario

Thanks in Advance,

Dharani

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

One way to achieve the same is to create a context atribute of type State

(com.sap.ide.webdynpro.uielementdefinitions.State)and bind the same with the property state of the input field. you can then change the value as and when required using:


wdContext.currentContextElement().setState(WDState.NORMAL)

or
  wdContext.currentContextElement().setState(WDState.REQUIRED)

Former Member
0 Kudos

Hi ,

check the end date and then the Return Interview Date'.

Date d = null;

if(wdcontext.currentcontextElement.getEndDate() != d)

{

if(wdcontext.currentcontextElement.getInterviewDate() != d)

{

// code to be executed when Enddate and interview date

// are enterd

}

else

{

// throw exception when interview date is not entered.

wdComponentAPI.getMessageManager().reportException("Enter Interview Date");

}

}

Thanks,

Sunith Hari

former_member214651
Active Contributor
0 Kudos

Hi Dharani,

There is an option in NWDS for creating an attrinute of type State for dynamically setting the state of a child in ur view.

Based on whether the end date has been entered or not, set the state variable to REQUIRED or STANDARD.

Regards,

Poojith M V

Former Member
0 Kudos

HI

Let me understand ur question, By mandatory, there are two ways

1) You want to show it is mandatory, that means u want a red star in front of it.......

2) You just want to validate the date......

Answer 1. associate a label with ur input field and set the "label for" property of the label to the id of ur input field. Now Make a context of type state(which ucan get in Dictionary Simple Type->com.sap.ide.webdynpro.uielementdefinitions->State) and bind it to the "State" property of ur Return Date.

Now check if the Sickness date==null. if yes, then change the context attribute to "normal" and if it is !=null, change the context attribute to "required". Problem soved.

Answer 2. If u just need to check or just validate the date fields, if Sickness date ==null then proceed. else if Sickness date !=null and Return date ==null, then create a message saying that "Return Date is mandatory"....

Please try this and do let me know if it works or u need any further help in this problem

Regards,

Gita